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
7 The ls_dirtbl[].lock was an rwlock, but since it was only used in write
8 mode a spinlock will suffice.
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>
14 diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c
15 index 92969f8..858fba1 100644
18 @@ -156,7 +156,7 @@ void dlm_dir_remove_entry(struct dlm_ls *ls, int nodeid, char *name, int namelen
20 bucket = dir_hash(ls, name, namelen);
22 - write_lock(&ls->ls_dirtbl[bucket].lock);
23 + spin_lock(&ls->ls_dirtbl[bucket].lock);
25 de = search_bucket(ls, name, namelen, bucket);
27 @@ -173,7 +173,7 @@ void dlm_dir_remove_entry(struct dlm_ls *ls, int nodeid, char *name, int namelen
31 - write_unlock(&ls->ls_dirtbl[bucket].lock);
32 + spin_unlock(&ls->ls_dirtbl[bucket].lock);
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), );
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);
48 - write_unlock(&ls->ls_dirtbl[i].lock);
49 + spin_unlock(&ls->ls_dirtbl[i].lock);
53 @@ -307,17 +307,17 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,
55 bucket = dir_hash(ls, name, namelen);
57 - write_lock(&ls->ls_dirtbl[bucket].lock);
58 + spin_lock(&ls->ls_dirtbl[bucket].lock);
59 de = search_bucket(ls, name, namelen, bucket);
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)
69 - write_unlock(&ls->ls_dirtbl[bucket].lock);
70 + spin_unlock(&ls->ls_dirtbl[bucket].lock);
72 if (namelen > DLM_RESNAME_MAXLEN)
74 @@ -330,7 +330,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,
76 memcpy(de->name, name, namelen);
78 - write_lock(&ls->ls_dirtbl[bucket].lock);
79 + spin_lock(&ls->ls_dirtbl[bucket].lock);
80 tmp = search_bucket(ls, name, namelen, bucket);
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);
86 *r_nodeid = de->master_nodeid;
87 - write_unlock(&ls->ls_dirtbl[bucket].lock);
88 + spin_unlock(&ls->ls_dirtbl[bucket].lock);
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 {
99 struct list_head list;
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,
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);
117 INIT_LIST_HEAD(&ls->ls_waiters);