]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Steven Whitehouse <swhiteho@redhat.com> |
2 | commit 305a47b17c6efcc0e7b67b0bd41e2c12b7af758b | |
3 | Author: Steven Whitehouse <swhiteho@redhat.com> | |
4 | Date: Fri Jan 16 16:21:12 2009 +0000 | |
5 | Subject: dlm: Change rwlock which is only used in write mode to a spinlock | |
6 | ||
7 | The ls_dirtbl[].lock was an rwlock, but since it was only used in write | |
8 | mode a spinlock will suffice. | |
9 | ||
10 | Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> | |
11 | Signed-off-by: David Teigland <teigland@redhat.com> | |
12 | Signed-off-by: Coly Li <coly.li@suse.de> | |
13 | ||
14 | diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c | |
15 | index 92969f8..858fba1 100644 | |
16 | --- a/fs/dlm/dir.c | |
17 | +++ b/fs/dlm/dir.c | |
18 | @@ -156,7 +156,7 @@ void dlm_dir_remove_entry(struct dlm_ls *ls, int nodeid, char *name, int namelen | |
19 | ||
20 | bucket = dir_hash(ls, name, namelen); | |
21 | ||
22 | - write_lock(&ls->ls_dirtbl[bucket].lock); | |
23 | + spin_lock(&ls->ls_dirtbl[bucket].lock); | |
24 | ||
25 | de = search_bucket(ls, name, namelen, bucket); | |
26 | ||
27 | @@ -173,7 +173,7 @@ void dlm_dir_remove_entry(struct dlm_ls *ls, int nodeid, char *name, int namelen | |
28 | list_del(&de->list); | |
29 | kfree(de); | |
30 | out: | |
31 | - write_unlock(&ls->ls_dirtbl[bucket].lock); | |
32 | + spin_unlock(&ls->ls_dirtbl[bucket].lock); | |
33 | } | |
34 | ||
35 | void dlm_dir_clear(struct dlm_ls *ls) | |
36 | @@ -185,14 +185,14 @@ void dlm_dir_clear(struct dlm_ls *ls) | |
37 | DLM_ASSERT(list_empty(&ls->ls_recover_list), ); | |
38 | ||
39 | for (i = 0; i < ls->ls_dirtbl_size; i++) { | |
40 | - write_lock(&ls->ls_dirtbl[i].lock); | |
41 | + spin_lock(&ls->ls_dirtbl[i].lock); | |
42 | head = &ls->ls_dirtbl[i].list; | |
43 | while (!list_empty(head)) { | |
44 | de = list_entry(head->next, struct dlm_direntry, list); | |
45 | list_del(&de->list); | |
46 | put_free_de(ls, de); | |
47 | } | |
48 | - write_unlock(&ls->ls_dirtbl[i].lock); | |
49 | + spin_unlock(&ls->ls_dirtbl[i].lock); | |
50 | } | |
51 | } | |
52 | ||
53 | @@ -307,17 +307,17 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name, | |
54 | ||
55 | bucket = dir_hash(ls, name, namelen); | |
56 | ||
57 | - write_lock(&ls->ls_dirtbl[bucket].lock); | |
58 | + spin_lock(&ls->ls_dirtbl[bucket].lock); | |
59 | de = search_bucket(ls, name, namelen, bucket); | |
60 | if (de) { | |
61 | *r_nodeid = de->master_nodeid; | |
62 | - write_unlock(&ls->ls_dirtbl[bucket].lock); | |
63 | + spin_unlock(&ls->ls_dirtbl[bucket].lock); | |
64 | if (*r_nodeid == nodeid) | |
65 | return -EEXIST; | |
66 | return 0; | |
67 | } | |
68 | ||
69 | - write_unlock(&ls->ls_dirtbl[bucket].lock); | |
70 | + spin_unlock(&ls->ls_dirtbl[bucket].lock); | |
71 | ||
72 | if (namelen > DLM_RESNAME_MAXLEN) | |
73 | return -EINVAL; | |
74 | @@ -330,7 +330,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name, | |
75 | de->length = namelen; | |
76 | memcpy(de->name, name, namelen); | |
77 | ||
78 | - write_lock(&ls->ls_dirtbl[bucket].lock); | |
79 | + spin_lock(&ls->ls_dirtbl[bucket].lock); | |
80 | tmp = search_bucket(ls, name, namelen, bucket); | |
81 | if (tmp) { | |
82 | kfree(de); | |
83 | @@ -339,7 +339,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name, | |
84 | list_add_tail(&de->list, &ls->ls_dirtbl[bucket].list); | |
85 | } | |
86 | *r_nodeid = de->master_nodeid; | |
87 | - write_unlock(&ls->ls_dirtbl[bucket].lock); | |
88 | + spin_unlock(&ls->ls_dirtbl[bucket].lock); | |
89 | return 0; | |
90 | } | |
91 | ||
92 | diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h | |
93 | index 076e86f..d01ca0a 100644 | |
94 | --- a/fs/dlm/dlm_internal.h | |
95 | +++ b/fs/dlm/dlm_internal.h | |
96 | @@ -99,7 +99,7 @@ struct dlm_direntry { | |
97 | ||
98 | struct dlm_dirtable { | |
99 | struct list_head list; | |
100 | - rwlock_t lock; | |
101 | + spinlock_t lock; | |
102 | }; | |
103 | ||
104 | struct dlm_rsbtable { | |
105 | diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c | |
106 | index aa32e5f..cd8e2df 100644 | |
107 | --- a/fs/dlm/lockspace.c | |
108 | +++ b/fs/dlm/lockspace.c | |
109 | @@ -487,7 +487,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace, | |
110 | goto out_lkbfree; | |
111 | for (i = 0; i < size; i++) { | |
112 | INIT_LIST_HEAD(&ls->ls_dirtbl[i].list); | |
113 | - rwlock_init(&ls->ls_dirtbl[i].lock); | |
114 | + spin_lock_init(&ls->ls_dirtbl[i].lock); | |
115 | } | |
116 | ||
117 | INIT_LIST_HEAD(&ls->ls_waiters); |