Skip to content

Commit 85e86ed

Browse files
teiglandswhiteho
authored andcommitted
[DLM] block scand during recovery [1/6]
Don't let dlm_scand run during recovery since it may try to do a resource directory removal while the directory nodes are changing. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 916297a commit 85e86ed

3 files changed

Lines changed: 31 additions & 26 deletions

File tree

‎fs/dlm/lock.c‎

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,17 @@ void dlm_dump_rsb(struct dlm_rsb *r)
194194

195195
/* Threads cannot use the lockspace while it's being recovered */
196196

197-
static inline void lock_recovery(struct dlm_ls *ls)
197+
static inline void dlm_lock_recovery(struct dlm_ls *ls)
198198
{
199199
down_read(&ls->ls_in_recovery);
200200
}
201201

202-
static inline void unlock_recovery(struct dlm_ls *ls)
202+
void dlm_unlock_recovery(struct dlm_ls *ls)
203203
{
204204
up_read(&ls->ls_in_recovery);
205205
}
206206

207-
static inline int lock_recovery_try(struct dlm_ls *ls)
207+
int dlm_lock_recovery_try(struct dlm_ls *ls)
208208
{
209209
return down_read_trylock(&ls->ls_in_recovery);
210210
}
@@ -985,11 +985,10 @@ void dlm_scan_rsbs(struct dlm_ls *ls)
985985
{
986986
int i;
987987

988-
if (dlm_locking_stopped(ls))
989-
return;
990-
991988
for (i = 0; i < ls->ls_rsbtbl_size; i++) {
992989
shrink_bucket(ls, i);
990+
if (dlm_locking_stopped(ls))
991+
break;
993992
cond_resched();
994993
}
995994
}
@@ -2274,7 +2273,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
22742273
if (!ls)
22752274
return -EINVAL;
22762275

2277-
lock_recovery(ls);
2276+
dlm_lock_recovery(ls);
22782277

22792278
if (convert)
22802279
error = find_lkb(ls, lksb->sb_lkid, &lkb);
@@ -2302,7 +2301,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
23022301
if (error == -EAGAIN)
23032302
error = 0;
23042303
out:
2305-
unlock_recovery(ls);
2304+
dlm_unlock_recovery(ls);
23062305
dlm_put_lockspace(ls);
23072306
return error;
23082307
}
@@ -2322,7 +2321,7 @@ int dlm_unlock(dlm_lockspace_t *lockspace,
23222321
if (!ls)
23232322
return -EINVAL;
23242323

2325-
lock_recovery(ls);
2324+
dlm_lock_recovery(ls);
23262325

23272326
error = find_lkb(ls, lkid, &lkb);
23282327
if (error)
@@ -2344,7 +2343,7 @@ int dlm_unlock(dlm_lockspace_t *lockspace,
23442343
out_put:
23452344
dlm_put_lkb(lkb);
23462345
out:
2347-
unlock_recovery(ls);
2346+
dlm_unlock_recovery(ls);
23482347
dlm_put_lockspace(ls);
23492348
return error;
23502349
}
@@ -3424,7 +3423,7 @@ int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
34243423
}
34253424
}
34263425

3427-
if (lock_recovery_try(ls))
3426+
if (dlm_lock_recovery_try(ls))
34283427
break;
34293428
schedule();
34303429
}
@@ -3503,7 +3502,7 @@ int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
35033502
log_error(ls, "unknown message type %d", ms->m_type);
35043503
}
35053504

3506-
unlock_recovery(ls);
3505+
dlm_unlock_recovery(ls);
35073506
out:
35083507
dlm_put_lockspace(ls);
35093508
dlm_astd_wake();
@@ -4040,7 +4039,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
40404039
struct dlm_args args;
40414040
int error;
40424041

4043-
lock_recovery(ls);
4042+
dlm_lock_recovery(ls);
40444043

40454044
error = create_lkb(ls, &lkb);
40464045
if (error) {
@@ -4094,7 +4093,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
40944093
list_add_tail(&lkb->lkb_ownqueue, &ua->proc->locks);
40954094
spin_unlock(&ua->proc->locks_spin);
40964095
out:
4097-
unlock_recovery(ls);
4096+
dlm_unlock_recovery(ls);
40984097
return error;
40994098
}
41004099

