Whamcloud - gitweb
LU-13645 ldlm: extra checks for DOM locks 78/39878/6
authorVitaly Fertman <c17818@cray.com>
Wed, 2 Sep 2020 17:14:06 +0000 (20:14 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 30 Oct 2020 06:20:08 +0000 (06:20 +0000)
a couple of checks are added:
- only DOM lock can be a group lock;
- DOM bit must be the only mandatory one, or optional;

Signed-off-by: Vitaly Fertman <c17818@cray.com>
HPE-bug-id: LUS-8987
Change-Id: Iaf7a14a66eb0f125d2f6f7d06f5de0add387e101
Reviewed-on: https://review.whamcloud.com/39878
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_inodebits.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lproc.c
lustre/mdt/mdt_open.c

index 68914d9..220f651 100644 (file)
@@ -178,6 +178,11 @@ ldlm_inodebits_compat_queue(struct list_head *queue, struct ldlm_lock *req,
        if ((req_bits | *try_bits) == 0)
                RETURN(0);
 
+       /* Group lock could be only DOM */
+       if (unlikely(req_mode == LCK_GROUP &&
+                    (req_bits | *try_bits) != MDS_INODELOCK_DOM))
+               RETURN(-EPROTO);
+
        list_for_each(tmp, queue) {
                struct list_head *mode_tail;
 
@@ -285,6 +290,18 @@ ldlm_inodebits_compat_queue(struct list_head *queue, struct ldlm_lock *req,
                                        if (*ldlm_flags & LDLM_FL_BLOCK_NOWAIT)
                                                RETURN(-EWOULDBLOCK);
 
+                                       /* Combined DOM lock came across GROUP
+                                        * DOM lock, it makes the thread to be
+                                        * blocked for a long time, not allowed,
+                                        * the trybits to be used instead.
+                                        * Not combined DOM lock is requested by
+                                        * client, and have to wait for long
+                                        * until re-worked to a non-intent
+                                        * request). */
+                                       if ((req_bits & MDS_INODELOCK_DOM) &&
+                                           (req_bits & ~MDS_INODELOCK_DOM))
+                                               RETURN(-EPROTO);
+
                                        goto skip_work_list;
                                }
 
index e1b12aa..a106e45 100644 (file)
@@ -197,6 +197,7 @@ struct coordinator {
 enum {
        NO_DOM_LOCK_ON_OPEN = 0,
        TRYLOCK_DOM_ON_OPEN = 1,
+       /* not used anymore, left here for compatibility */
        ALWAYS_DOM_LOCK_ON_OPEN = 2,
        NUM_DOM_LOCK_ON_OPEN_MODES
 };
index 452c7cc..3dc1b07 100644 (file)
@@ -981,6 +981,9 @@ static ssize_t dom_lock_store(struct kobject *kobj, struct attribute *attr,
                        return rc;
        }
 
+       if (val == ALWAYS_DOM_LOCK_ON_OPEN)
+               val = TRYLOCK_DOM_ON_OPEN;
+
        if (val < 0 || val >= NUM_DOM_LOCK_ON_OPEN_MODES)
                return -EINVAL;
 
index b2c7536..5b474a4 100644 (file)
@@ -900,15 +900,7 @@ static int mdt_object_open_lock(struct mdt_thread_info *info,
                        lhc = &info->mti_lh[MDT_LH_LOCAL];
                } else if (dom_lock) {
                        lm = (open_flags & MDS_FMODE_WRITE) ? LCK_PW : LCK_PR;
-                       if (dom_lock == TRYLOCK_DOM_ON_OPEN) {
-                               trybits |= MDS_INODELOCK_DOM |
-                                          MDS_INODELOCK_LAYOUT;
-                       } else {
-                               /* dom_lock == ALWAYS_DOM_LOCK_ON_OPEN */
-                               *ibits = MDS_INODELOCK_DOM;
-                               if (info->mti_mdt->mdt_opts.mo_dom_read_open)
-                                       trybits |= MDS_INODELOCK_LAYOUT;
-                       }
+                       trybits |= MDS_INODELOCK_DOM | MDS_INODELOCK_LAYOUT;
                }
 
                CDEBUG(D_INODE, "normal open:"DFID" lease count: %d, lm: %d\n",