Skip to content

Commit 9502a7f

Browse files
Alexander Aringteigland
authored andcommitted
dlm: use kref_put_lock in put_rsb
This patch will optimize put_rsb() 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 <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 0ccc106 commit 9502a7f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fs/dlm/lock.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,12 @@ static void put_rsb(struct dlm_rsb *r)
350350
{
351351
struct dlm_ls *ls = r->res_ls;
352352
uint32_t bucket = r->res_bucket;
353+
int rv;
353354

354-
spin_lock(&ls->ls_rsbtbl[bucket].lock);
355-
kref_put(&r->res_ref, toss_rsb);
356-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
355+
rv = kref_put_lock(&r->res_ref, toss_rsb,
356+
&ls->ls_rsbtbl[bucket].lock);
357+
if (rv)
358+
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
357359
}
358360

359361
void dlm_put_rsb(struct dlm_rsb *r)

0 commit comments

Comments
 (0)