aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSunil Mushran <sunil.mushran@oracle.com>2009-02-26 18:00:47 -0500
committerMark Fasheh <mfasheh@suse.com>2009-04-03 14:39:23 -0400
commit7141514b8307734c117f100c4a3637887c5def45 (patch)
tree8f2944508cdb0dd1ea7288d7300e4c29995c904e /fs
parente64ff14607ac90b2f3349550a41cc8dc0c0b1324 (diff)
ocfs2/dlm: Remove struct dlm_lock_name in struct dlm_master_list_entry
This patch removes struct dlm_lock_name and adds the entries directly to struct dlm_master_list_entry. Under the new scheme, both mles that are backed by a lockres or not, will have the name populated in mle->mname. This allows us to get rid of code that was figuring out the location of the mle name. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/dlm/dlmcommon.h14
-rw-r--r--fs/ocfs2/dlm/dlmdebug.c12
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c68
3 files changed, 23 insertions, 71 deletions
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index 266fde9354bd..0102be35980c 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -56,12 +56,6 @@ enum dlm_mle_type {
56 DLM_MLE_NUM_TYPES 56 DLM_MLE_NUM_TYPES
57}; 57};
58 58
59struct dlm_lock_name {
60 unsigned int hash;
61 unsigned int len;
62 unsigned char name[DLM_LOCKID_NAME_MAX];
63};
64
65struct dlm_master_list_entry { 59struct dlm_master_list_entry {
66 struct hlist_node master_hash_node; 60 struct hlist_node master_hash_node;
67 struct list_head hb_events; 61 struct list_head hb_events;
@@ -80,10 +74,10 @@ struct dlm_master_list_entry {
80 enum dlm_mle_type type; 74 enum dlm_mle_type type;
81 struct o2hb_callback_func mle_hb_up; 75 struct o2hb_callback_func mle_hb_up;
82 struct o2hb_callback_func mle_hb_down; 76 struct o2hb_callback_func mle_hb_down;
83 union { 77 struct dlm_lock_resource *mleres;
84 struct dlm_lock_resource *mleres; 78 unsigned char mname[DLM_LOCKID_NAME_MAX];
85 struct dlm_lock_name mlename; 79 unsigned int mnamelen;
86 } u; 80 unsigned int mnamehash;
87}; 81};
88 82
89enum dlm_ast_type { 83enum dlm_ast_type {
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index bf9fa270ee98..bdf1c7817bb5 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -287,18 +287,8 @@ static int stringify_nodemap(unsigned long *nodemap, int maxnodes,
287static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len) 287static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len)
288{ 288{
289 int out = 0; 289 int out = 0;
290 unsigned int namelen;
291 unsigned char *name;
292 char *mle_type; 290 char *mle_type;
293 291
294 if (mle->type != DLM_MLE_MASTER) {
295 name = mle->u.mlename.name;
296 namelen = mle->u.mlename.len;
297 } else {
298 name = (unsigned char *)mle->u.mleres->lockname.name;
299 namelen = mle->u.mleres->lockname.len;
300 }
301
302 if (mle->type == DLM_MLE_BLOCK) 292 if (mle->type == DLM_MLE_BLOCK)
303 mle_type = "BLK"; 293 mle_type = "BLK";
304 else if (mle->type == DLM_MLE_MASTER) 294 else if (mle->type == DLM_MLE_MASTER)
@@ -306,7 +296,7 @@ static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len)
306 else 296 else
307 mle_type = "MIG"; 297 mle_type = "MIG";
308 298
309 out += stringify_lockname(name, namelen, buf + out, len - out); 299 out += stringify_lockname(mle->mname, mle->mnamelen, buf + out, len - out);
310 out += snprintf(buf + out, len - out, 300 out += snprintf(buf + out, len - out,
311 "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n", 301 "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n",
312 mle_type, mle->master, mle->new_master, 302 mle_type, mle->master, mle->new_master,
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index d9c5c5a34007..f8b653fcd4dd 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -68,41 +68,16 @@ static int dlm_do_assert_master(struct dlm_ctxt *dlm,
68 void *nodemap, u32 flags); 68 void *nodemap, u32 flags);
69static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data); 69static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data);
70 70
71static inline void __dlm_mle_name(struct dlm_master_list_entry *mle,
72 unsigned char **name, unsigned int *namelen,
73 unsigned int *namehash)
74{
75 BUG_ON(mle->type != DLM_MLE_BLOCK &&
76 mle->type != DLM_MLE_MASTER &&
77 mle->type != DLM_MLE_MIGRATION);
78
79 if (mle->type != DLM_MLE_MASTER) {
80 *name = mle->u.mlename.name;
81 *namelen = mle->u.mlename.len;
82 if (namehash)
83 *namehash = mle->u.mlename.hash;
84 } else {
85 *name = (unsigned char *)mle->u.mleres->lockname.name;
86 *namelen = mle->u.mleres->lockname.len;
87 if (namehash)
88 *namehash = mle->u.mleres->lockname.hash;
89 }
90}
91
92static inline int dlm_mle_equal(struct dlm_ctxt *dlm, 71static inline int dlm_mle_equal(struct dlm_ctxt *dlm,
93 struct dlm_master_list_entry *mle, 72 struct dlm_master_list_entry *mle,
94 const char *name, 73 const char *name,
95 unsigned int namelen) 74 unsigned int namelen)
96{ 75{
97 unsigned char *mlename;
98 unsigned int mlelen;
99
100 if (dlm != mle->dlm) 76 if (dlm != mle->dlm)
101 return 0; 77 return 0;
102 78
103 __dlm_mle_name(mle, &mlename, &mlelen, NULL); 79 if (namelen != mle->mnamelen ||
104 80 memcmp(name, mle->mname, namelen) != 0)
105 if (namelen != mlelen || memcmp(name, mlename, namelen) != 0)
106 return 0; 81 return 0;
107 82
108 return 1; 83 return 1;
@@ -317,12 +292,16 @@ static void dlm_init_mle(struct dlm_master_list_entry *mle,
317 292
318 if (mle->type == DLM_MLE_MASTER) { 293 if (mle->type == DLM_MLE_MASTER) {
319 BUG_ON(!res); 294 BUG_ON(!res);
320 mle->u.mleres = res; 295 mle->mleres = res;
296 memcpy(mle->mname, res->lockname.name, res->lockname.len);
297 mle->mnamelen = res->lockname.len;
298 mle->mnamehash = res->lockname.hash;
321 } else { 299 } else {
322 BUG_ON(!name); 300 BUG_ON(!name);
323 memcpy(mle->u.mlename.name, name, namelen); 301 mle->mleres = NULL;
324 mle->u.mlename.len = namelen; 302 memcpy(mle->mname, name, namelen);
325 mle->u.mlename.hash = dlm_lockid_hash(name, namelen); 303 mle->mnamelen = namelen;
304 mle->mnamehash = dlm_lockid_hash(name, namelen);
326 } 305 }
327 306
328 atomic_inc(&dlm->mle_tot_count[mle->type]); 307 atomic_inc(&dlm->mle_tot_count[mle->type]);
@@ -350,13 +329,10 @@ void __dlm_unlink_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle)
350void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle) 329void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle)
351{ 330{
352 struct hlist_head *bucket; 331 struct hlist_head *bucket;
353 unsigned char *mname;
354 unsigned int mlen, hash;
355 332
356 assert_spin_locked(&dlm->master_lock); 333 assert_spin_locked(&dlm->master_lock);
357 334
358 __dlm_mle_name(mle, &mname, &mlen, &hash); 335 bucket = dlm_master_hash(dlm, mle->mnamehash);
359 bucket = dlm_master_hash(dlm, hash);
360 hlist_add_head(&mle->master_hash_node, bucket); 336 hlist_add_head(&mle->master_hash_node, bucket);
361} 337}
362 338
@@ -450,8 +426,6 @@ static void dlm_mle_release(struct kref *kref)
450{ 426{
451 struct dlm_master_list_entry *mle; 427 struct dlm_master_list_entry *mle;
452 struct dlm_ctxt *dlm; 428 struct dlm_ctxt *dlm;
453 unsigned char *mname;
454 unsigned int mlen;
455 429
456 mlog_entry_void(); 430 mlog_entry_void();
457 431
@@ -461,8 +435,8 @@ static void dlm_mle_release(struct kref *kref)
461 assert_spin_locked(&dlm->spinlock); 435 assert_spin_locked(&dlm->spinlock);
462 assert_spin_locked(&dlm->master_lock); 436 assert_spin_locked(&dlm->master_lock);
463 437
464 __dlm_mle_name(mle, &mname, &mlen, NULL); 438 mlog(0, "Releasing mle for %.*s, type %d\n", mle->mnamelen, mle->mname,
465 mlog(0, "Releasing mle for %.*s, type %d\n", mlen, mname, mle->type); 439 mle->type);
466 440
467 /* remove from list if not already */ 441 /* remove from list if not already */
468 __dlm_unlink_mle(dlm, mle); 442 __dlm_unlink_mle(dlm, mle);
@@ -1284,7 +1258,7 @@ static int dlm_restart_lock_mastery(struct dlm_ctxt *dlm,
1284 res->lockname.len, 1258 res->lockname.len,
1285 res->lockname.name); 1259 res->lockname.name);
1286 mle->type = DLM_MLE_MASTER; 1260 mle->type = DLM_MLE_MASTER;
1287 mle->u.mleres = res; 1261 mle->mleres = res;
1288 } 1262 }
1289 } 1263 }
1290 } 1264 }
@@ -1323,18 +1297,14 @@ static int dlm_do_master_request(struct dlm_lock_resource *res,
1323 struct dlm_ctxt *dlm = mle->dlm; 1297 struct dlm_ctxt *dlm = mle->dlm;
1324 struct dlm_master_request request; 1298 struct dlm_master_request request;
1325 int ret, response=0, resend; 1299 int ret, response=0, resend;
1326 unsigned char *mlename;
1327 unsigned int mlenamelen;
1328 1300
1329 memset(&request, 0, sizeof(request)); 1301 memset(&request, 0, sizeof(request));
1330 request.node_idx = dlm->node_num; 1302 request.node_idx = dlm->node_num;
1331 1303
1332 BUG_ON(mle->type == DLM_MLE_MIGRATION); 1304 BUG_ON(mle->type == DLM_MLE_MIGRATION);
1333 1305
1334 __dlm_mle_name(mle, &mlename, &mlenamelen, NULL); 1306 request.namelen = (u8)mle->mnamelen;
1335 1307 memcpy(request.name, mle->mname, request.namelen);
1336 request.namelen = (u8)mlenamelen;
1337 memcpy(request.name, mlename, request.namelen);
1338 1308
1339again: 1309again:
1340 ret = o2net_send_message(DLM_MASTER_REQUEST_MSG, dlm->key, &request, 1310 ret = o2net_send_message(DLM_MASTER_REQUEST_MSG, dlm->key, &request,
@@ -3203,12 +3173,10 @@ static struct dlm_lock_resource *dlm_reset_mleres_owner(struct dlm_ctxt *dlm,
3203 struct dlm_master_list_entry *mle) 3173 struct dlm_master_list_entry *mle)
3204{ 3174{
3205 struct dlm_lock_resource *res; 3175 struct dlm_lock_resource *res;
3206 unsigned int hash;
3207 3176
3208 /* Find the lockres associated to the mle and set its owner to UNK */ 3177 /* Find the lockres associated to the mle and set its owner to UNK */
3209 hash = dlm_lockid_hash(mle->u.mlename.name, mle->u.mlename.len); 3178 res = __dlm_lookup_lockres(dlm, mle->mname, mle->mnamelen,
3210 res = __dlm_lookup_lockres(dlm, mle->u.mlename.name, mle->u.mlename.len, 3179 mle->mnamehash);
3211 hash);
3212 if (res) { 3180 if (res) {
3213 spin_unlock(&dlm->master_lock); 3181 spin_unlock(&dlm->master_lock);
3214 3182