]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.suse/dlm-fix-locking-of-lockspace-list-in-dlm_scand.patch
Imported linux-2.6.27.39 suse/xen patches.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.suse / dlm-fix-locking-of-lockspace-list-in-dlm_scand.patch
CommitLineData
2cb7cef9
BS
1From: David Teigland <teigland@redhat.com>
2commit c1dcf65ffc5796bf4ff75c13f448e63b3a416fd6
3Author: David Teigland <teigland@redhat.com>
4Date: Mon Aug 18 14:03:25 2008 -0500
5Subject: dlm: fix locking of lockspace list in dlm_scand
6
7 The dlm_scand thread needs to lock the list of lockspaces
8 when going through it.
9
10Signed-off-by: David Teigland <teigland@redhat.com>
11Signed-off-by: Coly Li <coly.li@suse.de>
12
13diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
14index 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;
23
24 struct dlm_rsbtable *ls_rsbtbl;
25diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
26index 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);
31 }
32
33+static struct dlm_ls *find_ls_to_scan(void)
34+{
35+ struct dlm_ls *ls;
36+
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);
42+ return ls;
43+ }
44+ }
45+ spin_unlock(&lslist_lock);
46+ return NULL;
47+}
48+
49 static int dlm_scand(void *data)
50 {
51 struct dlm_ls *ls;
52+ int timeout_jiffies = dlm_config.ci_scan_secs * HZ;
53
54 while (!kthread_should_stop()) {
55- list_for_each_entry(ls, &lslist, ls_list) {
56+ ls = find_ls_to_scan();
57+ if (ls) {
58 if (dlm_lock_recovery_try(ls)) {
59+ ls->ls_scan_time = jiffies;
60 dlm_scan_rsbs(ls);
61 dlm_scan_timeout(ls);
62 dlm_unlock_recovery(ls);
63+ } else {
64+ ls->ls_scan_time += HZ;
65 }
66+ } else {
67+ schedule_timeout_interruptible(timeout_jiffies);
68 }
69- schedule_timeout_interruptible(dlm_config.ci_scan_secs * HZ);
70 }
71 return 0;
72 }
73@@ -418,6 +440,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
74 ls->ls_lvblen = lvblen;
75 ls->ls_count = 0;
76 ls->ls_flags = 0;
77+ ls->ls_scan_time = jiffies;
78
79 if (flags & DLM_LSFL_TIMEWARN)
80 set_bit(LSFL_TIMEWARN, &ls->ls_flags);