Skip to content

Commit 097691d

Browse files
Alexander Aringteigland
authored andcommitted
dlm: convert ls_waiters_mutex to spinlock
Convert the waiters mutex to a spinlock in prepration for processing messages in softirq context. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 6b52ea7 commit 097691d

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

fs/dlm/debug_fs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ static ssize_t waiters_read(struct file *file, char __user *userbuf,
743743
goto out;
744744
}
745745

746-
mutex_lock(&ls->ls_waiters_mutex);
746+
spin_lock(&ls->ls_waiters_lock);
747747
memset(debug_buf, 0, sizeof(debug_buf));
748748

749749
list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) {
@@ -754,7 +754,7 @@ static ssize_t waiters_read(struct file *file, char __user *userbuf,
754754
break;
755755
pos += ret;
756756
}
757-
mutex_unlock(&ls->ls_waiters_mutex);
757+
spin_unlock(&ls->ls_waiters_lock);
758758
dlm_unlock_recovery(ls);
759759

760760
rv = simple_read_from_buffer(userbuf, count, ppos, debug_buf, pos);

fs/dlm/dlm_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ struct dlm_ls {
595595
struct dlm_rsbtable *ls_rsbtbl;
596596
uint32_t ls_rsbtbl_size;
597597

598-
struct mutex ls_waiters_mutex;
598+
spinlock_t ls_waiters_lock;
599599
struct list_head ls_waiters; /* lkbs needing a reply */
600600

601601
struct mutex ls_orphans_mutex;

fs/dlm/lock.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ static int add_to_waiters(struct dlm_lkb *lkb, int mstype, int to_nodeid)
14061406
struct dlm_ls *ls = lkb->lkb_resource->res_ls;
14071407
int error = 0;
14081408

1409-
mutex_lock(&ls->ls_waiters_mutex);
1409+
spin_lock(&ls->ls_waiters_lock);
14101410

14111411
if (is_overlap_unlock(lkb) ||
14121412
(is_overlap_cancel(lkb) && (mstype == DLM_MSG_CANCEL))) {
@@ -1449,7 +1449,7 @@ static int add_to_waiters(struct dlm_lkb *lkb, int mstype, int to_nodeid)
14491449
log_error(ls, "addwait error %x %d flags %x %d %d %s",
14501450
lkb->lkb_id, error, dlm_iflags_val(lkb), mstype,
14511451
lkb->lkb_wait_type, lkb->lkb_resource->res_name);
1452-
mutex_unlock(&ls->ls_waiters_mutex);
1452+
spin_unlock(&ls->ls_waiters_lock);
14531453
return error;
14541454
}
14551455

@@ -1549,9 +1549,9 @@ static int remove_from_waiters(struct dlm_lkb *lkb, int mstype)
15491549
struct dlm_ls *ls = lkb->lkb_resource->res_ls;
15501550
int error;
15511551

1552-
mutex_lock(&ls->ls_waiters_mutex);
1552+
spin_lock(&ls->ls_waiters_lock);
15531553
error = _remove_from_waiters(lkb, mstype, NULL);
1554-
mutex_unlock(&ls->ls_waiters_mutex);
1554+
spin_unlock(&ls->ls_waiters_lock);
15551555
return error;
15561556
}
15571557

@@ -1569,13 +1569,13 @@ static int remove_from_waiters_ms(struct dlm_lkb *lkb,
15691569
int error;
15701570

15711571
if (!local)
1572-
mutex_lock(&ls->ls_waiters_mutex);
1572+
spin_lock(&ls->ls_waiters_lock);
15731573
else
15741574
WARN_ON_ONCE(!rwsem_is_locked(&ls->ls_in_recovery) ||
15751575
!dlm_locking_stopped(ls));
15761576
error = _remove_from_waiters(lkb, le32_to_cpu(ms->m_type), ms);
15771577
if (!local)
1578-
mutex_unlock(&ls->ls_waiters_mutex);
1578+
spin_unlock(&ls->ls_waiters_lock);
15791579
return error;
15801580
}
15811581

@@ -4993,15 +4993,15 @@ static struct dlm_lkb *find_resend_waiter(struct dlm_ls *ls)
49934993
{
49944994
struct dlm_lkb *lkb = NULL, *iter;
49954995

4996-
mutex_lock(&ls->ls_waiters_mutex);
4996+
spin_lock(&ls->ls_waiters_lock);
49974997
list_for_each_entry(iter, &ls->ls_waiters, lkb_wait_reply) {
49984998
if (test_bit(DLM_IFL_RESEND_BIT, &iter->lkb_iflags)) {
49994999
hold_lkb(iter);
50005000
lkb = iter;
50015001
break;
50025002
}
50035003
}
5004-
mutex_unlock(&ls->ls_waiters_mutex);
5004+
spin_unlock(&ls->ls_waiters_lock);
50055005

50065006
return lkb;
50075007
}
@@ -5101,9 +5101,9 @@ int dlm_recover_waiters_post(struct dlm_ls *ls)
51015101
}
51025102

51035103
/* Forcibly remove from waiters list */
5104-
mutex_lock(&ls->ls_waiters_mutex);
5104+
spin_lock(&ls->ls_waiters_lock);
51055105
list_del_init(&lkb->lkb_wait_reply);
5106-
mutex_unlock(&ls->ls_waiters_mutex);
5106+
spin_unlock(&ls->ls_waiters_lock);
51075107

51085108
/*
51095109
* The lkb is now clear of all prior waiters state and can be

fs/dlm/lockspace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ static int new_lockspace(const char *name, const char *cluster,
515515
spin_lock_init(&ls->ls_lkbidr_spin);
516516

517517
INIT_LIST_HEAD(&ls->ls_waiters);
518-
mutex_init(&ls->ls_waiters_mutex);
518+
spin_lock_init(&ls->ls_waiters_lock);
519519
INIT_LIST_HEAD(&ls->ls_orphans);
520520
mutex_init(&ls->ls_orphans_mutex);
521521

0 commit comments

Comments
 (0)