From 9aa574a51b84717c1f3949ed2e28a49e49840a93 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Sun, 22 Oct 2017 12:41:38 +0530 Subject: protocol/client: handle the subdir handshake properly for add-brick There should be different way we handle handshake in case of subdir mount for the first time, and in case of subsequent graph changes. Change-Id: I2a7ba836433bb0a0f4a861809e2bb0d7fbc4da54 BUG: 1505323 Signed-off-by: Amar Tumballi --- tests/features/subdir-mount.t | 31 +++++++++++++++++++++----- xlators/protocol/client/src/client-handshake.c | 10 ++++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/tests/features/subdir-mount.t b/tests/features/subdir-mount.t index ab7ef35815..1742f8655e 100644 --- a/tests/features/subdir-mount.t +++ b/tests/features/subdir-mount.t @@ -82,17 +82,38 @@ TEST $CLI volume stop $V0 TEST $CLI volume start $V0 -# /subdir2 has not allowed IP -TEST $GFS --subdir-mount /subdir2 -s $H0 --volfile-id $V0 $M1 -TEST stat $M1 - TEST $GFS --subdir-mount /subdir1/subdir1.1/subdir1.2 -s $H0 --volfile-id $V0 $M2 TEST stat $M2 +# mount shouldn't fail even after add-brick +TEST $CLI volume add-brick $V0 replica 2 $H0:$B0/${V0}{5,6}; + +# Give time for client process to get notified and use the new +# volfile after add-brick +sleep 1 + +# Existing mount should still be active +mount_inode=$(stat --format "%i" "$M2") +TEST test "$mount_inode" == "1" + +TEST umount $M2 + +# because the subdir is not yet 'healed', below should fail. +TEST $GFS --subdir-mount /subdir2 -s $H0 --volfile-id $V0 $M2 +mount_inode=$(stat --format "%i" "$M2") +TEST test "$mount_inode" != "1" + +# Allow the heal to complete +TEST stat $M0/subdir1/subdir1.1/subdir1.2/subdir1.2_file; +TEST stat $M0/subdir2/ + +# Now the mount should succeed +TEST $GFS --subdir-mount /subdir2 -s $H0 --volfile-id $V0 $M1 +TEST stat $M1 + # umount $M1 / $M2 TEST umount $M0 TEST umount $M1 -TEST umount $M2 TEST $CLI volume stop $V0; diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index cd71c2c34a..3cf2b06cb0 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -1079,10 +1079,14 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m int32_t op_errno = 0; gf_boolean_t auth_fail = _gf_false; uint32_t lk_ver = 0; + glusterfs_ctx_t *ctx = NULL; frame = myframe; this = frame->this; conf = this->private; + GF_VALIDATE_OR_GOTO (this->name, conf, out); + ctx = this->ctx; + GF_VALIDATE_OR_GOTO (this->name, ctx, out); if (-1 == req->rpc_status) { gf_msg (frame->this->name, GF_LOG_WARNING, ENOTCONN, @@ -1145,9 +1149,13 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m auth_fail = _gf_true; op_ret = 0; } - if ((op_errno == ENOENT) && this->ctx->cmd_args.subdir_mount) { + if ((op_errno == ENOENT) && this->ctx->cmd_args.subdir_mount && + (ctx->graph_id <= 1)) { /* A case of subdir not being present at the moment, ride on auth_fail framework to notify the error */ + /* Make sure this case is handled only in the new + graph, so mount may fail in this case. In case + of 'add-brick' etc, we need to continue retry */ auth_fail = _gf_true; op_ret = 0; } -- cgit