Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /******************************************************************************
0003 *******************************************************************************
0004 **
0005 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
0006 **  Copyright (C) 2004-2011 Red Hat, Inc.  All rights reserved.
0007 **
0008 **
0009 *******************************************************************************
0010 ******************************************************************************/
0011 
0012 #ifndef __DLM_INTERNAL_DOT_H__
0013 #define __DLM_INTERNAL_DOT_H__
0014 
0015 /*
0016  * This is the main header file to be included in each DLM source file.
0017  */
0018 
0019 #include <linux/slab.h>
0020 #include <linux/sched.h>
0021 #include <linux/types.h>
0022 #include <linux/ctype.h>
0023 #include <linux/spinlock.h>
0024 #include <linux/vmalloc.h>
0025 #include <linux/list.h>
0026 #include <linux/errno.h>
0027 #include <linux/random.h>
0028 #include <linux/delay.h>
0029 #include <linux/socket.h>
0030 #include <linux/kthread.h>
0031 #include <linux/kobject.h>
0032 #include <linux/kref.h>
0033 #include <linux/kernel.h>
0034 #include <linux/jhash.h>
0035 #include <linux/miscdevice.h>
0036 #include <linux/mutex.h>
0037 #include <linux/idr.h>
0038 #include <linux/ratelimit.h>
0039 #include <linux/uaccess.h>
0040 
0041 #include <linux/dlm.h>
0042 #include "config.h"
0043 
0044 struct dlm_ls;
0045 struct dlm_lkb;
0046 struct dlm_rsb;
0047 struct dlm_member;
0048 struct dlm_rsbtable;
0049 struct dlm_recover;
0050 struct dlm_header;
0051 struct dlm_message;
0052 struct dlm_rcom;
0053 struct dlm_mhandle;
0054 struct dlm_msg;
0055 
0056 #define log_print(fmt, args...) \
0057     printk(KERN_ERR "dlm: "fmt"\n" , ##args)
0058 #define log_print_ratelimited(fmt, args...) \
0059     printk_ratelimited(KERN_ERR "dlm: "fmt"\n", ##args)
0060 #define log_error(ls, fmt, args...) \
0061     printk(KERN_ERR "dlm: %s: " fmt "\n", (ls)->ls_name , ##args)
0062 
0063 #define log_rinfo(ls, fmt, args...) \
0064 do { \
0065     if (dlm_config.ci_log_info) \
0066         printk(KERN_INFO "dlm: %s: " fmt "\n", \
0067             (ls)->ls_name, ##args); \
0068     else if (dlm_config.ci_log_debug) \
0069         printk(KERN_DEBUG "dlm: %s: " fmt "\n", \
0070                (ls)->ls_name , ##args); \
0071 } while (0)
0072 
0073 #define log_debug(ls, fmt, args...) \
0074 do { \
0075     if (dlm_config.ci_log_debug) \
0076         printk(KERN_DEBUG "dlm: %s: " fmt "\n", \
0077                (ls)->ls_name , ##args); \
0078 } while (0)
0079 
0080 #define log_limit(ls, fmt, args...) \
0081 do { \
0082     if (dlm_config.ci_log_debug) \
0083         printk_ratelimited(KERN_DEBUG "dlm: %s: " fmt "\n", \
0084             (ls)->ls_name , ##args); \
0085 } while (0)
0086 
0087 #define DLM_ASSERT(x, do) \
0088 { \
0089   if (!(x)) \
0090   { \
0091     printk(KERN_ERR "\nDLM:  Assertion failed on line %d of file %s\n" \
0092                "DLM:  assertion:  \"%s\"\n" \
0093                "DLM:  time = %lu\n", \
0094                __LINE__, __FILE__, #x, jiffies); \
0095     {do} \
0096     printk("\n"); \
0097     panic("DLM:  Record message above and reboot.\n"); \
0098   } \
0099 }
0100 
0101 
0102 #define DLM_RTF_SHRINK      0x00000001
0103 
0104 struct dlm_rsbtable {
0105     struct rb_root      keep;
0106     struct rb_root      toss;
0107     spinlock_t      lock;
0108     uint32_t        flags;
0109 };
0110 
0111 
0112 /*
0113  * Lockspace member (per node in a ls)
0114  */
0115 
0116 struct dlm_member {
0117     struct list_head    list;
0118     int         nodeid;
0119     int         weight;
0120     int         slot;
0121     int         slot_prev;
0122     int         comm_seq;
0123     uint32_t        generation;
0124 };
0125 
0126 /*
0127  * Save and manage recovery state for a lockspace.
0128  */
0129 
0130 struct dlm_recover {
0131     struct list_head    list;
0132     struct dlm_config_node  *nodes;
0133     int         nodes_count;
0134     uint64_t        seq;
0135 };
0136 
0137 /*
0138  * Pass input args to second stage locking function.
0139  */
0140 
0141 struct dlm_args {
0142     uint32_t        flags;
0143     void            (*astfn) (void *astparam);
0144     void            *astparam;
0145     void            (*bastfn) (void *astparam, int mode);
0146     int         mode;
0147     struct dlm_lksb     *lksb;
0148 #ifdef CONFIG_DLM_DEPRECATED_API
0149     unsigned long       timeout;
0150 #endif
0151 };
0152 
0153 
0154 /*
0155  * Lock block
0156  *
0157  * A lock can be one of three types:
0158  *
0159  * local copy      lock is mastered locally
0160  *                 (lkb_nodeid is zero and DLM_LKF_MSTCPY is not set)
0161  * process copy    lock is mastered on a remote node
0162  *                 (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is not set)
0163  * master copy     master node's copy of a lock owned by remote node
0164  *                 (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is set)
0165  *
0166  * lkb_exflags: a copy of the most recent flags arg provided to dlm_lock or
0167  * dlm_unlock.  The dlm does not modify these or use any private flags in
0168  * this field; it only contains DLM_LKF_ flags from dlm.h.  These flags
0169  * are sent as-is to the remote master when the lock is remote.
0170  *
0171  * lkb_flags: internal dlm flags (DLM_IFL_ prefix) from dlm_internal.h.
0172  * Some internal flags are shared between the master and process nodes;
0173  * these shared flags are kept in the lower two bytes.  One of these
0174  * flags set on the master copy will be propagated to the process copy
0175  * and v.v.  Other internal flags are private to the master or process
0176  * node (e.g. DLM_IFL_MSTCPY).  These are kept in the high two bytes.
0177  *
0178  * lkb_sbflags: status block flags.  These flags are copied directly into
0179  * the caller's lksb.sb_flags prior to the dlm_lock/dlm_unlock completion
0180  * ast.  All defined in dlm.h with DLM_SBF_ prefix.
0181  *
0182  * lkb_status: the lock status indicates which rsb queue the lock is
0183  * on, grant, convert, or wait.  DLM_LKSTS_ WAITING/GRANTED/CONVERT
0184  *
0185  * lkb_wait_type: the dlm message type (DLM_MSG_ prefix) for which a
0186  * reply is needed.  Only set when the lkb is on the lockspace waiters
0187  * list awaiting a reply from a remote node.
0188  *
0189  * lkb_nodeid: when the lkb is a local copy, nodeid is 0; when the lkb
0190  * is a master copy, nodeid specifies the remote lock holder, when the
0191  * lkb is a process copy, the nodeid specifies the lock master.
0192  */
0193 
0194 /* lkb_status */
0195 
0196 #define DLM_LKSTS_WAITING   1
0197 #define DLM_LKSTS_GRANTED   2
0198 #define DLM_LKSTS_CONVERT   3
0199 
0200 /* lkb_flags */
0201 
0202 #define DLM_IFL_MSTCPY      0x00010000
0203 #define DLM_IFL_RESEND      0x00020000
0204 #define DLM_IFL_DEAD        0x00040000
0205 #define DLM_IFL_OVERLAP_UNLOCK  0x00080000
0206 #define DLM_IFL_OVERLAP_CANCEL  0x00100000
0207 #define DLM_IFL_ENDOFLIFE   0x00200000
0208 #ifdef CONFIG_DLM_DEPRECATED_API
0209 #define DLM_IFL_WATCH_TIMEWARN  0x00400000
0210 #define DLM_IFL_TIMEOUT_CANCEL  0x00800000
0211 #endif
0212 #define DLM_IFL_DEADLOCK_CANCEL 0x01000000
0213 #define DLM_IFL_STUB_MS     0x02000000 /* magic number for m_flags */
0214 /* least significant 2 bytes are message changed, they are full transmitted
0215  * but at receive side only the 2 bytes LSB will be set.
0216  *
0217  * Even wireshark dlm dissector does only evaluate the lower bytes and note
0218  * that they may not be used on transceiver side, we assume the higher bytes
0219  * are for internal use or reserved so long they are not parsed on receiver
0220  * side.
0221  */
0222 #define DLM_IFL_USER        0x00000001
0223 #define DLM_IFL_ORPHAN      0x00000002
0224 
0225 #define DLM_CALLBACKS_SIZE  6
0226 
0227 #define DLM_CB_CAST     0x00000001
0228 #define DLM_CB_BAST     0x00000002
0229 #define DLM_CB_SKIP     0x00000004
0230 
0231 struct dlm_callback {
0232     uint64_t        seq;
0233     uint32_t        flags;      /* DLM_CBF_ */
0234     int         sb_status;  /* copy to lksb status */
0235     uint8_t         sb_flags;   /* copy to lksb flags */
0236     int8_t          mode; /* rq mode of bast, gr mode of cast */
0237 };
0238 
0239 struct dlm_lkb {
0240     struct dlm_rsb      *lkb_resource;  /* the rsb */
0241     struct kref     lkb_ref;
0242     int         lkb_nodeid; /* copied from rsb */
0243     int         lkb_ownpid; /* pid of lock owner */
0244     uint32_t        lkb_id;     /* our lock ID */
0245     uint32_t        lkb_remid;  /* lock ID on remote partner */
0246     uint32_t        lkb_exflags;    /* external flags from caller */
0247     uint32_t        lkb_sbflags;    /* lksb flags */
0248     uint32_t        lkb_flags;  /* internal flags */
0249     uint32_t        lkb_lvbseq; /* lvb sequence number */
0250 
0251     int8_t          lkb_status;     /* granted, waiting, convert */
0252     int8_t          lkb_rqmode; /* requested lock mode */
0253     int8_t          lkb_grmode; /* granted lock mode */
0254     int8_t          lkb_highbast;   /* highest mode bast sent for */
0255 
0256     int8_t          lkb_wait_type;  /* type of reply waiting for */
0257     int8_t          lkb_wait_count;
0258     int         lkb_wait_nodeid; /* for debugging */
0259 
0260     struct list_head    lkb_statequeue; /* rsb g/c/w list */
0261     struct list_head    lkb_rsb_lookup; /* waiting for rsb lookup */
0262     struct list_head    lkb_wait_reply; /* waiting for remote reply */
0263     struct list_head    lkb_ownqueue;   /* list of locks for a process */
0264     ktime_t         lkb_timestamp;
0265 
0266 #ifdef CONFIG_DLM_DEPRECATED_API
0267     struct list_head    lkb_time_list;
0268     unsigned long       lkb_timeout_cs;
0269 #endif
0270 
0271     struct mutex        lkb_cb_mutex;
0272     struct work_struct  lkb_cb_work;
0273     struct list_head    lkb_cb_list; /* for ls_cb_delay or proc->asts */
0274     struct dlm_callback lkb_callbacks[DLM_CALLBACKS_SIZE];
0275     struct dlm_callback lkb_last_cast;
0276     struct dlm_callback lkb_last_bast;
0277     ktime_t         lkb_last_cast_time; /* for debugging */
0278     ktime_t         lkb_last_bast_time; /* for debugging */
0279 
0280     uint64_t        lkb_recover_seq; /* from ls_recover_seq */
0281 
0282     char            *lkb_lvbptr;
0283     struct dlm_lksb     *lkb_lksb;      /* caller's status block */
0284     void            (*lkb_astfn) (void *astparam);
0285     void            (*lkb_bastfn) (void *astparam, int mode);
0286     union {
0287         void            *lkb_astparam;  /* caller's ast arg */
0288         struct dlm_user_args    *lkb_ua;
0289     };
0290 };
0291 
0292 /*
0293  * res_master_nodeid is "normal": 0 is unset/invalid, non-zero is the real
0294  * nodeid, even when nodeid is our_nodeid.
0295  *
0296  * res_nodeid is "odd": -1 is unset/invalid, zero means our_nodeid,
0297  * greater than zero when another nodeid.
0298  *
0299  * (TODO: remove res_nodeid and only use res_master_nodeid)
0300  */
0301 
0302 struct dlm_rsb {
0303     struct dlm_ls       *res_ls;    /* the lockspace */
0304     struct kref     res_ref;
0305     struct mutex        res_mutex;
0306     unsigned long       res_flags;
0307     int         res_length; /* length of rsb name */
0308     int         res_nodeid;
0309     int         res_master_nodeid;
0310     int         res_dir_nodeid;
0311     int         res_id;     /* for ls_recover_idr */
0312     uint32_t                res_lvbseq;
0313     uint32_t        res_hash;
0314     uint32_t        res_bucket; /* rsbtbl */
0315     unsigned long       res_toss_time;
0316     uint32_t        res_first_lkid;
0317     struct list_head    res_lookup; /* lkbs waiting on first */
0318     union {
0319         struct list_head    res_hashchain;
0320         struct rb_node      res_hashnode;   /* rsbtbl */
0321     };
0322     struct list_head    res_grantqueue;
0323     struct list_head    res_convertqueue;
0324     struct list_head    res_waitqueue;
0325 
0326     struct list_head    res_root_list;      /* used for recovery */
0327     struct list_head    res_recover_list;   /* used for recovery */
0328     int         res_recover_locks_count;
0329 
0330     char            *res_lvbptr;
0331     char            res_name[DLM_RESNAME_MAXLEN+1];
0332 };
0333 
0334 /* dlm_master_lookup() flags */
0335 
0336 #define DLM_LU_RECOVER_DIR  1
0337 #define DLM_LU_RECOVER_MASTER   2
0338 
0339 /* dlm_master_lookup() results */
0340 
0341 #define DLM_LU_MATCH        1
0342 #define DLM_LU_ADD      2
0343 
0344 /* find_rsb() flags */
0345 
0346 #define R_REQUEST       0x00000001
0347 #define R_RECEIVE_REQUEST   0x00000002
0348 #define R_RECEIVE_RECOVER   0x00000004
0349 
0350 /* rsb_flags */
0351 
0352 enum rsb_flags {
0353     RSB_MASTER_UNCERTAIN,
0354     RSB_VALNOTVALID,
0355     RSB_VALNOTVALID_PREV,
0356     RSB_NEW_MASTER,
0357     RSB_NEW_MASTER2,
0358     RSB_RECOVER_CONVERT,
0359     RSB_RECOVER_GRANT,
0360     RSB_RECOVER_LVB_INVAL,
0361 };
0362 
0363 static inline void rsb_set_flag(struct dlm_rsb *r, enum rsb_flags flag)
0364 {
0365     __set_bit(flag, &r->res_flags);
0366 }
0367 
0368 static inline void rsb_clear_flag(struct dlm_rsb *r, enum rsb_flags flag)
0369 {
0370     __clear_bit(flag, &r->res_flags);
0371 }
0372 
0373 static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag)
0374 {
0375     return test_bit(flag, &r->res_flags);
0376 }
0377 
0378 
0379 /* dlm_header is first element of all structs sent between nodes */
0380 
0381 #define DLM_HEADER_MAJOR    0x00030000
0382 #define DLM_HEADER_MINOR    0x00000002
0383 
0384 #define DLM_VERSION_3_1     0x00030001
0385 #define DLM_VERSION_3_2     0x00030002
0386 
0387 #define DLM_HEADER_SLOTS    0x00000001
0388 
0389 #define DLM_MSG         1
0390 #define DLM_RCOM        2
0391 #define DLM_OPTS        3
0392 #define DLM_ACK         4
0393 #define DLM_FIN         5
0394 
0395 struct dlm_header {
0396     __le32          h_version;
0397     union {
0398         /* for DLM_MSG and DLM_RCOM */
0399         __le32      h_lockspace;
0400         /* for DLM_ACK and DLM_OPTS */
0401         __le32      h_seq;
0402     } u;
0403     __le32          h_nodeid;   /* nodeid of sender */
0404     __le16          h_length;
0405     uint8_t         h_cmd;      /* DLM_MSG, DLM_RCOM */
0406     uint8_t         h_pad;
0407 };
0408 
0409 #define DLM_MSG_REQUEST     1
0410 #define DLM_MSG_CONVERT     2
0411 #define DLM_MSG_UNLOCK      3
0412 #define DLM_MSG_CANCEL      4
0413 #define DLM_MSG_REQUEST_REPLY   5
0414 #define DLM_MSG_CONVERT_REPLY   6
0415 #define DLM_MSG_UNLOCK_REPLY    7
0416 #define DLM_MSG_CANCEL_REPLY    8
0417 #define DLM_MSG_GRANT       9
0418 #define DLM_MSG_BAST        10
0419 #define DLM_MSG_LOOKUP      11
0420 #define DLM_MSG_REMOVE      12
0421 #define DLM_MSG_LOOKUP_REPLY    13
0422 #define DLM_MSG_PURGE       14
0423 
0424 struct dlm_message {
0425     struct dlm_header   m_header;
0426     __le32          m_type;     /* DLM_MSG_ */
0427     __le32          m_nodeid;
0428     __le32          m_pid;
0429     __le32          m_lkid;     /* lkid on sender */
0430     __le32          m_remid;    /* lkid on receiver */
0431     __le32          m_parent_lkid;
0432     __le32          m_parent_remid;
0433     __le32          m_exflags;
0434     __le32          m_sbflags;
0435     __le32          m_flags;
0436     __le32          m_lvbseq;
0437     __le32          m_hash;
0438     __le32          m_status;
0439     __le32          m_grmode;
0440     __le32          m_rqmode;
0441     __le32          m_bastmode;
0442     __le32          m_asts;
0443     __le32          m_result;   /* 0 or -EXXX */
0444     char            m_extra[];  /* name or lvb */
0445 };
0446 
0447 
0448 #define DLM_RS_NODES        0x00000001
0449 #define DLM_RS_NODES_ALL    0x00000002
0450 #define DLM_RS_DIR      0x00000004
0451 #define DLM_RS_DIR_ALL      0x00000008
0452 #define DLM_RS_LOCKS        0x00000010
0453 #define DLM_RS_LOCKS_ALL    0x00000020
0454 #define DLM_RS_DONE     0x00000040
0455 #define DLM_RS_DONE_ALL     0x00000080
0456 
0457 #define DLM_RCOM_STATUS     1
0458 #define DLM_RCOM_NAMES      2
0459 #define DLM_RCOM_LOOKUP     3
0460 #define DLM_RCOM_LOCK       4
0461 #define DLM_RCOM_STATUS_REPLY   5
0462 #define DLM_RCOM_NAMES_REPLY    6
0463 #define DLM_RCOM_LOOKUP_REPLY   7
0464 #define DLM_RCOM_LOCK_REPLY 8
0465 
0466 struct dlm_rcom {
0467     struct dlm_header   rc_header;
0468     __le32          rc_type;    /* DLM_RCOM_ */
0469     __le32          rc_result;  /* multi-purpose */
0470     __le64          rc_id;      /* match reply with request */
0471     __le64          rc_seq;     /* sender's ls_recover_seq */
0472     __le64          rc_seq_reply;   /* remote ls_recover_seq */
0473     char            rc_buf[];
0474 };
0475 
0476 struct dlm_opt_header {
0477     __le16      t_type;
0478     __le16      t_length;
0479     __le32      t_pad;
0480     /* need to be 8 byte aligned */
0481     char        t_value[];
0482 };
0483 
0484 /* encapsulation header */
0485 struct dlm_opts {
0486     struct dlm_header   o_header;
0487     uint8_t         o_nextcmd;
0488     uint8_t         o_pad;
0489     __le16          o_optlen;
0490     __le32          o_pad2;
0491     char            o_opts[];
0492 };
0493 
0494 union dlm_packet {
0495     struct dlm_header   header;     /* common to other two */
0496     struct dlm_message  message;
0497     struct dlm_rcom     rcom;
0498     struct dlm_opts     opts;
0499 };
0500 
0501 #define DLM_RSF_NEED_SLOTS  0x00000001
0502 
0503 /* RCOM_STATUS data */
0504 struct rcom_status {
0505     __le32          rs_flags;
0506     __le32          rs_unused1;
0507     __le64          rs_unused2;
0508 };
0509 
0510 /* RCOM_STATUS_REPLY data */
0511 struct rcom_config {
0512     __le32          rf_lvblen;
0513     __le32          rf_lsflags;
0514 
0515     /* DLM_HEADER_SLOTS adds: */
0516     __le32          rf_flags;
0517     __le16          rf_our_slot;
0518     __le16          rf_num_slots;
0519     __le32          rf_generation;
0520     __le32          rf_unused1;
0521     __le64          rf_unused2;
0522 };
0523 
0524 struct rcom_slot {
0525     __le32          ro_nodeid;
0526     __le16          ro_slot;
0527     __le16          ro_unused1;
0528     __le64          ro_unused2;
0529 };
0530 
0531 struct rcom_lock {
0532     __le32          rl_ownpid;
0533     __le32          rl_lkid;
0534     __le32          rl_remid;
0535     __le32          rl_parent_lkid;
0536     __le32          rl_parent_remid;
0537     __le32          rl_exflags;
0538     __le32          rl_flags;
0539     __le32          rl_lvbseq;
0540     __le32          rl_result;
0541     int8_t          rl_rqmode;
0542     int8_t          rl_grmode;
0543     int8_t          rl_status;
0544     int8_t          rl_asts;
0545     __le16          rl_wait_type;
0546     __le16          rl_namelen;
0547     char            rl_name[DLM_RESNAME_MAXLEN];
0548     char            rl_lvb[];
0549 };
0550 
0551 /*
0552  * The max number of resources per rsbtbl bucket that shrink will attempt
0553  * to remove in each iteration.
0554  */
0555 
0556 #define DLM_REMOVE_NAMES_MAX 8
0557 
0558 struct dlm_ls {
0559     struct list_head    ls_list;    /* list of lockspaces */
0560     dlm_lockspace_t     *ls_local_handle;
0561     uint32_t        ls_global_id;   /* global unique lockspace ID */
0562     uint32_t        ls_generation;
0563     uint32_t        ls_exflags;
0564     int         ls_lvblen;
0565     atomic_t        ls_count;   /* refcount of processes in
0566                            the dlm using this ls */
0567     wait_queue_head_t   ls_count_wait;
0568     int         ls_create_count; /* create/release refcount */
0569     unsigned long       ls_flags;   /* LSFL_ */
0570     unsigned long       ls_scan_time;
0571     struct kobject      ls_kobj;
0572 
0573     struct idr      ls_lkbidr;
0574     spinlock_t      ls_lkbidr_spin;
0575 
0576     struct dlm_rsbtable *ls_rsbtbl;
0577     uint32_t        ls_rsbtbl_size;
0578 
0579     struct mutex        ls_waiters_mutex;
0580     struct list_head    ls_waiters; /* lkbs needing a reply */
0581 
0582     struct mutex        ls_orphans_mutex;
0583     struct list_head    ls_orphans;
0584 
0585 #ifdef CONFIG_DLM_DEPRECATED_API
0586     struct mutex        ls_timeout_mutex;
0587     struct list_head    ls_timeout;
0588 #endif
0589 
0590     spinlock_t      ls_new_rsb_spin;
0591     int         ls_new_rsb_count;
0592     struct list_head    ls_new_rsb; /* new rsb structs */
0593 
0594     spinlock_t      ls_remove_spin;
0595     wait_queue_head_t   ls_remove_wait;
0596     char            ls_remove_name[DLM_RESNAME_MAXLEN+1];
0597     char            *ls_remove_names[DLM_REMOVE_NAMES_MAX];
0598     int         ls_remove_len;
0599     int         ls_remove_lens[DLM_REMOVE_NAMES_MAX];
0600 
0601     struct list_head    ls_nodes;   /* current nodes in ls */
0602     struct list_head    ls_nodes_gone;  /* dead node list, recovery */
0603     int         ls_num_nodes;   /* number of nodes in ls */
0604     int         ls_low_nodeid;
0605     int         ls_total_weight;
0606     int         *ls_node_array;
0607 
0608     int         ls_slot;
0609     int         ls_num_slots;
0610     int         ls_slots_size;
0611     struct dlm_slot     *ls_slots;
0612 
0613     struct dlm_rsb      ls_stub_rsb;    /* for returning errors */
0614     struct dlm_lkb      ls_stub_lkb;    /* for returning errors */
0615     struct dlm_message  ls_stub_ms; /* for faking a reply */
0616 
0617     struct dentry       *ls_debug_rsb_dentry; /* debugfs */
0618     struct dentry       *ls_debug_waiters_dentry; /* debugfs */
0619     struct dentry       *ls_debug_locks_dentry; /* debugfs */
0620     struct dentry       *ls_debug_all_dentry; /* debugfs */
0621     struct dentry       *ls_debug_toss_dentry; /* debugfs */
0622 
0623     wait_queue_head_t   ls_uevent_wait; /* user part of join/leave */
0624     int         ls_uevent_result;
0625     struct completion   ls_recovery_done;
0626     int         ls_recovery_result;
0627 
0628     struct miscdevice       ls_device;
0629 
0630     struct workqueue_struct *ls_callback_wq;
0631 
0632     /* recovery related */
0633 
0634     struct mutex        ls_cb_mutex;
0635     struct list_head    ls_cb_delay; /* save for queue_work later */
0636     struct timer_list   ls_timer;
0637     struct task_struct  *ls_recoverd_task;
0638     struct mutex        ls_recoverd_active;
0639     spinlock_t      ls_recover_lock;
0640     unsigned long       ls_recover_begin; /* jiffies timestamp */
0641     uint32_t        ls_recover_status; /* DLM_RS_ */
0642     uint64_t        ls_recover_seq;
0643     struct dlm_recover  *ls_recover_args;
0644     struct rw_semaphore ls_in_recovery; /* block local requests */
0645     struct rw_semaphore ls_recv_active; /* block dlm_recv */
0646     struct list_head    ls_requestqueue;/* queue remote requests */
0647     atomic_t        ls_requestqueue_cnt;
0648     wait_queue_head_t   ls_requestqueue_wait;
0649     struct mutex        ls_requestqueue_mutex;
0650     struct dlm_rcom     *ls_recover_buf;
0651     int         ls_recover_nodeid; /* for debugging */
0652     unsigned int        ls_recover_dir_sent_res; /* for log info */
0653     unsigned int        ls_recover_dir_sent_msg; /* for log info */
0654     unsigned int        ls_recover_locks_in; /* for log info */
0655     uint64_t        ls_rcom_seq;
0656     spinlock_t      ls_rcom_spin;
0657     struct list_head    ls_recover_list;
0658     spinlock_t      ls_recover_list_lock;
0659     int         ls_recover_list_count;
0660     struct idr      ls_recover_idr;
0661     spinlock_t      ls_recover_idr_lock;
0662     wait_queue_head_t   ls_wait_general;
0663     wait_queue_head_t   ls_recover_lock_wait;
0664     struct mutex        ls_clear_proc_locks;
0665 
0666     struct list_head    ls_root_list;   /* root resources */
0667     struct rw_semaphore ls_root_sem;    /* protect root_list */
0668 
0669     const struct dlm_lockspace_ops *ls_ops;
0670     void            *ls_ops_arg;
0671 
0672     int         ls_namelen;
0673     char            ls_name[1];
0674 };
0675 
0676 /*
0677  * LSFL_RECOVER_STOP - dlm_ls_stop() sets this to tell dlm recovery routines
0678  * that they should abort what they're doing so new recovery can be started.
0679  *
0680  * LSFL_RECOVER_DOWN - dlm_ls_stop() sets this to tell dlm_recoverd that it
0681  * should do down_write() on the in_recovery rw_semaphore. (doing down_write
0682  * within dlm_ls_stop causes complaints about the lock acquired/released
0683  * in different contexts.)
0684  *
0685  * LSFL_RECOVER_LOCK - dlm_recoverd holds the in_recovery rw_semaphore.
0686  * It sets this after it is done with down_write() on the in_recovery
0687  * rw_semaphore and clears it after it has released the rw_semaphore.
0688  *
0689  * LSFL_RECOVER_WORK - dlm_ls_start() sets this to tell dlm_recoverd that it
0690  * should begin recovery of the lockspace.
0691  *
0692  * LSFL_RUNNING - set when normal locking activity is enabled.
0693  * dlm_ls_stop() clears this to tell dlm locking routines that they should
0694  * quit what they are doing so recovery can run.  dlm_recoverd sets
0695  * this after recovery is finished.
0696  */
0697 
0698 #define LSFL_RECOVER_STOP   0
0699 #define LSFL_RECOVER_DOWN   1
0700 #define LSFL_RECOVER_LOCK   2
0701 #define LSFL_RECOVER_WORK   3
0702 #define LSFL_RUNNING        4
0703 
0704 #define LSFL_RCOM_READY     5
0705 #define LSFL_RCOM_WAIT      6
0706 #define LSFL_UEVENT_WAIT    7
0707 #ifdef CONFIG_DLM_DEPRECATED_API
0708 #define LSFL_TIMEWARN       8
0709 #endif
0710 #define LSFL_CB_DELAY       9
0711 #define LSFL_NODIR      10
0712 
0713 /* much of this is just saving user space pointers associated with the
0714    lock that we pass back to the user lib with an ast */
0715 
0716 struct dlm_user_args {
0717     struct dlm_user_proc    *proc; /* each process that opens the lockspace
0718                       device has private data
0719                       (dlm_user_proc) on the struct file,
0720                       the process's locks point back to it*/
0721     struct dlm_lksb     lksb;
0722     struct dlm_lksb __user  *user_lksb;
0723     void __user     *castparam;
0724     void __user     *castaddr;
0725     void __user     *bastparam;
0726     void __user     *bastaddr;
0727     uint64_t        xid;
0728 };
0729 
0730 #define DLM_PROC_FLAGS_CLOSING 1
0731 #define DLM_PROC_FLAGS_COMPAT  2
0732 
0733 /* locks list is kept so we can remove all a process's locks when it
0734    exits (or orphan those that are persistent) */
0735 
0736 struct dlm_user_proc {
0737     dlm_lockspace_t     *lockspace;
0738     unsigned long       flags; /* DLM_PROC_FLAGS */
0739     struct list_head    asts;
0740     spinlock_t      asts_spin;
0741     struct list_head    locks;
0742     spinlock_t      locks_spin;
0743     struct list_head    unlocking;
0744     wait_queue_head_t   wait;
0745 };
0746 
0747 static inline int dlm_locking_stopped(struct dlm_ls *ls)
0748 {
0749     return !test_bit(LSFL_RUNNING, &ls->ls_flags);
0750 }
0751 
0752 static inline int dlm_recovery_stopped(struct dlm_ls *ls)
0753 {
0754     return test_bit(LSFL_RECOVER_STOP, &ls->ls_flags);
0755 }
0756 
0757 static inline int dlm_no_directory(struct dlm_ls *ls)
0758 {
0759     return test_bit(LSFL_NODIR, &ls->ls_flags);
0760 }
0761 
0762 #ifdef CONFIG_DLM_DEPRECATED_API
0763 int dlm_netlink_init(void);
0764 void dlm_netlink_exit(void);
0765 void dlm_timeout_warn(struct dlm_lkb *lkb);
0766 #else
0767 static inline int dlm_netlink_init(void) { return 0; }
0768 static inline void dlm_netlink_exit(void) { };
0769 static inline void dlm_timeout_warn(struct dlm_lkb *lkb) { };
0770 #endif
0771 int dlm_plock_init(void);
0772 void dlm_plock_exit(void);
0773 
0774 #ifdef CONFIG_DLM_DEBUG
0775 void dlm_register_debugfs(void);
0776 void dlm_unregister_debugfs(void);
0777 void dlm_create_debug_file(struct dlm_ls *ls);
0778 void dlm_delete_debug_file(struct dlm_ls *ls);
0779 void *dlm_create_debug_comms_file(int nodeid, void *data);
0780 void dlm_delete_debug_comms_file(void *ctx);
0781 #else
0782 static inline void dlm_register_debugfs(void) { }
0783 static inline void dlm_unregister_debugfs(void) { }
0784 static inline void dlm_create_debug_file(struct dlm_ls *ls) { }
0785 static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
0786 static inline void *dlm_create_debug_comms_file(int nodeid, void *data) { return NULL; }
0787 static inline void dlm_delete_debug_comms_file(void *ctx) { }
0788 #endif
0789 
0790 #endif              /* __DLM_INTERNAL_DOT_H__ */
0791