Commit 8bc674cb authored by Kurt Hackel's avatar Kurt Hackel Committed by Mark Fasheh

ocfs2: Fix empty lvb check

The check for an empty lvb should check the entire buffer not just the first
byte.
Signed-off-by: default avatarKurt Hackel <kurt.hackel@oracle.com>
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent aba9aac7
...@@ -315,6 +315,15 @@ enum dlm_lockres_list { ...@@ -315,6 +315,15 @@ enum dlm_lockres_list {
DLM_BLOCKED_LIST DLM_BLOCKED_LIST
}; };
static inline int dlm_lvb_is_empty(char *lvb)
{
int i;
for (i=0; i<DLM_LVB_LEN; i++)
if (lvb[i])
return 0;
return 1;
}
static inline struct list_head * static inline struct list_head *
dlm_list_idx_to_ptr(struct dlm_lock_resource *res, enum dlm_lockres_list idx) dlm_list_idx_to_ptr(struct dlm_lock_resource *res, enum dlm_lockres_list idx)
{ {
......
...@@ -1021,8 +1021,9 @@ static int dlm_add_lock_to_array(struct dlm_lock *lock, ...@@ -1021,8 +1021,9 @@ static int dlm_add_lock_to_array(struct dlm_lock *lock,
ml->type == LKM_PRMODE) { ml->type == LKM_PRMODE) {
/* if it is already set, this had better be a PR /* if it is already set, this had better be a PR
* and it has to match */ * and it has to match */
if (mres->lvb[0] && (ml->type == LKM_EXMODE || if (!dlm_lvb_is_empty(mres->lvb) &&
memcmp(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN))) { (ml->type == LKM_EXMODE ||
memcmp(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN))) {
mlog(ML_ERROR, "mismatched lvbs!\n"); mlog(ML_ERROR, "mismatched lvbs!\n");
__dlm_print_one_lock_resource(lock->lockres); __dlm_print_one_lock_resource(lock->lockres);
BUG(); BUG();
...@@ -1554,7 +1555,7 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm, ...@@ -1554,7 +1555,7 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
lksb->flags |= (ml->flags & lksb->flags |= (ml->flags &
(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB)); (DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB));
if (mres->lvb[0]) { if (!dlm_lvb_is_empty(mres->lvb)) {
if (lksb->flags & DLM_LKSB_PUT_LVB) { if (lksb->flags & DLM_LKSB_PUT_LVB) {
/* other node was trying to update /* other node was trying to update
* lvb when node died. recreate the * lvb when node died. recreate the
...@@ -1565,8 +1566,9 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm, ...@@ -1565,8 +1566,9 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
* most recent valid lvb info */ * most recent valid lvb info */
BUG_ON(ml->type != LKM_EXMODE && BUG_ON(ml->type != LKM_EXMODE &&
ml->type != LKM_PRMODE); ml->type != LKM_PRMODE);
if (res->lvb[0] && (ml->type == LKM_EXMODE || if (!dlm_lvb_is_empty(res->lvb) &&
memcmp(res->lvb, mres->lvb, DLM_LVB_LEN))) { (ml->type == LKM_EXMODE ||
memcmp(res->lvb, mres->lvb, DLM_LVB_LEN))) {
mlog(ML_ERROR, "received bad lvb!\n"); mlog(ML_ERROR, "received bad lvb!\n");
__dlm_print_one_lock_resource(res); __dlm_print_one_lock_resource(res);
BUG(); BUG();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment