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