Blob Blame History Raw
From 4bed27703450593b546671f2e3c9649095d9e04d Mon Sep 17 00:00:00 2001
From: Poornima G <pgurusid@redhat.com>
Date: Thu, 16 Feb 2017 13:05:25 +0530
Subject: [PATCH 294/294] marker: Fix inode value in loc, in setxattr fop

On recieving a rename fop, marker_rename() stores the,
oldloc and newloc in its 'local' struct, once the rename
is done, the xtime marker(last updated time) is set on
the file, but sending a setxattr fop. When upcall
receives the setxattr fop, the loc->inode is NULL and
it crashes. The loc->inode can be NULL only in one valid
case, i.e. in rename case where the inode of new loc
can be NULL. Hence, marker should have filled the inode
of the new_loc before issuing a setxattr.

marker_rename_cbk was already fixed in a previous commit.
Fixing marker_rename_done to send valid inode in this commit.

Also in upcall check for NULL inode so that there is no crash.

>Reviewed-on: https://review.gluster.org/16633
>Reviewed-by: Kotresh HR <khiremat@redhat.com>
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: soumya k <skoduri@redhat.com>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>Reviewed-by: Raghavendra G <rgowdapp@redhat.com>

Change-Id: I3ed2a05118fed3367dfe3251ce4477310cb480d0
BUG: 1422431
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/98136
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
 tests/bugs/upcall/bug-1422776.t      | 30 ++++++++++++++++++++++++++++++
 xlators/features/marker/src/marker.c |  2 ++
 xlators/features/upcall/src/upcall.c |  4 ++++
 3 files changed, 36 insertions(+)
 create mode 100755 tests/bugs/upcall/bug-1422776.t

diff --git a/tests/bugs/upcall/bug-1422776.t b/tests/bugs/upcall/bug-1422776.t
new file mode 100755
index 0000000..cb249ce
--- /dev/null
+++ b/tests/bugs/upcall/bug-1422776.t
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+
+cleanup;
+
+##  Start glusterd
+TEST glusterd;
+
+##  Lets create volume
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2,3};
+
+##  Enable the upcall xlator, and increase the md-cache timeout to max
+TEST $CLI volume set $V0 features.cache-invalidation on
+TEST $CLI volume set $V0 features.cache-invalidation-timeout 600
+TEST $CLI volume set $V0 indexing on
+
+##  Start the volume
+TEST $CLI volume start $V0
+TEST $CLI volume quota $V0 enable
+
+##  Create two gluster mounts
+TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0
+
+##  Create directory and files from the M0
+TEST touch $M0/file1
+TEST mv $M0/file1 $M0/file2
+
+cleanup;
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c
index f578f6c..b51b9cc 100644
--- a/xlators/features/marker/src/marker.c
+++ b/xlators/features/marker/src/marker.c
@@ -1292,6 +1292,8 @@ marker_rename_done (call_frame_t *frame, void *cookie, xlator_t *this,
         loc_wipe (&newloc);
 
         if (priv->feature_enabled & GF_XTIME) {
+                if (!local->loc.inode)
+                        local->loc.inode = inode_ref (oplocal->loc.inode);
                 //update marks on oldpath
                 gf_uuid_copy (local->loc.gfid, oplocal->loc.inode->gfid);
                 marker_xtime_update_marks (this, oplocal);
diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c
index 19d9a9d..abbe3ee 100644
--- a/xlators/features/upcall/src/upcall.c
+++ b/xlators/features/upcall/src/upcall.c
@@ -2250,6 +2250,10 @@ upcall_local_init (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
 {
         upcall_local_t *local = NULL;
 
+        GF_VALIDATE_OR_GOTO ("upcall", this, out);
+        GF_VALIDATE_OR_GOTO (this->name, frame, out);
+        GF_VALIDATE_OR_GOTO (this->name, inode, out);
+
         local = mem_get0 (THIS->local_pool);
 
         if (!local)
-- 
2.9.3