diff options
-rw-r--r-- | tests/bugs/bug-1164613.t | 7 | ||||
-rwxr-xr-x | tests/bugs/bug-1166197.t | 48 | ||||
-rw-r--r-- | tests/include.rc | 6 | ||||
-rw-r--r-- | xlators/features/snapview-client/src/snapview-client.c | 35 | ||||
-rw-r--r-- | xlators/features/snapview-server/src/snapview-server.c | 8 |
5 files changed, 85 insertions, 19 deletions
diff --git a/tests/bugs/bug-1164613.t b/tests/bugs/bug-1164613.t index 1942dcbc628..b7b27f1d649 100644 --- a/tests/bugs/bug-1164613.t +++ b/tests/bugs/bug-1164613.t @@ -3,11 +3,6 @@ . $(dirname $0)/../include.rc . $(dirname $0)/../snapshot.rc -function stat_testfile() { - stat $M0/snaps/snaps/testfile - echo $? -} - cleanup; TEST verify_lvm_version; TEST glusterd; @@ -26,7 +21,7 @@ TEST $CLI snapshot activate snaps TEST $CLI volume set $V0 features.uss enable TEST $CLI volume set $V0 snapshot-directory snaps -EXPECT_WITHIN 20 "0" stat_testfile +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" STAT $M0/snaps/snaps/testfile umount -f $M0 diff --git a/tests/bugs/bug-1166197.t b/tests/bugs/bug-1166197.t new file mode 100755 index 00000000000..a1e2480d62b --- /dev/null +++ b/tests/bugs/bug-1166197.t @@ -0,0 +1,48 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../snapshot.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../nfs.rc + +cleanup; +CURDIR=`pwd` + +TEST verify_lvm_version; +TEST glusterd; +TEST pidof glusterd; + +TEST setup_lvm 1 + +TEST $CLI volume create $V0 $H0:$L1 +TEST $CLI volume start $V0 +TEST $CLI snapshot config activate-on-create enable +TEST $CLI volume set $V0 features.uss enable + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status'; +TEST mount_nfs $H0:/$V0 $N0 nolock +TEST mkdir $N0/testdir + +TEST $CLI snapshot create snap1 $V0 +TEST $CLI snapshot create snap2 $V0 + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" STAT $N0/testdir/.snaps + +TEST cd $N0/testdir +TEST cd .snaps +TEST ls + +TEST $CLI snapshot deactivate snap2 +TEST ls + +TEST cd $CURDIR + +#Clean up +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" umount_nfs $N0 +TEST $CLI snapshot delete snap1 +TEST $CLI snapshot delete snap2 +TEST $CLI volume stop $V0 force +TEST $CLI volume delete $V0 + +cleanup; + diff --git a/tests/include.rc b/tests/include.rc index 000005a4e33..dc6fc6e25dc 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -826,3 +826,9 @@ function UMOUNT_LOOP () ;; esac } + +function STAT() +{ + stat $1 + echo $? +} diff --git a/xlators/features/snapview-client/src/snapview-client.c b/xlators/features/snapview-client/src/snapview-client.c index 5f58422c32e..ea0feeaf4b2 100644 --- a/xlators/features/snapview-client/src/snapview-client.c +++ b/xlators/features/snapview-client/src/snapview-client.c @@ -147,16 +147,36 @@ svc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, is happening on a virtual inode (i.e history data residing in snaps). So if lookup fails with ENOENT and the inode context is not there, then send the lookup to the 2nd child of svc. + + If there are any changes in volfile/client-restarted then inode-ctx + is lost. In this case if nameless lookup fails with ESTALE, + then send the lookup to the 2nd child of svc. */ if (op_ret) { - if (op_errno == ENOENT && + if (subvolume == FIRST_CHILD (this)) { + gf_log (this->name, + (op_errno == ENOENT || op_errno == ESTALE) + ? GF_LOG_DEBUG:GF_LOG_ERROR, + "Lookup failed on normal graph with error %s", + strerror (op_errno)); + } else { + gf_log (this->name, + (op_errno == ENOENT || op_errno == ESTALE) + ? GF_LOG_DEBUG:GF_LOG_ERROR, + "Lookup failed on snapview graph with error %s", + strerror (op_errno)); + } + + if ((op_errno == ENOENT || op_errno == ESTALE) && !uuid_is_null (local->loc.gfid)) { ret = svc_inode_ctx_get (this, inode, &inode_type); if (ret < 0 && subvolume == FIRST_CHILD (this)) { gf_log (this->name, GF_LOG_DEBUG, "Lookup on normal graph failed. " "Sending lookup to snapview-server"); + subvolume = SECOND_CHILD (this); + local->subvolume = subvolume; STACK_WIND (frame, svc_lookup_cbk, subvolume, subvolume->fops->lookup, &local->loc, xdata); @@ -164,18 +184,7 @@ svc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } } - if (subvolume == FIRST_CHILD (this)) { - gf_log (this->name, - (op_errno == ENOENT)?GF_LOG_DEBUG:GF_LOG_ERROR, - "Lookup failed on normal graph with error %s", - strerror (op_errno)); - } else { - gf_log (this->name, - (op_errno == ENOENT)?GF_LOG_DEBUG:GF_LOG_ERROR, - "Lookup failed on snapview graph with error %s", - strerror (op_errno)); - } - goto out; + goto out; } if (local->loc.parent) diff --git a/xlators/features/snapview-server/src/snapview-server.c b/xlators/features/snapview-server/src/snapview-server.c index 6c65497b34c..d66150e769a 100644 --- a/xlators/features/snapview-server/src/snapview-server.c +++ b/xlators/features/snapview-server/src/snapview-server.c @@ -536,6 +536,14 @@ svs_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) fs = svs_initialise_snapshot_volume (this, dirent->name, NULL); } + if (inode_ctx && inode_ctx->type == SNAP_VIEW_ENTRY_POINT_INODE) { + /* entry-point may not be set in the dictonary. + * This can happen if snap-view client is restarted where + * inode-ctx not available and a nameless lookup has come + */ + entry_point = _gf_true; + } + /* lookup is on the entry point to the snapshot world */ if (entry_point) { op_ret = svs_lookup_entry_point (this, loc, parent, &buf, |