Skip to content

Commit 578acf9

Browse files
Alexander Aringteigland
authored andcommitted
dlm: use spin_lock_bh for message processing
Use spin_lock_bh for all spinlocks involved in message processing, in preparation for softirq message processing. DLM lock requests from user space involve dlm processing in user context, in addition to the standard kernel context, necessitating bh variants. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 308533b commit 578acf9

File tree

14 files changed

+287
-258
lines changed

14 files changed

+287
-258
lines changed

fs/dlm/ast.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ void dlm_add_cb(struct dlm_lkb *lkb, uint32_t flags, int mode, int status,
142142
cb->astparam = lkb->lkb_astparam;
143143
INIT_WORK(&cb->work, dlm_callback_work);
144144

145-
spin_lock(&ls->ls_cb_lock);
145+
spin_lock_bh(&ls->ls_cb_lock);
146146
if (test_bit(LSFL_CB_DELAY, &ls->ls_flags))
147147
list_add(&cb->list, &ls->ls_cb_delay);
148148
else
149149
queue_work(ls->ls_callback_wq, &cb->work);
150-
spin_unlock(&ls->ls_cb_lock);
150+
spin_unlock_bh(&ls->ls_cb_lock);
151151
break;
152152
case DLM_ENQUEUE_CALLBACK_SUCCESS:
153153
break;
@@ -179,9 +179,9 @@ void dlm_callback_stop(struct dlm_ls *ls)
179179
void dlm_callback_suspend(struct dlm_ls *ls)
180180
{
181181
if (ls->ls_callback_wq) {
182-
spin_lock(&ls->ls_cb_lock);
182+
spin_lock_bh(&ls->ls_cb_lock);
183183
set_bit(LSFL_CB_DELAY, &ls->ls_flags);
184-
spin_unlock(&ls->ls_cb_lock);
184+
spin_unlock_bh(&ls->ls_cb_lock);
185185

186186
flush_workqueue(ls->ls_callback_wq);
187187
}
@@ -199,7 +199,7 @@ void dlm_callback_resume(struct dlm_ls *ls)
199199
return;
200200

201201
more:
202-
spin_lock(&ls->ls_cb_lock);
202+
spin_lock_bh(&ls->ls_cb_lock);
203203
list_for_each_entry_safe(cb, safe, &ls->ls_cb_delay, list) {
204204
list_del(&cb->list);
205205
queue_work(ls->ls_callback_wq, &cb->work);
@@ -210,7 +210,7 @@ void dlm_callback_resume(struct dlm_ls *ls)
210210
empty = list_empty(&ls->ls_cb_delay);
211211
if (empty)
212212
clear_bit(LSFL_CB_DELAY, &ls->ls_flags);
213-
spin_unlock(&ls->ls_cb_lock);
213+
spin_unlock_bh(&ls->ls_cb_lock);
214214

215215
sum += count;
216216
if (!empty) {

fs/dlm/debug_fs.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -452,20 +452,20 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos)
452452

453453
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
454454

455-
spin_lock(&ls->ls_rsbtbl[bucket].lock);
455+
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
456456
if (!RB_EMPTY_ROOT(tree)) {
457457
for (node = rb_first(tree); node; node = rb_next(node)) {
458458
r = rb_entry(node, struct dlm_rsb, res_hashnode);
459459
if (!entry--) {
460460
dlm_hold_rsb(r);
461461
ri->rsb = r;
462462
ri->bucket = bucket;
463-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
463+
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
464464
return ri;
465465
}
466466
}
467467
}
468-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
468+
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
469469

470470
/*
471471
* move to the first rsb in the next non-empty bucket
@@ -484,18 +484,18 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos)
484484
}
485485
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
486486

487-
spin_lock(&ls->ls_rsbtbl[bucket].lock);
487+
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
488488
if (!RB_EMPTY_ROOT(tree)) {
489489
node = rb_first(tree);
490490
r = rb_entry(node, struct dlm_rsb, res_hashnode);
491491
dlm_hold_rsb(r);
492492
ri->rsb = r;
493493
ri->bucket = bucket;
494-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
494+
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
495495
*pos = n;
496496
return ri;
497497
}
498-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
498+
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
499499
}
500500
}
501501

@@ -516,20 +516,20 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
516516
* move to the next rsb in the same bucket
517517
*/
518518

519-
spin_lock(&ls->ls_rsbtbl[bucket].lock);
519+
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
520520
rp = ri->rsb;
521521
next = rb_next(&rp->res_hashnode);
522522

523523
if (next) {
524524
r = rb_entry(next, struct dlm_rsb, res_hashnode);
525525
dlm_hold_rsb(r);
526526
ri->rsb = r;
527-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
527+
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
528528
dlm_put_rsb(rp);
529529
++*pos;
530530
return ri;
531531
}
532-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
532+
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
533533
dlm_put_rsb(rp);
534534

535535
/*
@@ -550,18 +550,18 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
550550
}
551551
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
552552

553-
spin_lock(&ls->ls_rsbtbl[bucket].lock);
553+
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
554554
if (!RB_EMPTY_ROOT(tree)) {
555555
next = rb_first(tree);
556556
r = rb_entry(next, struct dlm_rsb, res_hashnode);
557557
dlm_hold_rsb(r);
558558
ri->rsb = r;
559559
ri->bucket = bucket;
560-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
560+
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
561561
*pos = n;
562562
return ri;
563563
}
564-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
564+
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
565565
}
566566
}
567567

@@ -743,7 +743,7 @@ static ssize_t waiters_read(struct file *file, char __user *userbuf,
743743
goto out;
744744
}
745745

746-
spin_lock(&ls->ls_waiters_lock);
746+
spin_lock_bh(&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-
spin_unlock(&ls->ls_waiters_lock);
757+
spin_unlock_bh(&ls->ls_waiters_lock);
758758
dlm_unlock_recovery(ls);
759759

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

fs/dlm/dir.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ static struct dlm_rsb *find_rsb_root(struct dlm_ls *ls, const char *name,
204204
hash = jhash(name, len, 0);
205205
bucket = hash & (ls->ls_rsbtbl_size - 1);
206206

207-
spin_lock(&ls->ls_rsbtbl[bucket].lock);
207+
spin_lock_bh(&ls->ls_rsbtbl[bucket].lock);
208208
rv = dlm_search_rsb_tree(&ls->ls_rsbtbl[bucket].keep, name, len, &r);
209209
if (rv)
210210
rv = dlm_search_rsb_tree(&ls->ls_rsbtbl[bucket].toss,
211211
name, len, &r);
212-
spin_unlock(&ls->ls_rsbtbl[bucket].lock);
212+
spin_unlock_bh(&ls->ls_rsbtbl[bucket].lock);
213213

214214
if (!rv)
215215
return r;
@@ -245,7 +245,7 @@ static void drop_dir_ctx(struct dlm_ls *ls, int nodeid)
245245
{
246246
struct dlm_dir_dump *dd, *safe;
247247

248-
write_lock(&ls->ls_dir_dump_lock);
248+
write_lock_bh(&ls->ls_dir_dump_lock);
249249
list_for_each_entry_safe(dd, safe, &ls->ls_dir_dump_list, list) {
250250
if (dd->nodeid_init == nodeid) {
251251
log_error(ls, "drop dump seq %llu",
@@ -254,21 +254,21 @@ static void drop_dir_ctx(struct dlm_ls *ls, int nodeid)
254254
kfree(dd);
255255
}
256256
}
257-
write_unlock(&ls->ls_dir_dump_lock);
257+
write_unlock_bh(&ls->ls_dir_dump_lock);
258258
}
259259

260260
static struct dlm_dir_dump *lookup_dir_dump(struct dlm_ls *ls, int nodeid)
261261
{
262262
struct dlm_dir_dump *iter, *dd = NULL;
263263

264-
read_lock(&ls->ls_dir_dump_lock);
264+
read_lock_bh(&ls->ls_dir_dump_lock);
265265
list_for_each_entry(iter, &ls->ls_dir_dump_list, list) {
266266
if (iter->nodeid_init == nodeid) {
267267
dd = iter;
268268
break;
269269
}
270270
}
271-
read_unlock(&ls->ls_dir_dump_lock);
271+
read_unlock_bh(&ls->ls_dir_dump_lock);
272272

273273
return dd;
274274
}
@@ -291,9 +291,9 @@ static struct dlm_dir_dump *init_dir_dump(struct dlm_ls *ls, int nodeid)
291291
dd->seq_init = ls->ls_recover_seq;
292292
dd->nodeid_init = nodeid;
293293

294-
write_lock(&ls->ls_dir_dump_lock);
294+
write_lock_bh(&ls->ls_dir_dump_lock);
295295
list_add(&dd->list, &ls->ls_dir_dump_list);
296-
write_unlock(&ls->ls_dir_dump_lock);
296+
write_unlock_bh(&ls->ls_dir_dump_lock);
297297

298298
return dd;
299299
}
@@ -311,7 +311,7 @@ void dlm_copy_master_names(struct dlm_ls *ls, const char *inbuf, int inlen,
311311
struct dlm_dir_dump *dd;
312312
__be16 be_namelen;
313313

314-
read_lock(&ls->ls_masters_lock);
314+
read_lock_bh(&ls->ls_masters_lock);
315315

316316
if (inlen > 1) {
317317
dd = lookup_dir_dump(ls, nodeid);
@@ -397,12 +397,12 @@ void dlm_copy_master_names(struct dlm_ls *ls, const char *inbuf, int inlen,
397397
log_rinfo(ls, "dlm_recover_directory nodeid %d sent %u res out %u messages",
398398
nodeid, dd->sent_res, dd->sent_msg);
399399

400-
write_lock(&ls->ls_dir_dump_lock);
400+
write_lock_bh(&ls->ls_dir_dump_lock);
401401
list_del_init(&dd->list);
402-
write_unlock(&ls->ls_dir_dump_lock);
402+
write_unlock_bh(&ls->ls_dir_dump_lock);
403403
kfree(dd);
404404
}
405405
out:
406-
read_unlock(&ls->ls_masters_lock);
406+
read_unlock_bh(&ls->ls_masters_lock);
407407
}
408408

0 commit comments

Comments
 (0)