From: Patrick Farrell Date: Mon, 3 Dec 2018 16:36:08 +0000 (-0600) Subject: LU-11719 ldlm: Adjust search_* functions X-Git-Tag: 2.12.51~71 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=a231148843bd4a30d962378841160602180c88d8 LU-11719 ldlm: Adjust search_* functions The search_itree and search_queue functions should both return either a pointer to a found lock or NULL. Currently, search_itree just returns the contents of data->lmd_lock, whether or not a lock was found. search_queue will do the same under certain cirumstances. Zero lmd_lock in both search_* functions, and also stop searching in search_itree once a lock is found. cray-bug-id: LUS-6783 Signed-off-by: Patrick Farrell Change-Id: Ie231166756e60c228370f8f1a019ccfe14dfda6a Reviewed-on: https://review.whamcloud.com/33754 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 5e7afe6..f83971c 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -1262,6 +1262,8 @@ static struct ldlm_lock *search_itree(struct ldlm_resource *res, }; int idx; + data->lmd_lock = NULL; + for (idx = 0; idx < LCK_MODE_NUM; idx++) { struct ldlm_interval_tree *tree = &res->lr_itree[idx]; @@ -1273,8 +1275,11 @@ static struct ldlm_lock *search_itree(struct ldlm_resource *res, interval_search(tree->lit_root, &ext, itree_overlap_cb, data); + if (data->lmd_lock) + return data->lmd_lock; } - return data->lmd_lock; + + return NULL; } @@ -1292,11 +1297,14 @@ static struct ldlm_lock *search_queue(struct list_head *queue, struct ldlm_lock *lock; int rc; + data->lmd_lock = NULL; + list_for_each_entry(lock, queue, l_res_link) { rc = lock_matches(lock, data); if (rc == INTERVAL_ITER_STOP) return data->lmd_lock; } + return NULL; }