"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/features/locks/src/common.h" (16 Sep 2020, 8746 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "common.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2    Copyright (c) 2006-2012, 2015-2016 Red Hat, Inc. <http://www.redhat.com>
    3    This file is part of GlusterFS.
    4 
    5    This file is licensed to you under your choice of the GNU Lesser
    6    General Public License, version 3 or any later version (LGPLv3 or
    7    later), or the GNU General Public License, version 2 (GPLv2), in all
    8    cases as published by the Free Software Foundation.
    9 */
   10 #ifndef __COMMON_H__
   11 #define __COMMON_H__
   12 
   13 /*dump locks format strings */
   14 #define RANGE_FMT "type=%s, whence=%hd, start=%llu, len=%llu"
   15 #define ENTRY_FMT "type=%s on basename=%s"
   16 #define DUMP_GEN_FMT "pid = %llu, owner=%s, client=%p"
   17 #define GRNTD_AT "granted at %s"
   18 #define BLKD_AT "blocked at %s"
   19 #define CONN_ID "connection-id=%s"
   20 #define DUMP_BLKD_FMT DUMP_GEN_FMT ", " CONN_ID ", " BLKD_AT
   21 #define DUMP_GRNTD_FMT DUMP_GEN_FMT ", " CONN_ID ", " GRNTD_AT
   22 #define DUMP_BLKD_GRNTD_FMT DUMP_GEN_FMT ", " CONN_ID ", " BLKD_AT ", " GRNTD_AT
   23 
   24 #define ENTRY_BLKD_FMT ENTRY_FMT ", " DUMP_BLKD_FMT
   25 #define ENTRY_GRNTD_FMT ENTRY_FMT ", " DUMP_GRNTD_FMT
   26 #define ENTRY_BLKD_GRNTD_FMT ENTRY_FMT ", " DUMP_BLKD_GRNTD_FMT
   27 
   28 #define RANGE_BLKD_FMT RANGE_FMT ", " DUMP_BLKD_FMT
   29 #define RANGE_GRNTD_FMT RANGE_FMT ", " DUMP_GRNTD_FMT
   30 #define RANGE_BLKD_GRNTD_FMT RANGE_FMT ", " DUMP_BLKD_GRNTD_FMT
   31 
   32 #define SET_FLOCK_PID(flock, lock) ((flock)->l_pid = lock->client_pid)
   33 
   34 #define PL_STACK_UNWIND_AND_FREE(__local, fop, frame, op_ret, params...)       \
   35     do {                                                                       \
   36         frame->local = NULL;                                                   \
   37         STACK_UNWIND_STRICT(fop, frame, op_ret, params);                       \
   38         if (__local) {                                                         \
   39             if (__local->inodelk_dom_count_req)                                \
   40                 data_unref(__local->inodelk_dom_count_req);                    \
   41             loc_wipe(&__local->loc[0]);                                        \
   42             loc_wipe(&__local->loc[1]);                                        \
   43             if (__local->fd)                                                   \
   44                 fd_unref(__local->fd);                                         \
   45             if (__local->inode)                                                \
   46                 inode_unref(__local->inode);                                   \
   47             if (__local->xdata) {                                              \
   48                 dict_unref(__local->xdata);                                    \
   49                 __local->xdata = NULL;                                         \
   50             }                                                                  \
   51             mem_put(__local);                                                  \
   52         }                                                                      \
   53     } while (0)
   54 
   55 posix_lock_t *
   56 new_posix_lock(struct gf_flock *flock, client_t *client, pid_t client_pid,
   57                gf_lkowner_t *owner, fd_t *fd, uint32_t lk_flags, int blocking,
   58                int32_t *op_errno);
   59 
   60 pl_inode_t *
   61 pl_inode_get(xlator_t *this, inode_t *inode, pl_local_t *local);
   62 
   63 posix_lock_t *
   64 pl_getlk(pl_inode_t *inode, posix_lock_t *lock);
   65 
   66 int
   67 pl_setlk(xlator_t *this, pl_inode_t *inode, posix_lock_t *lock, int can_block);
   68 
   69 int
   70 pl_lock_preempt(pl_inode_t *pl_inode, posix_lock_t *reqlock);
   71 
   72 void
   73 grant_blocked_locks(xlator_t *this, pl_inode_t *inode);
   74 
   75 void
   76 posix_lock_to_flock(posix_lock_t *lock, struct gf_flock *flock);
   77 
   78 int
   79 locks_overlap(posix_lock_t *l1, posix_lock_t *l2);
   80 
   81 int
   82 same_owner(posix_lock_t *l1, posix_lock_t *l2);
   83 
   84 void
   85 __delete_lock(posix_lock_t *);
   86 
   87 void
   88 __destroy_lock(posix_lock_t *);
   89 
   90 pl_dom_list_t *
   91 get_domain(pl_inode_t *pl_inode, const char *volume);
   92 
   93 void
   94 grant_blocked_inode_locks(xlator_t *this, pl_inode_t *pl_inode,
   95                           pl_dom_list_t *dom, struct timespec *now,
   96                           struct list_head *contend);
   97 
   98 void
   99 inodelk_contention_notify(xlator_t *this, struct list_head *contend);
  100 
  101 void
  102 __delete_inode_lock(pl_inode_lock_t *lock);
  103 
  104 void
  105 __pl_inodelk_unref(pl_inode_lock_t *lock);
  106 
  107 void
  108 __grant_blocked_inode_locks(xlator_t *this, pl_inode_t *pl_inode,
  109                             struct list_head *granted, pl_dom_list_t *dom,
  110                             struct timespec *now, struct list_head *contend);
  111 
  112 void
  113 unwind_granted_inodes(xlator_t *this, pl_inode_t *pl_inode,
  114                       struct list_head *granted);
  115 
  116 void
  117 grant_blocked_entry_locks(xlator_t *this, pl_inode_t *pl_inode,
  118                           pl_dom_list_t *dom, struct timespec *now,
  119                           struct list_head *contend);
  120 
  121 void
  122 entrylk_contention_notify(xlator_t *this, struct list_head *contend);
  123 
  124 void
  125 pl_update_refkeeper(xlator_t *this, inode_t *inode);
  126 
  127 int32_t
  128 __get_inodelk_count(xlator_t *this, pl_inode_t *pl_inode, char *domname);
  129 int32_t
  130 get_inodelk_count(xlator_t *this, inode_t *inode, char *domname);
  131 
  132 int32_t
  133 __get_entrylk_count(xlator_t *this, pl_inode_t *pl_inode);
  134 int32_t
  135 get_entrylk_count(xlator_t *this, inode_t *inode);
  136 
  137 void
  138 pl_trace_in(xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc, int cmd,
  139             struct gf_flock *flock, const char *domain);
  140 
  141 void
  142 pl_trace_out(xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc, int cmd,
  143              struct gf_flock *flock, int op_ret, int op_errno,
  144              const char *domain);
  145 
  146 void
  147 pl_trace_block(xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc,
  148                int cmd, struct gf_flock *flock, const char *domain);
  149 
  150 void
  151 pl_trace_flush(xlator_t *this, call_frame_t *frame, fd_t *fd);
  152 
  153 void
  154 entrylk_trace_in(xlator_t *this, call_frame_t *frame, const char *volume,
  155                  fd_t *fd, loc_t *loc, const char *basename, entrylk_cmd cmd,
  156                  entrylk_type type);
  157 
  158 void
  159 entrylk_trace_out(xlator_t *this, call_frame_t *frame, const char *volume,
  160                   fd_t *fd, loc_t *loc, const char *basename, entrylk_cmd cmd,
  161                   entrylk_type type, int op_ret, int op_errno);
  162 
  163 void
  164 entrylk_trace_block(xlator_t *this, call_frame_t *frame, const char *volume,
  165                     fd_t *fd, loc_t *loc, const char *basename, entrylk_cmd cmd,
  166                     entrylk_type type);
  167 
  168 void
  169 pl_print_verdict(char *str, int size, int op_ret, int op_errno);
  170 
  171 void
  172 pl_print_lockee(char *str, int size, fd_t *fd, loc_t *loc);
  173 
  174 void
  175 pl_print_locker(char *str, int size, xlator_t *this, call_frame_t *frame);
  176 
  177 void
  178 pl_print_inodelk(char *str, int size, int cmd, struct gf_flock *flock,
  179                  const char *domain);
  180 
  181 void
  182 pl_trace_release(xlator_t *this, fd_t *fd);
  183 
  184 unsigned long
  185 fd_to_fdnum(fd_t *fd);
  186 
  187 fd_t *
  188 fd_from_fdnum(posix_lock_t *lock);
  189 
  190 int
  191 pl_reserve_setlk(xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
  192                  int can_block);
  193 int
  194 reservelks_equal(posix_lock_t *l1, posix_lock_t *l2);
  195 
  196 int
  197 pl_verify_reservelk(xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
  198                     int can_block);
  199 int
  200 pl_reserve_unlock(xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *reqlock);
  201 
  202 int32_t
  203 check_entrylk_on_basename(xlator_t *this, inode_t *parent, char *basename);
  204 
  205 void
  206 __pl_inodelk_unref(pl_inode_lock_t *lock);
  207 void
  208 __pl_entrylk_unref(pl_entry_lock_t *lock);
  209 
  210 int
  211 pl_metalock_is_active(pl_inode_t *pl_inode);
  212 
  213 void
  214 __pl_queue_lock(pl_inode_t *pl_inode, posix_lock_t *reqlock);
  215 
  216 void
  217 inodelk_contention_notify_check(xlator_t *xl, pl_inode_lock_t *lock,
  218                                 struct timespec *now,
  219                                 struct list_head *contend);
  220 
  221 void
  222 entrylk_contention_notify_check(xlator_t *xl, pl_entry_lock_t *lock,
  223                                 struct timespec *now,
  224                                 struct list_head *contend);
  225 
  226 gf_boolean_t
  227 pl_does_monkey_want_stuck_lock();
  228 
  229 gf_boolean_t
  230 pl_is_mandatory_locking_enabled(pl_inode_t *pl_inode);
  231 
  232 void
  233 pl_clean_local(pl_local_t *local);
  234 
  235 int
  236 pl_local_init(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd);
  237 
  238 gf_boolean_t
  239 pl_is_lk_owner_valid(gf_lkowner_t *owner, client_t *client);
  240 
  241 int32_t
  242 pl_inode_remove_prepare(xlator_t *xl, call_frame_t *frame, loc_t *loc,
  243                         pl_inode_t **ppl_inode, struct list_head *contend);
  244 
  245 int32_t
  246 pl_inode_remove_complete(xlator_t *xl, pl_inode_t *pl_inode, call_stub_t *stub,
  247                          struct list_head *contend);
  248 
  249 void
  250 pl_inode_remove_wake(struct list_head *list);
  251 
  252 void
  253 pl_inode_remove_cbk(xlator_t *xl, pl_inode_t *pl_inode, int32_t error);
  254 
  255 void
  256 pl_inode_remove_unlocked(xlator_t *xl, pl_inode_t *pl_inode,
  257                          struct list_head *list);
  258 
  259 int32_t
  260 pl_inode_remove_inodelk(pl_inode_t *pl_inode, pl_inode_lock_t *lock);
  261 
  262 #endif /* __COMMON_H__ */