@@ -4106,7 +4105,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
41064105
struct dlm_user_args *ua;
41074106
int error;
41084107

4109-
lock_recovery(ls);
4108+
dlm_lock_recovery(ls);
41104109

41114110
error = find_lkb(ls, lkid, &lkb);
41124111
if (error)
@@ -4146,7 +4145,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
41464145
out_put:
41474146
dlm_put_lkb(lkb);
41484147
out:
4149-
unlock_recovery(ls);
4148+
dlm_unlock_recovery(ls);
41504149
kfree(ua_tmp);
41514150
return error;
41524151
}
@@ -4159,7 +4158,7 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
41594158
struct dlm_user_args *ua;
41604159
int error;
41614160

4162-
lock_recovery(ls);
4161+
dlm_lock_recovery(ls);
41634162

41644163
error = find_lkb(ls, lkid, &lkb);
41654164
if (error)
@@ -4194,7 +4193,7 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
41944193
out_put:
41954194
dlm_put_lkb(lkb);
41964195
out:
4197-
unlock_recovery(ls);
4196+
dlm_unlock_recovery(ls);
41984197
kfree(ua_tmp);
41994198
return error;
42004199
}
@@ -4207,7 +4206,7 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
42074206
struct dlm_user_args *ua;
42084207
int error;
42094208

4210-
lock_recovery(ls);
4209+
dlm_lock_recovery(ls);
42114210

42124211
error = find_lkb(ls, lkid, &lkb);
42134212
if (error)
@@ -4231,7 +4230,7 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
42314230
out_put:
42324231
dlm_put_lkb(lkb);
42334232
out:
4234-
unlock_recovery(ls);
4233+
dlm_unlock_recovery(ls);
42354234
kfree(ua_tmp);
42364235
return error;
42374236
}
@@ -4314,7 +4313,7 @@ void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc)
43144313
{
43154314
struct dlm_lkb *lkb, *safe;
43164315

4317-
lock_recovery(ls);
4316+
dlm_lock_recovery(ls);
43184317

43194318
while (1) {
43204319
lkb = del_proc_lock(ls, proc);
@@ -4347,7 +4346,7 @@ void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc)
43474346
}
43484347

43494348
mutex_unlock(&ls->ls_clear_proc_locks);
4350-
unlock_recovery(ls);
4349+
dlm_unlock_recovery(ls);
43514350
}
43524351

43534352
static void purge_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc)
@@ -4429,12 +4428,12 @@ int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc,
44294428
if (nodeid != dlm_our_nodeid()) {
44304429
error = send_purge(ls, nodeid, pid);
44314430
} else {
4432-
lock_recovery(ls);
4431+
dlm_lock_recovery(ls);
44334432
if (pid == current->pid)
44344433
purge_proc_locks(ls, proc);
44354434
else
44364435
do_purge(ls, nodeid, pid);
4437-
unlock_recovery(ls);
4436+
dlm_unlock_recovery(ls);
44384437
}
44394438
return error;
44404439
}

‎fs/dlm/lock.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ void dlm_put_rsb(struct dlm_rsb *r);
2424
void dlm_hold_rsb(struct dlm_rsb *r);
2525
int dlm_put_lkb(struct dlm_lkb *lkb);
2626
void dlm_scan_rsbs(struct dlm_ls *ls);
27+
int dlm_lock_recovery_try(struct dlm_ls *ls);
28+
void dlm_unlock_recovery(struct dlm_ls *ls);
2729

2830
int dlm_purge_locks(struct dlm_ls *ls);
2931
void dlm_purge_mstcpy_locks(struct dlm_rsb *r);

‎fs/dlm/lockspace.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,12 @@ static int dlm_scand(void *data)
234234
struct dlm_ls *ls;
235235

236236
while (!kthread_should_stop()) {
237-
list_for_each_entry(ls, &lslist, ls_list)
238-
dlm_scan_rsbs(ls);
237+
list_for_each_entry(ls, &lslist, ls_list) {
238+
if (dlm_lock_recovery_try(ls)) {
239+
dlm_scan_rsbs(ls);
240+
dlm_unlock_recovery(ls);
241+
}
242+
}
239243
schedule_timeout_interruptible(dlm_config.ci_scan_secs * HZ);
240244
}
241245
return 0;

0 commit comments

Comments
 (0)