1 From: David Teigland <teigland@redhat.com>
2 commit c1dcf65ffc5796bf4ff75c13f448e63b3a416fd6
3 Author: David Teigland <teigland@redhat.com>
4 Date: Mon Aug 18 14:03:25 2008 -0500
5 Subject: dlm: fix locking of lockspace list in dlm_scand
7 The dlm_scand thread needs to lock the list of lockspaces
10 Signed-off-by: David Teigland <teigland@redhat.com>
11 Signed-off-by: Coly Li <coly.li@suse.de>
13 diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
14 index 9e0622a..868e4c9 100644
15 --- a/fs/dlm/dlm_internal.h
16 +++ b/fs/dlm/dlm_internal.h
17 @@ -445,6 +445,7 @@ struct dlm_ls {
18 the dlm using this ls */
19 int ls_create_count; /* create/release refcount */
20 unsigned long ls_flags; /* LSFL_ */
21 + unsigned long ls_scan_time;
22 struct kobject ls_kobj;
24 struct dlm_rsbtable *ls_rsbtbl;
25 diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
26 index ba672fe..d910501 100644
27 --- a/fs/dlm/lockspace.c
28 +++ b/fs/dlm/lockspace.c
29 @@ -212,19 +212,41 @@ void dlm_lockspace_exit(void)
30 kset_unregister(dlm_kset);
33 +static struct dlm_ls *find_ls_to_scan(void)
37 + spin_lock(&lslist_lock);
38 + list_for_each_entry(ls, &lslist, ls_list) {
39 + if (time_after_eq(jiffies, ls->ls_scan_time +
40 + dlm_config.ci_scan_secs * HZ)) {
41 + spin_unlock(&lslist_lock);
45 + spin_unlock(&lslist_lock);
49 static int dlm_scand(void *data)
52 + int timeout_jiffies = dlm_config.ci_scan_secs * HZ;
54 while (!kthread_should_stop()) {
55 - list_for_each_entry(ls, &lslist, ls_list) {
56 + ls = find_ls_to_scan();
58 if (dlm_lock_recovery_try(ls)) {
59 + ls->ls_scan_time = jiffies;
62 dlm_unlock_recovery(ls);
64 + ls->ls_scan_time += HZ;
67 + schedule_timeout_interruptible(timeout_jiffies);
69 - schedule_timeout_interruptible(dlm_config.ci_scan_secs * HZ);
73 @@ -418,6 +440,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
74 ls->ls_lvblen = lvblen;
77 + ls->ls_scan_time = jiffies;
79 if (flags & DLM_LSFL_TIMEWARN)
80 set_bit(LSFL_TIMEWARN, &ls->ls_flags);