Skip to content

Commit 484b4f9

Browse files
committed
dlm: revert atomic_t lkb_wait_count
Revert "fs: dlm: handle lkb wait count as atomic_t" This reverts commit 75a7d60. This counter does not need to be atomic. As the comment in the reverted commit mentions, the counter is protected by the rsb lock. Signed-off-by: David Teigland <[email protected]>
1 parent 2ab3d70 commit 484b4f9

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

fs/dlm/dlm_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ struct dlm_lkb {
246246
int8_t lkb_highbast; /* highest mode bast sent for */
247247

248248
int8_t lkb_wait_type; /* type of reply waiting for */
249-
atomic_t lkb_wait_count;
249+
int8_t lkb_wait_count;
250250
int lkb_wait_nodeid; /* for debugging */
251251

252252
struct list_head lkb_statequeue; /* rsb g/c/w list */

fs/dlm/lock.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,6 @@ static int add_to_waiters(struct dlm_lkb *lkb, int mstype, int to_nodeid)
14071407
{
14081408
struct dlm_ls *ls = lkb->lkb_resource->res_ls;
14091409
int error = 0;
1410-
int wc;
14111410

14121411
mutex_lock(&ls->ls_waiters_mutex);
14131412

@@ -1429,17 +1428,20 @@ static int add_to_waiters(struct dlm_lkb *lkb, int mstype, int to_nodeid)
14291428
error = -EBUSY;
14301429
goto out;
14311430
}
1432-
wc = atomic_inc_return(&lkb->lkb_wait_count);
1431+
lkb->lkb_wait_count++;
14331432
hold_lkb(lkb);
14341433

14351434
log_debug(ls, "addwait %x cur %d overlap %d count %d f %x",
1436-
lkb->lkb_id, lkb->lkb_wait_type, mstype, wc,
1437-
dlm_iflags_val(lkb));
1435+
lkb->lkb_id, lkb->lkb_wait_type, mstype,
1436+
lkb->lkb_wait_count, dlm_iflags_val(lkb));
14381437
goto out;
14391438
}
14401439

1441-
wc = atomic_fetch_inc(&lkb->lkb_wait_count);
1442-
DLM_ASSERT(!wc, dlm_print_lkb(lkb); printk("wait_count %d\n", wc););
1440+
DLM_ASSERT(!lkb->lkb_wait_count,
1441+
dlm_print_lkb(lkb);
1442+
printk("wait_count %d\n", lkb->lkb_wait_count););
1443+
1444+
lkb->lkb_wait_count++;
14431445
lkb->lkb_wait_type = mstype;
14441446
lkb->lkb_wait_nodeid = to_nodeid; /* for debugging */
14451447
hold_lkb(lkb);
@@ -1502,7 +1504,7 @@ static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype,
15021504
log_debug(ls, "remwait %x convert_reply zap overlap_cancel",
15031505
lkb->lkb_id);
15041506
lkb->lkb_wait_type = 0;
1505-
atomic_dec(&lkb->lkb_wait_count);
1507+
lkb->lkb_wait_count--;
15061508
unhold_lkb(lkb);
15071509
goto out_del;
15081510
}
@@ -1529,15 +1531,16 @@ static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype,
15291531
if (overlap_done && lkb->lkb_wait_type) {
15301532
log_error(ls, "remwait error %x reply %d wait_type %d overlap",
15311533
lkb->lkb_id, mstype, lkb->lkb_wait_type);
1532-
atomic_dec(&lkb->lkb_wait_count);
1534+
lkb->lkb_wait_count--;
15331535
unhold_lkb(lkb);
15341536
lkb->lkb_wait_type = 0;
15351537
}
15361538

1537-
DLM_ASSERT(atomic_read(&lkb->lkb_wait_count), dlm_print_lkb(lkb););
1539+
DLM_ASSERT(lkb->lkb_wait_count, dlm_print_lkb(lkb););
15381540

15391541
clear_bit(DLM_IFL_RESEND_BIT, &lkb->lkb_iflags);
1540-
if (atomic_dec_and_test(&lkb->lkb_wait_count))
1542+
lkb->lkb_wait_count--;
1543+
if (!lkb->lkb_wait_count)
15411544
list_del_init(&lkb->lkb_wait_reply);
15421545
unhold_lkb(lkb);
15431546
return 0;
@@ -2666,7 +2669,7 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
26662669
goto out;
26672670

26682671
/* lock not allowed if there's any op in progress */
2669-
if (lkb->lkb_wait_type || atomic_read(&lkb->lkb_wait_count))
2672+
if (lkb->lkb_wait_type || lkb->lkb_wait_count)
26702673
goto out;
26712674

26722675
if (is_overlap(lkb))
@@ -2728,7 +2731,7 @@ static int validate_unlock_args(struct dlm_lkb *lkb, struct dlm_args *args)
27282731

27292732
/* normal unlock not allowed if there's any op in progress */
27302733
if (!(args->flags & (DLM_LKF_CANCEL | DLM_LKF_FORCEUNLOCK)) &&
2731-
(lkb->lkb_wait_type || atomic_read(&lkb->lkb_wait_count)))
2734+
(lkb->lkb_wait_type || lkb->lkb_wait_count))
27322735
goto out;
27332736

27342737
/* an lkb may be waiting for an rsb lookup to complete where the
@@ -5070,9 +5073,10 @@ int dlm_recover_waiters_post(struct dlm_ls *ls)
50705073
/* drop all wait_count references we still
50715074
* hold a reference for this iteration.
50725075
*/
5073-
while (!atomic_dec_and_test(&lkb->lkb_wait_count))
5076+
while (lkb->lkb_wait_count) {
5077+
lkb->lkb_wait_count--;
50745078
unhold_lkb(lkb);
5075-
5079+
}
50765080
mutex_lock(&ls->ls_waiters_mutex);
50775081
list_del_init(&lkb->lkb_wait_reply);
50785082
mutex_unlock(&ls->ls_waiters_mutex);

0 commit comments

Comments
 (0)