summaryrefslogtreecommitdiffstats
path: root/fs/dlm
diff options
context:
space:
mode:
authorAlexander Aring <aahringo@redhat.com>2022-05-02 11:14:10 -0400
committerDavid Teigland <teigland@redhat.com>2022-05-02 11:23:49 -0500
commit8e51ec6146fdec82f7308f89113497631013f16a (patch)
treeb2ca657b32bb99488d760c16832ca5c9f909550a /fs/dlm
parent9502a7f688fe7bff297b4e1b64622e0da9b27d78 (diff)
downloadlinux-stable-8e51ec6146fdec82f7308f89113497631013f16a.tar.gz
linux-stable-8e51ec6146fdec82f7308f89113497631013f16a.tar.bz2
linux-stable-8e51ec6146fdec82f7308f89113497631013f16a.zip
dlm: use kref_put_lock in __put_lkb
This patch will optimize __put_lkb() by using kref_put_lock(). The function kref_put_lock() will only take the lock if the reference is going to be zero, if not the lock will never be held. Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm')
-rw-r--r--fs/dlm/lock.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index a331210434b2..226822f49d30 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -1268,9 +1268,11 @@ static void kill_lkb(struct kref *kref)
static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb)
{
uint32_t lkid = lkb->lkb_id;
+ int rv;
- spin_lock(&ls->ls_lkbidr_spin);
- if (kref_put(&lkb->lkb_ref, kill_lkb)) {
+ rv = kref_put_lock(&lkb->lkb_ref, kill_lkb,
+ &ls->ls_lkbidr_spin);
+ if (rv) {
idr_remove(&ls->ls_lkbidr, lkid);
spin_unlock(&ls->ls_lkbidr_spin);
@@ -1280,11 +1282,9 @@ static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb)
if (lkb->lkb_lvbptr && is_master_copy(lkb))
dlm_free_lvb(lkb->lkb_lvbptr);
dlm_free_lkb(lkb);
- return 1;
- } else {
- spin_unlock(&ls->ls_lkbidr_spin);
- return 0;
}
+
+ return rv;
}
int dlm_put_lkb(struct dlm_lkb *lkb)