From 9d3815b47992ab8ba374ff3f0f1bec2aa0d14bf1 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Thu, 9 Nov 2023 16:29:03 +0300 Subject: [PATCH] LU-17278 ldlm: don't grant failed lock lock convert can re-grant lock if it loses some bits. this procedure can race with the import's invalidation. thus lock can become invalid (l_granted_mode=LCK_MINMODE): LustreError: 8637:0:(ldlm_lock.c:1095:ldlm_grant_lock_with_skiplist()) ASSERTION( ldlm_is_granted(lock) ) Lustre-change: https://review.whamcloud.com/53051 Lustre-commit: f3b45a05475d8c65f06c81f41176b5a7f7d1acaa Signed-off-by: Alex Zhuravlev Change-Id: I7bb20d62948224647d7632f2822fba44d39a7713 Reviewed-by: Andreas Dilger Reviewed-by: Mikhail Pershin Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53286 Tested-by: jenkins Tested-by: Maloo --- lustre/ldlm/ldlm_inodebits.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lustre/ldlm/ldlm_inodebits.c b/lustre/ldlm/ldlm_inodebits.c index fad8fc6..502cb6b 100644 --- a/lustre/ldlm/ldlm_inodebits.c +++ b/lustre/ldlm/ldlm_inodebits.c @@ -558,6 +558,14 @@ int ldlm_cli_inodebits_convert(struct ldlm_lock *lock, if (rc) GOTO(full_cancel, rc); + /* + * check that the lock is still actual as it could get + * invalidated by an eviction being unproteced few + * lines above. + */ + if (ldlm_is_failed(lock)) + GOTO(full_cancel, rc = -EINVAL); + /* Finally clear these bits in lock ibits */ ldlm_inodebits_drop(lock, drop_bits); -- 1.8.3.1