From f3b45a05475d8c65f06c81f41176b5a7f7d1acaa 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) ) Signed-off-by: Alex Zhuravlev Change-Id: I7bb20d62948224647d7632f2822fba44d39a7713 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53051 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Mikhail Pershin Reviewed-by: Oleg Drokin --- 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 0fc4c1b..85df949 100644 --- a/lustre/ldlm/ldlm_inodebits.c +++ b/lustre/ldlm/ldlm_inodebits.c @@ -571,6 +571,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