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