From 0a3c72f13045309573f74f2e02771035d734cc05 Mon Sep 17 00:00:00 2001 From: Vitaly Fertman Date: Wed, 2 Sep 2020 20:14:06 +0300 Subject: [PATCH] LU-13645 ldlm: extra checks for DOM locks 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 HPE-bug-id: LUS-8987 Change-Id: Iaf7a14a66eb0f125d2f6f7d06f5de0add387e101 Reviewed-on: https://review.whamcloud.com/39878 Reviewed-by: Mike Pershin Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_inodebits.c | 17 +++++++++++++++++ lustre/mdt/mdt_internal.h | 1 + lustre/mdt/mdt_lproc.c | 3 +++ lustre/mdt/mdt_open.c | 10 +--------- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/lustre/ldlm/ldlm_inodebits.c b/lustre/ldlm/ldlm_inodebits.c index 68914d9..220f651 100644 --- a/lustre/ldlm/ldlm_inodebits.c +++ b/lustre/ldlm/ldlm_inodebits.c @@ -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; } diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index e1b12aa..a106e45 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -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 }; diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 452c7cc..3dc1b07 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -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; diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index b2c7536..5b474a4 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -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", -- 1.8.3.1