Whamcloud - gitweb
LU-11285 mdt: improve IBITS lock definitions 55/35955/2
authorAndreas Dilger <adilger@whamcloud.com>
Mon, 3 Jun 2019 18:21:53 +0000 (12:21 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 12 Sep 2019 03:51:18 +0000 (03:51 +0000)
Move MDS_INODELOCK_* flags into a named enum, and add the definitions
for the newer flags into wirecheck/wiretest to ensure consistency.

Rename MDS_INODELOCK_MAXSHIFT to MDS_INODELOCK_NUMBITS to hold current
number of lockbits, rather than one less than the number of lockbits,
since the only two places that use it expect it to be one larger than
it is.  Fix uses of MDS_INODELOCK_NUMBITS to be number of locks.  This
does not change the value of MDS_INODELOCK_FULL, which is used in the
protocol to exchange supported lock bits between client and server.

Lustre-change: https://review.whamcloud.com/35045
Lustre-commit: 3611352b699ce479779c0ff92ca558d9321e58a2

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I0c2985bcc602b7182d5db2cf8d590923be2cab07
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/35955
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Stephan Thiell <sthiell@stanford.edu>
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/llite/file.c
lustre/ptlrpc/wiretest.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index d9b4428..aaeadbd 100644 (file)
@@ -1681,29 +1681,31 @@ enum mds_reint_op {
 #define DISP_OPEN_DENY      0x10000000
 
 /* INODE LOCK PARTS */
-#define MDS_INODELOCK_LOOKUP 0x000001  /* For namespace, dentry etc, and also
-                                        * was used to protect permission (mode,
-                                        * owner, group etc) before 2.4. */
-#define MDS_INODELOCK_UPDATE 0x000002  /* size, links, timestamps */
-#define MDS_INODELOCK_OPEN   0x000004  /* For opened files */
-#define MDS_INODELOCK_LAYOUT 0x000008  /* for layout */
-
-/* The PERM bit is added int 2.4, and it is used to protect permission(mode,
- * owner, group, acl etc), so to separate the permission from LOOKUP lock.
- * Because for remote directories(in DNE), these locks will be granted by
- * different MDTs(different ldlm namespace).
- *
- * For local directory, MDT will always grant UPDATE_LOCK|PERM_LOCK together.
- * For Remote directory, the master MDT, where the remote directory is, will
- * grant UPDATE_LOCK|PERM_LOCK, and the remote MDT, where the name entry is,
- * will grant LOOKUP_LOCK. */
-#define MDS_INODELOCK_PERM   0x000010
-#define MDS_INODELOCK_XATTR  0x000020  /* extended attributes */
-#define MDS_INODELOCK_DOM    0x000040 /* Data for data-on-mdt files */
-
-#define MDS_INODELOCK_MAXSHIFT 6
+enum mds_ibits_locks {
+       MDS_INODELOCK_LOOKUP    = 0x000001, /* For namespace, dentry etc.  Was
+                                            * used to protect permission (mode,
+                                            * owner, group, etc) before 2.4. */
+       MDS_INODELOCK_UPDATE    = 0x000002, /* size, links, timestamps */
+       MDS_INODELOCK_OPEN      = 0x000004, /* For opened files */
+       MDS_INODELOCK_LAYOUT    = 0x000008, /* for layout */
+
+       /* The PERM bit is added in 2.4, and is used to protect permission
+        * (mode, owner, group, ACL, etc.) separate from LOOKUP lock.
+        * For remote directories (in DNE) these locks will be granted by
+        * different MDTs (different LDLM namespace).
+        *
+        * For local directory, the MDT always grants UPDATE|PERM together.
+        * For remote directory, master MDT (where remote directory is) grants
+        * UPDATE|PERM, and remote MDT (where name entry is) grants LOOKUP_LOCK.
+        */
+       MDS_INODELOCK_PERM      = 0x000010,
+       MDS_INODELOCK_XATTR     = 0x000020, /* non-permission extended attrs */
+       MDS_INODELOCK_DOM       = 0x000040, /* Data for Data-on-MDT files */
+       /* Do not forget to increase MDS_INODELOCK_NUMBITS when adding bits */
+};
+#define MDS_INODELOCK_NUMBITS 7
 /* This FULL lock is useful to take on unlink sort of operations */
-#define MDS_INODELOCK_FULL ((1<<(MDS_INODELOCK_MAXSHIFT+1))-1)
+#define MDS_INODELOCK_FULL ((1 << MDS_INODELOCK_NUMBITS) - 1)
 /* DOM lock shouldn't be canceled early, use this macro for ELC */
 #define MDS_INODELOCK_ELC (MDS_INODELOCK_FULL & ~MDS_INODELOCK_DOM)
 
index 7f8f257..623d5b9 100644 (file)
@@ -4271,7 +4271,7 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, enum ldlm_mode l_req_mode)
                ldlm_lockname[mode]);
 
        flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK;
-       for (i = 0; i <= MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) {
+       for (i = 0; i < MDS_INODELOCK_NUMBITS && *bits != 0; i++) {
                policy.l_inodebits.bits = *bits & (1 << i);
                if (policy.l_inodebits.bits == 0)
                        continue;
index 63cba8b..ddaa44a 100644 (file)
@@ -2515,6 +2515,12 @@ void lustre_assert_wire_constants(void)
                MDS_INODELOCK_OPEN);
        LASSERTF(MDS_INODELOCK_LAYOUT == 0x000008, "found 0x%.8x\n",
                MDS_INODELOCK_LAYOUT);
+       LASSERTF(MDS_INODELOCK_PERM == 0x000010, "found 0x%.8x\n",
+               MDS_INODELOCK_PERM);
+       LASSERTF(MDS_INODELOCK_XATTR == 0x000020, "found 0x%.8x\n",
+               MDS_INODELOCK_XATTR);
+       LASSERTF(MDS_INODELOCK_DOM == 0x000040, "found 0x%.8x\n",
+               MDS_INODELOCK_DOM);
 
        /* Checks for struct mdt_ioepoch */
        LASSERTF((int)sizeof(struct mdt_ioepoch) == 24, "found %lld\n",
index 04d7a66..b938530 100644 (file)
@@ -1132,6 +1132,9 @@ check_mdt_body(void)
        CHECK_DEFINE_X(MDS_INODELOCK_UPDATE);
        CHECK_DEFINE_X(MDS_INODELOCK_OPEN);
        CHECK_DEFINE_X(MDS_INODELOCK_LAYOUT);
+       CHECK_DEFINE_X(MDS_INODELOCK_PERM);
+       CHECK_DEFINE_X(MDS_INODELOCK_XATTR);
+       CHECK_DEFINE_X(MDS_INODELOCK_DOM);
 }
 
 static void
index 51b82a5..1c1c45b 100644 (file)
@@ -2522,6 +2522,12 @@ void lustre_assert_wire_constants(void)
                MDS_INODELOCK_OPEN);
        LASSERTF(MDS_INODELOCK_LAYOUT == 0x000008, "found 0x%.8x\n",
                MDS_INODELOCK_LAYOUT);
+       LASSERTF(MDS_INODELOCK_PERM == 0x000010, "found 0x%.8x\n",
+               MDS_INODELOCK_PERM);
+       LASSERTF(MDS_INODELOCK_XATTR == 0x000020, "found 0x%.8x\n",
+               MDS_INODELOCK_XATTR);
+       LASSERTF(MDS_INODELOCK_DOM == 0x000040, "found 0x%.8x\n",
+               MDS_INODELOCK_DOM);
 
        /* Checks for struct mdt_ioepoch */
        LASSERTF((int)sizeof(struct mdt_ioepoch) == 24, "found %lld\n",