Skip to content

Commit c1dcf65

Browse files
committed
dlm: fix locking of lockspace list in dlm_scand
The dlm_scand thread needs to lock the list of lockspaces when going through it. Signed-off-by: David Teigland <teigland@redhat.com>
1 parent dc68c7e commit c1dcf65

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎fs/dlm/dlm_internal.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ struct dlm_ls {
445445
the dlm using this ls */
446446
int ls_create_count; /* create/release refcount */
447447
unsigned long ls_flags; /* LSFL_ */
448+
unsigned long ls_scan_time;
448449
struct kobject ls_kobj;
449450

450451
struct dlm_rsbtable *ls_rsbtbl;

‎fs/dlm/lockspace.c‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,41 @@ void dlm_lockspace_exit(void)
212212
kset_unregister(dlm_kset);
213213
}
214214

215+
static struct dlm_ls *find_ls_to_scan(void)
216+
{
217+
struct dlm_ls *ls;
218+
219+
spin_lock(&lslist_lock);
220+
list_for_each_entry(ls, &lslist, ls_list) {
221+
if (time_after_eq(jiffies, ls->ls_scan_time +
222+
dlm_config.ci_scan_secs * HZ)) {
223+
spin_unlock(&lslist_lock);
224+
return ls;
225+
}
226+
}
227+
spin_unlock(&lslist_lock);
228+
return NULL;
229+
}
230+
215231
static int dlm_scand(void *data)
216232
{
217233
struct dlm_ls *ls;
234+
int timeout_jiffies = dlm_config.ci_scan_secs * HZ;
218235

219236
while (!kthread_should_stop()) {
220-
list_for_each_entry(ls, &lslist, ls_list) {
237+
ls = find_ls_to_scan();
238+
if (ls) {
221239
if (dlm_lock_recovery_try(ls)) {
240+
ls->ls_scan_time = jiffies;
222241
dlm_scan_rsbs(ls);
223242
dlm_scan_timeout(ls);
224243
dlm_unlock_recovery(ls);
244+
} else {
245+
ls->ls_scan_time += HZ;
225246
}
247+
} else {
248+
schedule_timeout_interruptible(timeout_jiffies);
226249
}
227-
schedule_timeout_interruptible(dlm_config.ci_scan_secs * HZ);
228250
}
229251
return 0;
230252
}
@@ -418,6 +440,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
418440
ls->ls_lvblen = lvblen;
419441
ls->ls_count = 0;
420442
ls->ls_flags = 0;
443+
ls->ls_scan_time = jiffies;
421444

422445
if (flags & DLM_LSFL_TIMEWARN)
423446
set_bit(LSFL_TIMEWARN, &ls->ls_flags);

0 commit comments

Comments
 (0)