diff options
Diffstat (limited to 'fs/ocfs2/dlm/dlmmaster.c')
-rw-r--r-- | fs/ocfs2/dlm/dlmmaster.c | 68 |
1 files changed, 18 insertions, 50 deletions
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index d9c5c5a3400..f8b653fcd4d 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); |
69 | static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data); | 69 | static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data); |
70 | 70 | ||
71 | static 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 | |||
92 | static inline int dlm_mle_equal(struct dlm_ctxt *dlm, | 71 | static 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) | |||
350 | void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle) | 329 | void __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 | ||
1339 | again: | 1309 | again: |
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 | ||