diff options
| -rw-r--r-- | tests/bugs/geo-replication/bug-1296496.t | 43 | ||||
| -rw-r--r-- | xlators/features/marker/src/marker.c | 19 | ||||
| -rw-r--r-- | xlators/storage/posix/src/posix.c | 13 | 
3 files changed, 74 insertions, 1 deletions
diff --git a/tests/bugs/geo-replication/bug-1296496.t b/tests/bugs/geo-replication/bug-1296496.t new file mode 100644 index 00000000000..703fda65b84 --- /dev/null +++ b/tests/bugs/geo-replication/bug-1296496.t @@ -0,0 +1,43 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +## Start and create a replicated volume +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}-{0,1} + +TEST $CLI volume set $V0 indexing on + +TEST $CLI volume start $V0; + +## Mount native +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 + +## Mount client-pid=-1 +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 --client-pid=-1 $M1 + +TEST touch $M0 + +vol_uuid=$(gluster vol info $V0 | grep "Volume ID" | awk '{print $3}') + +xtime="trusted.glusterfs.$vol_uuid.xtime" + +#TEST xtime +TEST ! getfattr -n $xtime $M0 +TEST getfattr -n $xtime $M1 + +#TEST stime +slave_uuid=$(uuidgen) +stime="trusted.glusterfs.$vol_uuid.$slave_uuid.stime" +TEST setfattr -n $stime -v "0xFFFE" $B0/${V0}-0 +TEST setfattr -n $stime -v "0xFFFF" $B0/${V0}-1 + +TEST ! getfattr -n $stime $M0 +TEST getfattr -n $stime $M1 + +cleanup; diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index a2e91580175..10c7e04f21f 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -412,6 +412,21 @@ marker_filter_internal_xattrs (xlator_t *this, dict_t *xattrs)          dict_foreach_match (xattrs, _is_quota_internal_xattr, ext,                              dict_remove_foreach_fn, NULL); +} + +static void +marker_filter_gsyncd_xattrs (call_frame_t *frame, +                               xlator_t *this, dict_t *xattrs) +{ +        marker_conf_t *priv   = NULL; + +        priv = this->private; +        GF_ASSERT (priv); + +        if (frame->root->pid != GF_CLIENT_PID_GSYNCD && +            dict_get(xattrs, priv->marker_xattr)) { +                dict_del (xattrs, priv->marker_xattr); +        }          return;  } @@ -421,7 +436,6 @@ marker_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                       dict_t *xdata)  {          int32_t     ret  = -1; -          if (op_ret < 0)                  goto unwind; @@ -457,6 +471,9 @@ marker_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                  marker_filter_internal_xattrs (frame->this, dict);          } +        /* Filter gsyncd xtime xattr for non gsyncd clients */ +        marker_filter_gsyncd_xattrs (frame, frame->this, dict); +  unwind:          MARKER_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata);          return 0; diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 314585ac41b..6e6d9893936 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -4097,6 +4097,14 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,          op_ret = -1;          priv = this->private; +        /* Allow access to stime xattr only to geo-rep worker */ +        if (frame->root->pid != GF_CLIENT_PID_GSYNCD && name && +            fnmatch ("*.glusterfs.*.stime", name, FNM_PERIOD) == 0) { +                op_ret = -1; +                op_errno = ENOATTR; +                goto out; +        } +          if (loc->inode && IA_ISDIR(loc->inode->ia_type) && name &&              ZR_FILE_CONTENT_REQUEST(name)) {                  ret = posix_get_file_contents (this, loc->gfid, &name[15], @@ -4406,6 +4414,10 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,          list_offset = 0;          while (remaining_size > 0) {                  strcpy (keybuffer, list + list_offset); +                if (frame->root->pid != GF_CLIENT_PID_GSYNCD && +                    fnmatch ("*.glusterfs.*.stime", keybuffer, FNM_PERIOD) == 0) +                        goto ignore; +                  size = sys_lgetxattr (real_path, keybuffer, NULL, 0);                  if (size == -1) {                          op_ret = -1; @@ -4453,6 +4465,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,                          goto out;                  } +ignore:                  remaining_size -= strlen (keybuffer) + 1;                  list_offset += strlen (keybuffer) + 1;  | 
