Commit 72f6fe1f authored by Norton.Zhu's avatar Norton.Zhu Committed by Linus Torvalds

ocfs2: optimize error handling in dlm_request_join

Currently error handling in dlm_request_join is a little obscure, so
optimize it to promote readability.

If packet.code is invalid, reset it to JOIN_DISALLOW to keep it
meaningful.  It only influences the log printing.
Signed-off-by: default avatarNorton.Zhu <norton.zhu@huawei.com>
Cc: Srinivas Eeda <srinivas.eeda@oracle.com>
Reviewed-by: default avatarMark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 928dda1f
......@@ -1465,10 +1465,13 @@ static int dlm_request_join(struct dlm_ctxt *dlm,
if (status == -ENOPROTOOPT) {
status = 0;
*response = JOIN_OK_NO_MAP;
} else if (packet.code == JOIN_DISALLOW ||
packet.code == JOIN_OK_NO_MAP) {
} else {
*response = packet.code;
} else if (packet.code == JOIN_PROTOCOL_MISMATCH) {
switch (packet.code) {
case JOIN_DISALLOW:
case JOIN_OK_NO_MAP:
break;
case JOIN_PROTOCOL_MISMATCH:
mlog(ML_NOTICE,
"This node requested DLM locking protocol %u.%u and "
"filesystem locking protocol %u.%u. At least one of "
......@@ -1480,9 +1483,8 @@ static int dlm_request_join(struct dlm_ctxt *dlm,
dlm->fs_locking_proto.pv_minor,
node);
status = -EPROTO;
*response = packet.code;
} else if (packet.code == JOIN_OK) {
*response = packet.code;
break;
case JOIN_OK:
/* Use the same locking protocol as the remote node */
dlm->dlm_locking_proto.pv_minor = packet.dlm_minor;
dlm->fs_locking_proto.pv_minor = packet.fs_minor;
......@@ -1494,10 +1496,15 @@ static int dlm_request_join(struct dlm_ctxt *dlm,
dlm->dlm_locking_proto.pv_minor,
dlm->fs_locking_proto.pv_major,
dlm->fs_locking_proto.pv_minor);
} else {
break;
default:
status = -EINVAL;
mlog(ML_ERROR, "invalid response %d from node %u\n",
packet.code, node);
/* Reset response to JOIN_DISALLOW */
*response = JOIN_DISALLOW;
break;
}
}
mlog(0, "status %d, node %d response is %d\n", status, node,
......
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