Print this page
NEX-3758 Support for remote stale lock detection
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/flock_impl.h
          +++ new/usr/src/uts/common/sys/flock_impl.h
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   * and limitations under the License.
  13   13   *
  14   14   * When distributing Covered Code, include this CDDL HEADER in each
  15   15   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   16   * If applicable, add the following below this CDDL HEADER, with the
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
       22 +
  22   23  /*
       24 + * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       25 + */
       26 +
       27 +/*
  23   28   * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24   29   * Use is subject to license terms.
  25   30   * Copyright 2015 Joyent, Inc.
  26   31   */
  27   32  
  28   33  #ifndef _SYS_FLOCK_IMPL_H
  29   34  #define _SYS_FLOCK_IMPL_H
  30   35  
  31   36  #include <sys/types.h>
  32   37  #include <sys/fcntl.h>          /* flock definition */
↓ open down ↓ 3 lines elided ↑ open up ↑
  36   41  #include <sys/user.h>
  37   42  #include <sys/thread.h>
  38   43  #include <sys/proc.h>
  39   44  #include <sys/cred.h>
  40   45  #include <sys/debug.h>
  41   46  #include <sys/cmn_err.h>
  42   47  #include <sys/errno.h>
  43   48  #include <sys/systm.h>
  44   49  #include <sys/vnode.h>
  45   50  #include <sys/share.h>          /* just to get GETSYSID def */
       51 +#include <sys/time.h>
  46   52  
  47   53  #ifdef  __cplusplus
  48   54  extern "C" {
  49   55  #endif
  50   56  
  51   57  struct  edge {
  52   58          struct  edge    *edge_adj_next; /* adjacency list next */
  53   59          struct  edge    *edge_adj_prev; /* adjacency list prev */
  54   60          struct  edge    *edge_in_next;  /* incoming edges list next */
  55   61          struct  edge    *edge_in_prev;  /* incoming edges list prev */
↓ open down ↓ 4 lines elided ↑ open up ↑
  60   66  typedef struct  edge    edge_t;
  61   67  
  62   68  struct lock_descriptor {
  63   69          struct  lock_descriptor *l_next;        /* next active/sleep lock */
  64   70          struct  lock_descriptor *l_prev;        /* previous active/sleep lock */
  65   71          struct  edge            l_edge;         /* edge for adj and in lists */
  66   72          struct  lock_descriptor *l_stack;       /* for stack operations */
  67   73          struct  lock_descriptor *l_stack1;      /* for stack operations */
  68   74          struct  lock_descriptor *l_dstack;      /* stack for debug functions */
  69   75          struct  edge            *l_sedge;       /* start edge for graph alg. */
  70      -                        int     l_index;        /* used for barrier count */
  71      -                struct  graph   *l_graph;       /* graph this belongs to */
  72      -                vnode_t         *l_vnode;       /* vnode being locked */
  73      -                        int     l_type;         /* type of lock */
  74      -                        int     l_state;        /* state described below */
  75      -                u_offset_t      l_start;        /* start offset */
  76      -                u_offset_t      l_end;          /* end offset */
  77      -                flock64_t       l_flock;        /* original flock request */
  78      -                        int     l_color;        /* color used for graph alg */
  79      -                kcondvar_t      l_cv;           /* wait condition for lock */
  80      -                int             pvertex;        /* index to proc vertex */
  81      -                        int     l_status;       /* status described below */
  82      -                flk_nlm_status_t l_nlm_state;   /* state of NLM server */
  83      -                flk_callback_t  *l_callbacks;   /* callbacks, or NULL */
  84      -                zoneid_t        l_zoneid;       /* zone of request */
  85      -                file_t          *l_ofd;         /* OFD-style reference */
       76 +        int                     l_index;        /* used for barrier count */
       77 +        struct  graph           *l_graph;       /* graph this belongs to */
       78 +        vnode_t                 *l_vnode;       /* vnode being locked */
       79 +        int                     l_type;         /* type of lock */
       80 +        int                     l_state;        /* state described below */
       81 +        u_offset_t              l_start;        /* start offset */
       82 +        u_offset_t              l_end;          /* end offset */
       83 +        flock64_t               l_flock;        /* original flock request */
       84 +        int                     l_color;        /* color used for graph alg */
       85 +        kcondvar_t              l_cv;           /* wait condition for lock */
       86 +        int                     pvertex;        /* index to proc vertex */
       87 +        int                     l_status;       /* status described below */
       88 +        flk_nlm_status_t        l_nlm_state;    /* state of NLM server */
       89 +        flk_callback_t          *l_callbacks;   /* callbacks, or NULL */
       90 +        zoneid_t                l_zoneid;       /* zone of request */
       91 +        hrtime_t                l_blocker;      /* time when this lock */
       92 +                                                /* started to prevent other */
       93 +                                                /* locks from being set */
       94 +        file_t                  *l_ofd;         /* OFD-style reference */
  86   95  };
  87   96  
  88   97  typedef struct  lock_descriptor lock_descriptor_t;
  89   98  
  90   99  /*
  91  100   * Each graph holds locking information for some number of vnodes.  The
  92  101   * active and sleeping lists are circular, with a dummy head element.
  93  102   */
  94  103  
  95  104  struct  graph {
↓ open down ↓ 295 lines elided ↑ open up ↑
 391  400  {       \
 392  401  (lock1)->l_graph = (lock2)->l_graph; \
 393  402  (lock1)->l_vnode = (lock2)->l_vnode; \
 394  403  (lock1)->l_type = (lock2)->l_type; \
 395  404  (lock1)->l_state = (lock2)->l_state; \
 396  405  (lock1)->l_start = (lock2)->l_start; \
 397  406  (lock1)->l_end = (lock2)->l_end; \
 398  407  (lock1)->l_flock = (lock2)->l_flock; \
 399  408  (lock1)->l_zoneid = (lock2)->l_zoneid; \
 400  409  (lock1)->pvertex = (lock2)->pvertex; \
      410 +(lock1)->l_blocker = (lock2)->l_blocker; \
 401  411  }
 402  412  
 403  413  /*
 404  414   * Clustering
 405  415   */
 406  416  /* Routines to set and get the NLM state in a lock request */
 407  417  #define SET_NLM_STATE(lock, nlm_state)  ((lock)->l_nlm_state = nlm_state)
 408  418  #define GET_NLM_STATE(lock)     ((lock)->l_nlm_state)
 409  419  /*
 410  420   * NLM registry abstraction:
↓ open down ↓ 82 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX