]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
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 | |
6 | ||
7 | The dlm_scand thread needs to lock the list of lockspaces | |
8 | when going through it. | |
9 | ||
10 | Signed-off-by: David Teigland <teigland@redhat.com> | |
11 | Signed-off-by: Coly Li <coly.li@suse.de> | |
12 | ||
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; | |
23 | ||
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); | |
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); |