]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Sunil Mushran <sunil.mushran@oracle.com> |
2 | Date: Thu, 26 Feb 2009 15:00:38 -0800 | |
3 | Subject: ocfs2/dlm: Clean up struct dlm_lock_name | |
4 | Patch-mainline: 2.6.30 | |
5 | References: bnc#408304 | |
6 | ||
7 | For master mle, the name it stored in the attached lockres in struct qstr. | |
8 | For block and migration mle, the name is stored inline in struct dlm_lock_name. | |
9 | This patch attempts to make struct dlm_lock_name look like a struct qstr. While | |
10 | we could use struct qstr, we don't because we want to avoid having to malloc | |
11 | and free the lockname string as the mle's lifetime is fairly short. | |
12 | ||
13 | Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> | |
14 | Signed-off-by: Mark Fasheh <mfasheh@suse.com> | |
15 | --- | |
16 | fs/ocfs2/dlm/dlmcommon.h | 8 ++-- | |
17 | fs/ocfs2/dlm/dlmdebug.c | 10 +++--- | |
18 | fs/ocfs2/dlm/dlmmaster.c | 79 +++++++++++++++++++++++++-------------------- | |
19 | 3 files changed, 53 insertions(+), 44 deletions(-) | |
20 | ||
21 | Index: linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmcommon.h | |
22 | =================================================================== | |
23 | --- linux-2.6.27-sle11_ocfs2_update.orig/fs/ocfs2/dlm/dlmcommon.h | |
24 | +++ linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmcommon.h | |
25 | @@ -56,8 +56,8 @@ enum dlm_mle_type { | |
26 | }; | |
27 | ||
28 | struct dlm_lock_name { | |
29 | - u8 len; | |
30 | - u8 name[DLM_LOCKID_NAME_MAX]; | |
31 | + unsigned int len; | |
32 | + unsigned char name[DLM_LOCKID_NAME_MAX]; | |
33 | }; | |
34 | ||
35 | struct dlm_master_list_entry { | |
36 | @@ -79,8 +79,8 @@ struct dlm_master_list_entry { | |
37 | struct o2hb_callback_func mle_hb_up; | |
38 | struct o2hb_callback_func mle_hb_down; | |
39 | union { | |
40 | - struct dlm_lock_resource *res; | |
41 | - struct dlm_lock_name name; | |
42 | + struct dlm_lock_resource *mleres; | |
43 | + struct dlm_lock_name mlename; | |
44 | } u; | |
45 | }; | |
46 | ||
47 | Index: linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmdebug.c | |
48 | =================================================================== | |
49 | --- linux-2.6.27-sle11_ocfs2_update.orig/fs/ocfs2/dlm/dlmdebug.c | |
50 | +++ linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmdebug.c | |
51 | @@ -288,15 +288,15 @@ static int dump_mle(struct dlm_master_li | |
52 | { | |
53 | int out = 0; | |
54 | unsigned int namelen; | |
55 | - const char *name; | |
56 | + unsigned char *name; | |
57 | char *mle_type; | |
58 | ||
59 | if (mle->type != DLM_MLE_MASTER) { | |
60 | - namelen = mle->u.name.len; | |
61 | - name = mle->u.name.name; | |
62 | + name = mle->u.mlename.name; | |
63 | + namelen = mle->u.mlename.len; | |
64 | } else { | |
65 | - namelen = mle->u.res->lockname.len; | |
66 | - name = mle->u.res->lockname.name; | |
67 | + name = (unsigned char *)mle->u.mleres->lockname.name; | |
68 | + namelen = mle->u.mleres->lockname.len; | |
69 | } | |
70 | ||
71 | if (mle->type == DLM_MLE_BLOCK) | |
72 | Index: linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmmaster.c | |
73 | =================================================================== | |
74 | --- linux-2.6.27-sle11_ocfs2_update.orig/fs/ocfs2/dlm/dlmmaster.c | |
75 | +++ linux-2.6.27-sle11_ocfs2_update/fs/ocfs2/dlm/dlmmaster.c | |
76 | @@ -68,27 +68,38 @@ static int dlm_do_assert_master(struct d | |
77 | void *nodemap, u32 flags); | |
78 | static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data); | |
79 | ||
80 | +static inline void __dlm_mle_name(struct dlm_master_list_entry *mle, | |
81 | + unsigned char **name, unsigned int *namelen) | |
82 | +{ | |
83 | + BUG_ON(mle->type != DLM_MLE_BLOCK && | |
84 | + mle->type != DLM_MLE_MASTER && | |
85 | + mle->type != DLM_MLE_MIGRATION); | |
86 | + | |
87 | + if (mle->type != DLM_MLE_MASTER) { | |
88 | + *name = mle->u.mlename.name; | |
89 | + *namelen = mle->u.mlename.len; | |
90 | + } else { | |
91 | + *name = (unsigned char *)mle->u.mleres->lockname.name; | |
92 | + *namelen = mle->u.mleres->lockname.len; | |
93 | + } | |
94 | +} | |
95 | + | |
96 | static inline int dlm_mle_equal(struct dlm_ctxt *dlm, | |
97 | struct dlm_master_list_entry *mle, | |
98 | const char *name, | |
99 | unsigned int namelen) | |
100 | { | |
101 | - struct dlm_lock_resource *res; | |
102 | + unsigned char *mlename; | |
103 | + unsigned int mlelen; | |
104 | ||
105 | if (dlm != mle->dlm) | |
106 | return 0; | |
107 | ||
108 | - if (mle->type == DLM_MLE_BLOCK || | |
109 | - mle->type == DLM_MLE_MIGRATION) { | |
110 | - if (namelen != mle->u.name.len || | |
111 | - memcmp(name, mle->u.name.name, namelen)!=0) | |
112 | - return 0; | |
113 | - } else { | |
114 | - res = mle->u.res; | |
115 | - if (namelen != res->lockname.len || | |
116 | - memcmp(res->lockname.name, name, namelen) != 0) | |
117 | - return 0; | |
118 | - } | |
119 | + __dlm_mle_name(mle, &mlename, &mlelen); | |
120 | + | |
121 | + if (namelen != mlelen || memcmp(name, mlename, namelen) != 0) | |
122 | + return 0; | |
123 | + | |
124 | return 1; | |
125 | } | |
126 | ||
127 | @@ -295,17 +306,17 @@ static void dlm_init_mle(struct dlm_mast | |
128 | mle->new_master = O2NM_MAX_NODES; | |
129 | mle->inuse = 0; | |
130 | ||
131 | + BUG_ON(mle->type != DLM_MLE_BLOCK && | |
132 | + mle->type != DLM_MLE_MASTER && | |
133 | + mle->type != DLM_MLE_MIGRATION); | |
134 | + | |
135 | if (mle->type == DLM_MLE_MASTER) { | |
136 | BUG_ON(!res); | |
137 | - mle->u.res = res; | |
138 | - } else if (mle->type == DLM_MLE_BLOCK) { | |
139 | - BUG_ON(!name); | |
140 | - memcpy(mle->u.name.name, name, namelen); | |
141 | - mle->u.name.len = namelen; | |
142 | - } else /* DLM_MLE_MIGRATION */ { | |
143 | + mle->u.mleres = res; | |
144 | + } else { | |
145 | BUG_ON(!name); | |
146 | - memcpy(mle->u.name.name, name, namelen); | |
147 | - mle->u.name.len = namelen; | |
148 | + memcpy(mle->u.mlename.name, name, namelen); | |
149 | + mle->u.mlename.len = namelen; | |
150 | } | |
151 | ||
152 | /* copy off the node_map and register hb callbacks on our copy */ | |
153 | @@ -425,11 +436,11 @@ static void dlm_mle_release(struct kref | |
154 | ||
155 | if (mle->type != DLM_MLE_MASTER) { | |
156 | mlog(0, "calling mle_release for %.*s, type %d\n", | |
157 | - mle->u.name.len, mle->u.name.name, mle->type); | |
158 | + mle->u.mlename.len, mle->u.mlename.name, mle->type); | |
159 | } else { | |
160 | mlog(0, "calling mle_release for %.*s, type %d\n", | |
161 | - mle->u.res->lockname.len, | |
162 | - mle->u.res->lockname.name, mle->type); | |
163 | + mle->u.mleres->lockname.len, | |
164 | + mle->u.mleres->lockname.name, mle->type); | |
165 | } | |
166 | assert_spin_locked(&dlm->spinlock); | |
167 | assert_spin_locked(&dlm->master_lock); | |
168 | @@ -1277,7 +1288,7 @@ static int dlm_restart_lock_mastery(stru | |
169 | res->lockname.len, | |
170 | res->lockname.name); | |
171 | mle->type = DLM_MLE_MASTER; | |
172 | - mle->u.res = res; | |
173 | + mle->u.mleres = res; | |
174 | } | |
175 | } | |
176 | } | |
177 | @@ -1316,20 +1327,18 @@ static int dlm_do_master_request(struct | |
178 | struct dlm_ctxt *dlm = mle->dlm; | |
179 | struct dlm_master_request request; | |
180 | int ret, response=0, resend; | |
181 | + unsigned char *mlename; | |
182 | + unsigned int mlenamelen; | |
183 | ||
184 | memset(&request, 0, sizeof(request)); | |
185 | request.node_idx = dlm->node_num; | |
186 | ||
187 | BUG_ON(mle->type == DLM_MLE_MIGRATION); | |
188 | ||
189 | - if (mle->type != DLM_MLE_MASTER) { | |
190 | - request.namelen = mle->u.name.len; | |
191 | - memcpy(request.name, mle->u.name.name, request.namelen); | |
192 | - } else { | |
193 | - request.namelen = mle->u.res->lockname.len; | |
194 | - memcpy(request.name, mle->u.res->lockname.name, | |
195 | - request.namelen); | |
196 | - } | |
197 | + __dlm_mle_name(mle, &mlename, &mlenamelen); | |
198 | + | |
199 | + request.namelen = (u8)mlenamelen; | |
200 | + memcpy(request.name, mlename, request.namelen); | |
201 | ||
202 | again: | |
203 | ret = o2net_send_message(DLM_MASTER_REQUEST_MSG, dlm->key, &request, | |
204 | @@ -3264,9 +3273,9 @@ top: | |
205 | mle->master, mle->new_master); | |
206 | /* if there is a lockres associated with this | |
207 | * mle, find it and set its owner to UNKNOWN */ | |
208 | - hash = dlm_lockid_hash(mle->u.name.name, mle->u.name.len); | |
209 | - res = __dlm_lookup_lockres(dlm, mle->u.name.name, | |
210 | - mle->u.name.len, hash); | |
211 | + hash = dlm_lockid_hash(mle->u.mlename.name, mle->u.mlename.len); | |
212 | + res = __dlm_lookup_lockres(dlm, mle->u.mlename.name, | |
213 | + mle->u.mlename.len, hash); | |
214 | if (res) { | |
215 | /* unfortunately if we hit this rare case, our | |
216 | * lock ordering is messed. we need to drop |