3604df
From 4bed27703450593b546671f2e3c9649095d9e04d Mon Sep 17 00:00:00 2001
3604df
From: Poornima G <pgurusid@redhat.com>
3604df
Date: Thu, 16 Feb 2017 13:05:25 +0530
3604df
Subject: [PATCH 294/294] marker: Fix inode value in loc, in setxattr fop
3604df
3604df
On recieving a rename fop, marker_rename() stores the,
3604df
oldloc and newloc in its 'local' struct, once the rename
3604df
is done, the xtime marker(last updated time) is set on
3604df
the file, but sending a setxattr fop. When upcall
3604df
receives the setxattr fop, the loc->inode is NULL and
3604df
it crashes. The loc->inode can be NULL only in one valid
3604df
case, i.e. in rename case where the inode of new loc
3604df
can be NULL. Hence, marker should have filled the inode
3604df
of the new_loc before issuing a setxattr.
3604df
3604df
marker_rename_cbk was already fixed in a previous commit.
3604df
Fixing marker_rename_done to send valid inode in this commit.
3604df
3604df
Also in upcall check for NULL inode so that there is no crash.
3604df
3604df
>Reviewed-on: https://review.gluster.org/16633
3604df
>Reviewed-by: Kotresh HR <khiremat@redhat.com>
3604df
>Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
>Reviewed-by: soumya k <skoduri@redhat.com>
3604df
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
>Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
3604df
3604df
Change-Id: I3ed2a05118fed3367dfe3251ce4477310cb480d0
3604df
BUG: 1422431
3604df
Signed-off-by: Poornima G <pgurusid@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/98136
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
Tested-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 tests/bugs/upcall/bug-1422776.t      | 30 ++++++++++++++++++++++++++++++
3604df
 xlators/features/marker/src/marker.c |  2 ++
3604df
 xlators/features/upcall/src/upcall.c |  4 ++++
3604df
 3 files changed, 36 insertions(+)
3604df
 create mode 100755 tests/bugs/upcall/bug-1422776.t
3604df
3604df
diff --git a/tests/bugs/upcall/bug-1422776.t b/tests/bugs/upcall/bug-1422776.t
3604df
new file mode 100755
3604df
index 0000000..cb249ce
3604df
--- /dev/null
3604df
+++ b/tests/bugs/upcall/bug-1422776.t
3604df
@@ -0,0 +1,30 @@
3604df
+#!/bin/bash
3604df
+
3604df
+. $(dirname $0)/../../include.rc
3604df
+. $(dirname $0)/../../volume.rc
3604df
+
3604df
+cleanup;
3604df
+
3604df
+##  Start glusterd
3604df
+TEST glusterd;
3604df
+
3604df
+##  Lets create volume
3604df
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2,3};
3604df
+
3604df
+##  Enable the upcall xlator, and increase the md-cache timeout to max
3604df
+TEST $CLI volume set $V0 features.cache-invalidation on
3604df
+TEST $CLI volume set $V0 features.cache-invalidation-timeout 600
3604df
+TEST $CLI volume set $V0 indexing on
3604df
+
3604df
+##  Start the volume
3604df
+TEST $CLI volume start $V0
3604df
+TEST $CLI volume quota $V0 enable
3604df
+
3604df
+##  Create two gluster mounts
3604df
+TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0
3604df
+
3604df
+##  Create directory and files from the M0
3604df
+TEST touch $M0/file1
3604df
+TEST mv $M0/file1 $M0/file2
3604df
+
3604df
+cleanup;
3604df
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c
3604df
index f578f6c..b51b9cc 100644
3604df
--- a/xlators/features/marker/src/marker.c
3604df
+++ b/xlators/features/marker/src/marker.c
3604df
@@ -1292,6 +1292,8 @@ marker_rename_done (call_frame_t *frame, void *cookie, xlator_t *this,
3604df
         loc_wipe (&newloc);
3604df
 
3604df
         if (priv->feature_enabled & GF_XTIME) {
3604df
+                if (!local->loc.inode)
3604df
+                        local->loc.inode = inode_ref (oplocal->loc.inode);
3604df
                 //update marks on oldpath
3604df
                 gf_uuid_copy (local->loc.gfid, oplocal->loc.inode->gfid);
3604df
                 marker_xtime_update_marks (this, oplocal);
3604df
diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c
3604df
index 19d9a9d..abbe3ee 100644
3604df
--- a/xlators/features/upcall/src/upcall.c
3604df
+++ b/xlators/features/upcall/src/upcall.c
3604df
@@ -2250,6 +2250,10 @@ upcall_local_init (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
3604df
 {
3604df
         upcall_local_t *local = NULL;
3604df
 
3604df
+        GF_VALIDATE_OR_GOTO ("upcall", this, out);
3604df
+        GF_VALIDATE_OR_GOTO (this->name, frame, out);
3604df
+        GF_VALIDATE_OR_GOTO (this->name, inode, out);
3604df
+
3604df
         local = mem_get0 (THIS->local_pool);
3604df
 
3604df
         if (!local)
3604df
-- 
3604df
2.9.3
3604df