diff options
-rw-r--r-- | fs/ocfs2/dlm/dlmcommon.h | 8 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmdebug.c | 10 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmmaster.c | 79 |
3 files changed, 53 insertions, 44 deletions
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index 261e26501e57..b232aa0b3345 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h | |||
@@ -56,8 +56,8 @@ enum dlm_mle_type { | |||
56 | }; | 56 | }; |
57 | 57 | ||
58 | struct dlm_lock_name { | 58 | struct dlm_lock_name { |
59 | u8 len; | 59 | unsigned int len; |
60 | u8 name[DLM_LOCKID_NAME_MAX]; | 60 | unsigned char name[DLM_LOCKID_NAME_MAX]; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | struct dlm_master_list_entry { | 63 | struct dlm_master_list_entry { |
@@ -79,8 +79,8 @@ struct dlm_master_list_entry { | |||
79 | struct o2hb_callback_func mle_hb_up; | 79 | struct o2hb_callback_func mle_hb_up; |
80 | struct o2hb_callback_func mle_hb_down; | 80 | struct o2hb_callback_func mle_hb_down; |
81 | union { | 81 | union { |
82 | struct dlm_lock_resource *res; | 82 | struct dlm_lock_resource *mleres; |
83 | struct dlm_lock_name name; | 83 | struct dlm_lock_name mlename; |
84 | } u; | 84 | } u; |
85 | }; | 85 | }; |
86 | 86 | ||
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c index b32f60a5acfb..c82feb7b00b9 100644 --- a/fs/ocfs2/dlm/dlmdebug.c +++ b/fs/ocfs2/dlm/dlmdebug.c | |||
@@ -288,15 +288,15 @@ static 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; | 290 | unsigned int namelen; |
291 | const char *name; | 291 | unsigned char *name; |
292 | char *mle_type; | 292 | char *mle_type; |
293 | 293 | ||
294 | if (mle->type != DLM_MLE_MASTER) { | 294 | if (mle->type != DLM_MLE_MASTER) { |
295 | namelen = mle->u.name.len; | 295 | name = mle->u.mlename.name; |
296 | name = mle->u.name.name; | 296 | namelen = mle->u.mlename.len; |
297 | } else { | 297 | } else { |
298 | namelen = mle->u.res->lockname.len; | 298 | name = (unsigned char *)mle->u.mleres->lockname.name; |
299 | name = mle->u.res->lockname.name; | 299 | namelen = mle->u.mleres->lockname.len; |
300 | } | 300 | } |
301 | 301 | ||
302 | if (mle->type == DLM_MLE_BLOCK) | 302 | if (mle->type == DLM_MLE_BLOCK) |
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 0aa4b043f4de..040581e1cd04 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
@@ -68,27 +68,38 @@ 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 | { | ||
74 | BUG_ON(mle->type != DLM_MLE_BLOCK && | ||
75 | mle->type != DLM_MLE_MASTER && | ||
76 | mle->type != DLM_MLE_MIGRATION); | ||
77 | |||
78 | if (mle->type != DLM_MLE_MASTER) { | ||
79 | *name = mle->u.mlename.name; | ||
80 | *namelen = mle->u.mlename.len; | ||
81 | } else { | ||
82 | *name = (unsigned char *)mle->u.mleres->lockname.name; | ||
83 | *namelen = mle->u.mleres->lockname.len; | ||
84 | } | ||
85 | } | ||
86 | |||
71 | static inline int dlm_mle_equal(struct dlm_ctxt *dlm, | 87 | static inline int dlm_mle_equal(struct dlm_ctxt *dlm, |
72 | struct dlm_master_list_entry *mle, | 88 | struct dlm_master_list_entry *mle, |
73 | const char *name, | 89 | const char *name, |
74 | unsigned int namelen) | 90 | unsigned int namelen) |
75 | { | 91 | { |
76 | struct dlm_lock_resource *res; | 92 | unsigned char *mlename; |
93 | unsigned int mlelen; | ||
77 | 94 | ||
78 | if (dlm != mle->dlm) | 95 | if (dlm != mle->dlm) |
79 | return 0; | 96 | return 0; |
80 | 97 | ||
81 | if (mle->type == DLM_MLE_BLOCK || | 98 | __dlm_mle_name(mle, &mlename, &mlelen); |
82 | mle->type == DLM_MLE_MIGRATION) { | 99 | |
83 | if (namelen != mle->u.name.len || | 100 | if (namelen != mlelen || memcmp(name, mlename, namelen) != 0) |
84 | memcmp(name, mle->u.name.name, namelen)!=0) | 101 | return 0; |
85 | return 0; | 102 | |
86 | } else { | ||
87 | res = mle->u.res; | ||
88 | if (namelen != res->lockname.len || | ||
89 | memcmp(res->lockname.name, name, namelen) != 0) | ||
90 | return 0; | ||
91 | } | ||
92 | return 1; | 103 | return 1; |
93 | } | 104 | } |
94 | 105 | ||
@@ -295,17 +306,17 @@ static void dlm_init_mle(struct dlm_master_list_entry *mle, | |||
295 | mle->new_master = O2NM_MAX_NODES; | 306 | mle->new_master = O2NM_MAX_NODES; |
296 | mle->inuse = 0; | 307 | mle->inuse = 0; |
297 | 308 | ||
309 | BUG_ON(mle->type != DLM_MLE_BLOCK && | ||
310 | mle->type != DLM_MLE_MASTER && | ||
311 | mle->type != DLM_MLE_MIGRATION); | ||
312 | |||
298 | if (mle->type == DLM_MLE_MASTER) { | 313 | if (mle->type == DLM_MLE_MASTER) { |
299 | BUG_ON(!res); | 314 | BUG_ON(!res); |
300 | mle->u.res = res; | 315 | mle->u.mleres = res; |
301 | } else if (mle->type == DLM_MLE_BLOCK) { | 316 | } else { |
302 | BUG_ON(!name); | ||
303 | memcpy(mle->u.name.name, name, namelen); | ||
304 | mle->u.name.len = namelen; | ||
305 | } else /* DLM_MLE_MIGRATION */ { | ||
306 | BUG_ON(!name); | 317 | BUG_ON(!name); |
307 | memcpy(mle->u.name.name, name, namelen); | 318 | memcpy(mle->u.mlename.name, name, namelen); |
308 | mle->u.name.len = namelen; | 319 | mle->u.mlename.len = namelen; |
309 | } | 320 | } |
310 | 321 | ||
311 | /* copy off the node_map and register hb callbacks on our copy */ | 322 | /* copy off the node_map and register hb callbacks on our copy */ |
@@ -425,11 +436,11 @@ static void dlm_mle_release(struct kref *kref) | |||
425 | 436 | ||
426 | if (mle->type != DLM_MLE_MASTER) { | 437 | if (mle->type != DLM_MLE_MASTER) { |
427 | mlog(0, "calling mle_release for %.*s, type %d\n", | 438 | mlog(0, "calling mle_release for %.*s, type %d\n", |
428 | mle->u.name.len, mle->u.name.name, mle->type); | 439 | mle->u.mlename.len, mle->u.mlename.name, mle->type); |
429 | } else { | 440 | } else { |
430 | mlog(0, "calling mle_release for %.*s, type %d\n", | 441 | mlog(0, "calling mle_release for %.*s, type %d\n", |
431 | mle->u.res->lockname.len, | 442 | mle->u.mleres->lockname.len, |
432 | mle->u.res->lockname.name, mle->type); | 443 | mle->u.mleres->lockname.name, mle->type); |
433 | } | 444 | } |
434 | assert_spin_locked(&dlm->spinlock); | 445 | assert_spin_locked(&dlm->spinlock); |
435 | assert_spin_locked(&dlm->master_lock); | 446 | assert_spin_locked(&dlm->master_lock); |
@@ -1284,7 +1295,7 @@ static int dlm_restart_lock_mastery(struct dlm_ctxt *dlm, | |||
1284 | res->lockname.len, | 1295 | res->lockname.len, |
1285 | res->lockname.name); | 1296 | res->lockname.name); |
1286 | mle->type = DLM_MLE_MASTER; | 1297 | mle->type = DLM_MLE_MASTER; |
1287 | mle->u.res = res; | 1298 | mle->u.mleres = res; |
1288 | } | 1299 | } |
1289 | } | 1300 | } |
1290 | } | 1301 | } |
@@ -1323,20 +1334,18 @@ static int dlm_do_master_request(struct dlm_lock_resource *res, | |||
1323 | struct dlm_ctxt *dlm = mle->dlm; | 1334 | struct dlm_ctxt *dlm = mle->dlm; |
1324 | struct dlm_master_request request; | 1335 | struct dlm_master_request request; |
1325 | int ret, response=0, resend; | 1336 | int ret, response=0, resend; |
1337 | unsigned char *mlename; | ||
1338 | unsigned int mlenamelen; | ||
1326 | 1339 | ||
1327 | memset(&request, 0, sizeof(request)); | 1340 | memset(&request, 0, sizeof(request)); |
1328 | request.node_idx = dlm->node_num; | 1341 | request.node_idx = dlm->node_num; |
1329 | 1342 | ||
1330 | BUG_ON(mle->type == DLM_MLE_MIGRATION); | 1343 | BUG_ON(mle->type == DLM_MLE_MIGRATION); |
1331 | 1344 | ||
1332 | if (mle->type != DLM_MLE_MASTER) { | 1345 | __dlm_mle_name(mle, &mlename, &mlenamelen); |
1333 | request.namelen = mle->u.name.len; | 1346 | |
1334 | memcpy(request.name, mle->u.name.name, request.namelen); | 1347 | request.namelen = (u8)mlenamelen; |
1335 | } else { | 1348 | memcpy(request.name, mlename, request.namelen); |
1336 | request.namelen = mle->u.res->lockname.len; | ||
1337 | memcpy(request.name, mle->u.res->lockname.name, | ||
1338 | request.namelen); | ||
1339 | } | ||
1340 | 1349 | ||
1341 | again: | 1350 | again: |
1342 | ret = o2net_send_message(DLM_MASTER_REQUEST_MSG, dlm->key, &request, | 1351 | ret = o2net_send_message(DLM_MASTER_REQUEST_MSG, dlm->key, &request, |
@@ -3286,9 +3295,9 @@ top: | |||
3286 | mle->master, mle->new_master); | 3295 | mle->master, mle->new_master); |
3287 | /* if there is a lockres associated with this | 3296 | /* if there is a lockres associated with this |
3288 | * mle, find it and set its owner to UNKNOWN */ | 3297 | * mle, find it and set its owner to UNKNOWN */ |
3289 | hash = dlm_lockid_hash(mle->u.name.name, mle->u.name.len); | 3298 | hash = dlm_lockid_hash(mle->u.mlename.name, mle->u.mlename.len); |
3290 | res = __dlm_lookup_lockres(dlm, mle->u.name.name, | 3299 | res = __dlm_lookup_lockres(dlm, mle->u.mlename.name, |
3291 | mle->u.name.len, hash); | 3300 | mle->u.mlename.len, hash); |
3292 | if (res) { | 3301 | if (res) { |
3293 | /* unfortunately if we hit this rare case, our | 3302 | /* unfortunately if we hit this rare case, our |
3294 | * lock ordering is messed. we need to drop | 3303 | * lock ordering is messed. we need to drop |