From 4ddd1965a6a8c5bbdc04ac26ace09ba6e32bee34 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 3 Dec 2018 10:36:08 -0600 Subject: [PATCH] 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 Reviewed-on: https://review.whamcloud.com/40399 Tested-by: jenkins --- lustre/ldlm/ldlm_lock.c | 10 +++++++++- lustre/osc/osc_lock.c | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 3b403ff..64d331f 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -1285,6 +1285,8 @@ 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]; @@ -1296,8 +1298,11 @@ 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; } EXPORT_SYMBOL(search_itree); @@ -1316,11 +1321,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; } diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index ced5c41..8bd0f47 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -590,7 +590,7 @@ int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) cl_object_get(obj); } unlock_res_and_lock(dlmlock); - LDLM_LOCK_PUT(dlmlock); + LDLM_LOCK_RELEASE(dlmlock); dlmlock = NULL; -- 1.8.3.1