Skip to content

Commit 8e51ec6

Browse files
Alexander Aringteigland
authored andcommitted
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>
1 parent 9502a7f commit 8e51ec6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fs/dlm/lock.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,9 +1268,11 @@ static void kill_lkb(struct kref *kref)
12681268
static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb)
12691269
{
12701270
uint32_t lkid = lkb->lkb_id;
1271+
int rv;
12711272

1272-
spin_lock(&ls->ls_lkbidr_spin);
1273-
if (kref_put(&lkb->lkb_ref, kill_lkb)) {
1273+
rv = kref_put_lock(&lkb->lkb_ref, kill_lkb,
1274+
&ls->ls_lkbidr_spin);
1275+
if (rv) {
12741276
idr_remove(&ls->ls_lkbidr, lkid);
12751277
spin_unlock(&ls->ls_lkbidr_spin);
12761278

@@ -1280,11 +1282,9 @@ static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb)
12801282
if (lkb->lkb_lvbptr && is_master_copy(lkb))
12811283
dlm_free_lvb(lkb->lkb_lvbptr);
12821284
dlm_free_lkb(lkb);
1283-
return 1;
1284-
} else {
1285-
spin_unlock(&ls->ls_lkbidr_spin);
1286-
return 0;
12871285
}
1286+
1287+
return rv;
12881288
}
12891289

12901290
int dlm_put_lkb(struct dlm_lkb *lkb)

0 commit comments

Comments
 (0)