|
|
21ab4e |
From e8a94eab232c3b8297a9216b8c8d2a6bdb7656fb Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Saravanakumar Arumugam <sarumuga@redhat.com>
|
|
|
21ab4e |
Date: Fri, 8 Jul 2016 19:10:45 +0530
|
|
|
21ab4e |
Subject: [PATCH 397/406] geo-rep: filter out xtime attribute during getxattr
|
|
|
21ab4e |
|
|
|
21ab4e |
georep gsyncd's xtime needs to filtered irrespective
|
|
|
21ab4e |
of any process access.
|
|
|
21ab4e |
|
|
|
21ab4e |
This way, we can avoid (unnecessarily)syncing xtime attribute
|
|
|
21ab4e |
to slave, which may raise permission denied errors.
|
|
|
21ab4e |
|
|
|
21ab4e |
test case modified to check for xtime xattr only in backend.
|
|
|
21ab4e |
Back port of>
|
|
|
21ab4e |
>Change-Id: I2390b703048d5cc747d91fa2ae884dc55de58669
|
|
|
21ab4e |
>BUG: 1353952
|
|
|
21ab4e |
>Signed-off-by: Saravanakumar Arumugam <sarumuga@redhat.com>
|
|
|
21ab4e |
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
21ab4e |
>Reviewed-on: https://review.gluster.org/14880
|
|
|
21ab4e |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>Reviewed-by: Kotresh HR <khiremat@redhat.com>
|
|
|
21ab4e |
>Tested-by: Kotresh HR <khiremat@redhat.com>
|
|
|
21ab4e |
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: Ibdee6f3093648a7e0fb1e2b6be8172e604ab657f
|
|
|
21ab4e |
BUG: 1327045
|
|
|
21ab4e |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/103428
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
tests/basic/geo-replication/marker-xattrs.t | 17 ++++-----
|
|
|
21ab4e |
tests/bugs/geo-replication/bug-1296496.t | 3 +-
|
|
|
21ab4e |
tests/bugs/geo-replication/bug-877293.t | 4 +--
|
|
|
21ab4e |
xlators/storage/posix/src/posix-helpers.c | 53 ++++++++++++++++++++++++++++-
|
|
|
21ab4e |
xlators/storage/posix/src/posix.c | 15 ++++----
|
|
|
21ab4e |
xlators/storage/posix/src/posix.h | 3 +-
|
|
|
21ab4e |
6 files changed, 73 insertions(+), 22 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/tests/basic/geo-replication/marker-xattrs.t b/tests/basic/geo-replication/marker-xattrs.t
|
|
|
21ab4e |
index dd5483d..e5b26a6 100755
|
|
|
21ab4e |
--- a/tests/basic/geo-replication/marker-xattrs.t
|
|
|
21ab4e |
+++ b/tests/basic/geo-replication/marker-xattrs.t
|
|
|
21ab4e |
@@ -24,11 +24,11 @@ TEST touch $M0
|
|
|
21ab4e |
vol_uuid=$(get_volume_mark $M1)
|
|
|
21ab4e |
xtime=trusted.glusterfs.$vol_uuid.xtime
|
|
|
21ab4e |
|
|
|
21ab4e |
-TEST "getfattr -n $xtime $M1 | grep -q ${xtime}="
|
|
|
21ab4e |
+TEST "getfattr -n $xtime $B0/${V0}-1 | grep -q ${xtime}="
|
|
|
21ab4e |
|
|
|
21ab4e |
TEST kill_brick $V0 $H0 $B0/${V0}-0
|
|
|
21ab4e |
|
|
|
21ab4e |
-TEST "getfattr -n $xtime $M1 | grep -q ${xtime}="
|
|
|
21ab4e |
+TEST "getfattr -n $xtime $B0/${V0}-1 | grep -q ${xtime}="
|
|
|
21ab4e |
|
|
|
21ab4e |
TEST getfattr -d -m. -e hex $M1
|
|
|
21ab4e |
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
|
|
|
21ab4e |
@@ -61,13 +61,13 @@ vol_uuid=$(get_volume_mark $M1)
|
|
|
21ab4e |
xtime=trusted.glusterfs.$vol_uuid.xtime
|
|
|
21ab4e |
stime=trusted.glusterfs.$vol_uuid.stime
|
|
|
21ab4e |
|
|
|
21ab4e |
-stime_val=$(getfattr -e hex -n $xtime $M1 | grep ${xtime}= | cut -f2 -d'=')
|
|
|
21ab4e |
+stime_val=$(getfattr -e hex -n $xtime $B0/${V0}-1 | grep ${xtime}= | cut -f2 -d'=')
|
|
|
21ab4e |
TEST "setfattr -n $stime -v $stime_val $B0/${V0}-1"
|
|
|
21ab4e |
-TEST "getfattr -n $xtime $M1 | grep -q ${xtime}="
|
|
|
21ab4e |
+TEST "getfattr -n $xtime $B0/${V0}-1 | grep -q ${xtime}="
|
|
|
21ab4e |
|
|
|
21ab4e |
TEST kill_brick $V0 $H0 $B0/${V0}-0
|
|
|
21ab4e |
|
|
|
21ab4e |
-TEST "getfattr -n $xtime $M1 | grep -q ${xtime}="
|
|
|
21ab4e |
+TEST "getfattr -n $xtime $B0/${V0}-1 | grep -q ${xtime}="
|
|
|
21ab4e |
TEST "getfattr -n $stime $M1 | grep -q ${stime}="
|
|
|
21ab4e |
|
|
|
21ab4e |
TEST getfattr -d -m. -e hex $M1
|
|
|
21ab4e |
@@ -98,12 +98,9 @@ TEST touch $M0
|
|
|
21ab4e |
vol_uuid=$(get_volume_mark $M1)
|
|
|
21ab4e |
xtime=trusted.glusterfs.$vol_uuid.xtime
|
|
|
21ab4e |
|
|
|
21ab4e |
-TEST "getfattr -n $xtime $M1 | grep -q ${xtime}="
|
|
|
21ab4e |
+TEST "getfattr -n $xtime $B0/${V0}-0 | grep -q ${xtime}="
|
|
|
21ab4e |
|
|
|
21ab4e |
-TEST kill_brick $V0 $H0 $B0/${V0}-0
|
|
|
21ab4e |
-
|
|
|
21ab4e |
-#Stripe doesn't tolerate ENOTCONN
|
|
|
21ab4e |
-TEST ! "getfattr -n $xtime $M1 | grep -q ${xtime}="
|
|
|
21ab4e |
+TEST "getfattr -n $xtime $B0/${V0}-1 | grep -q ${xtime}="
|
|
|
21ab4e |
|
|
|
21ab4e |
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
|
|
|
21ab4e |
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M1
|
|
|
21ab4e |
diff --git a/tests/bugs/geo-replication/bug-1296496.t b/tests/bugs/geo-replication/bug-1296496.t
|
|
|
21ab4e |
index 703fda6..a157be7 100644
|
|
|
21ab4e |
--- a/tests/bugs/geo-replication/bug-1296496.t
|
|
|
21ab4e |
+++ b/tests/bugs/geo-replication/bug-1296496.t
|
|
|
21ab4e |
@@ -29,7 +29,8 @@ xtime="trusted.glusterfs.$vol_uuid.xtime"
|
|
|
21ab4e |
|
|
|
21ab4e |
#TEST xtime
|
|
|
21ab4e |
TEST ! getfattr -n $xtime $M0
|
|
|
21ab4e |
-TEST getfattr -n $xtime $M1
|
|
|
21ab4e |
+TEST getfattr -n $xtime $B0/${V0}-0
|
|
|
21ab4e |
+TEST getfattr -n $xtime $B0/${V0}-1
|
|
|
21ab4e |
|
|
|
21ab4e |
#TEST stime
|
|
|
21ab4e |
slave_uuid=$(uuidgen)
|
|
|
21ab4e |
diff --git a/tests/bugs/geo-replication/bug-877293.t b/tests/bugs/geo-replication/bug-877293.t
|
|
|
21ab4e |
index 542774a..c5205e8 100755
|
|
|
21ab4e |
--- a/tests/bugs/geo-replication/bug-877293.t
|
|
|
21ab4e |
+++ b/tests/bugs/geo-replication/bug-877293.t
|
|
|
21ab4e |
@@ -26,11 +26,11 @@ TEST touch $M0
|
|
|
21ab4e |
vol_uuid=`getfattr -n trusted.glusterfs.volume-mark -ehex $M1 | sed -n 's/^trusted.glusterfs.volume-mark=0x//p' | cut -b5-36 | sed 's/\([a-f0-9]\{8\}\)\([a-f0-9]\{4\}\)\([a-f0-9]\{4\}\)\([a-f0-9]\{4\}\)/\1-\2-\3-\4-/'`
|
|
|
21ab4e |
xtime=trusted.glusterfs.$vol_uuid.xtime
|
|
|
21ab4e |
|
|
|
21ab4e |
-TEST "getfattr -n $xtime $M1 | grep -q ${xtime}="
|
|
|
21ab4e |
+TEST "getfattr -n $xtime $B0/${V0}-0 | grep -q ${xtime}="
|
|
|
21ab4e |
|
|
|
21ab4e |
TEST kill_brick $V0 $H0 $B0/${V0}-0
|
|
|
21ab4e |
|
|
|
21ab4e |
-TEST "getfattr -n $xtime $M1 | grep -q ${xtime}="
|
|
|
21ab4e |
+TEST "getfattr -n $xtime $B0/${V0}-1 | grep -q ${xtime}="
|
|
|
21ab4e |
|
|
|
21ab4e |
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
|
|
|
21ab4e |
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M1
|
|
|
21ab4e |
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
|
|
|
21ab4e |
index 24b8bdd..dd6791c 100644
|
|
|
21ab4e |
--- a/xlators/storage/posix/src/posix-helpers.c
|
|
|
21ab4e |
+++ b/xlators/storage/posix/src/posix-helpers.c
|
|
|
21ab4e |
@@ -96,6 +96,57 @@ out:
|
|
|
21ab4e |
return flag;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+int
|
|
|
21ab4e |
+posix_handle_georep_xattrs (call_frame_t *frame, const char *name,
|
|
|
21ab4e |
+ int *op_errno, gf_boolean_t is_getxattr)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ int i = 0;
|
|
|
21ab4e |
+ int ret = 0;
|
|
|
21ab4e |
+ int pid = 1;
|
|
|
21ab4e |
+ gf_boolean_t filter_xattr = _gf_true;
|
|
|
21ab4e |
+ static const char *georep_xattr[] = { "*.glusterfs.*.stime",
|
|
|
21ab4e |
+ "*.glusterfs.*.xtime",
|
|
|
21ab4e |
+ "*.glusterfs.*.entry_stime",
|
|
|
21ab4e |
+ NULL
|
|
|
21ab4e |
+ };
|
|
|
21ab4e |
+ if (frame && frame->root) {
|
|
|
21ab4e |
+ pid = frame->root->pid;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (!name) {
|
|
|
21ab4e |
+ /* No need to do anything here */
|
|
|
21ab4e |
+ ret = 0;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (pid == GF_CLIENT_PID_GSYNCD && is_getxattr) {
|
|
|
21ab4e |
+ filter_xattr = _gf_false;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /* getxattr from gsyncd process should return all the
|
|
|
21ab4e |
+ * internal xattr. In other cases ignore such xattrs
|
|
|
21ab4e |
+ */
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ for (i = 0; filter_xattr && georep_xattr[i]; i++) {
|
|
|
21ab4e |
+ if (fnmatch (georep_xattr[i] , name, FNM_PERIOD) == 0) {
|
|
|
21ab4e |
+ ret = -1;
|
|
|
21ab4e |
+ if (op_errno)
|
|
|
21ab4e |
+ *op_errno = ENOATTR;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ gf_msg_debug ("posix", ENOATTR,
|
|
|
21ab4e |
+ "Ignoring the key %s as an internal "
|
|
|
21ab4e |
+ "xattrs.", name);
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ret = 0;
|
|
|
21ab4e |
+out:
|
|
|
21ab4e |
+ return ret;
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+
|
|
|
21ab4e |
static gf_boolean_t
|
|
|
21ab4e |
_is_in_array (char **str_array, char *str)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
@@ -729,7 +780,7 @@ _handle_list_xattr (dict_t *xattr_req, const char *real_path, int fdnum,
|
|
|
21ab4e |
if (posix_special_xattr (marker_xattrs, key))
|
|
|
21ab4e |
goto next;
|
|
|
21ab4e |
|
|
|
21ab4e |
- if (!fnmatch (GF_XATTR_STIME_PATTERN, key, 0))
|
|
|
21ab4e |
+ if (posix_handle_georep_xattrs (NULL, key, NULL, _gf_false))
|
|
|
21ab4e |
goto next;
|
|
|
21ab4e |
|
|
|
21ab4e |
if (dict_get (filler->xattr, key))
|
|
|
21ab4e |
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
|
|
|
21ab4e |
index 207c7fd..ed70782 100644
|
|
|
21ab4e |
--- a/xlators/storage/posix/src/posix.c
|
|
|
21ab4e |
+++ b/xlators/storage/posix/src/posix.c
|
|
|
21ab4e |
@@ -4313,11 +4313,10 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
op_ret = -1;
|
|
|
21ab4e |
priv = this->private;
|
|
|
21ab4e |
|
|
|
21ab4e |
- /* Allow access to stime xattr only to geo-rep worker */
|
|
|
21ab4e |
- if (frame->root->pid != GF_CLIENT_PID_GSYNCD && name &&
|
|
|
21ab4e |
- fnmatch ("*.glusterfs.*.stime", name, FNM_PERIOD) == 0) {
|
|
|
21ab4e |
+ ret = posix_handle_georep_xattrs (frame, name, &op_errno, _gf_true);
|
|
|
21ab4e |
+ if (ret == -1) {
|
|
|
21ab4e |
op_ret = -1;
|
|
|
21ab4e |
- op_errno = ENOATTR;
|
|
|
21ab4e |
+ /* errno should be set from the above function*/
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -4629,9 +4628,11 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
remaining_size = size;
|
|
|
21ab4e |
list_offset = 0;
|
|
|
21ab4e |
while (remaining_size > 0) {
|
|
|
21ab4e |
- strcpy (keybuffer, list + list_offset);
|
|
|
21ab4e |
- if (frame->root->pid != GF_CLIENT_PID_GSYNCD &&
|
|
|
21ab4e |
- fnmatch ("*.glusterfs.*.stime", keybuffer, FNM_PERIOD) == 0)
|
|
|
21ab4e |
+ strncpy (keybuffer, list + list_offset, sizeof(keybuffer));
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ret = posix_handle_georep_xattrs (frame, keybuffer, NULL,
|
|
|
21ab4e |
+ _gf_false);
|
|
|
21ab4e |
+ if (ret == -1)
|
|
|
21ab4e |
goto ignore;
|
|
|
21ab4e |
|
|
|
21ab4e |
size = sys_lgetxattr (real_path, keybuffer, NULL, 0);
|
|
|
21ab4e |
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
|
|
|
21ab4e |
index 87f91e5..6fd32c1 100644
|
|
|
21ab4e |
--- a/xlators/storage/posix/src/posix.h
|
|
|
21ab4e |
+++ b/xlators/storage/posix/src/posix.h
|
|
|
21ab4e |
@@ -259,7 +259,8 @@ int
|
|
|
21ab4e |
posix_get_ancestry (xlator_t *this, inode_t *leaf_inode,
|
|
|
21ab4e |
gf_dirent_t *head, char **path, int type, int32_t *op_errno,
|
|
|
21ab4e |
dict_t *xdata);
|
|
|
21ab4e |
-
|
|
|
21ab4e |
+int
|
|
|
21ab4e |
+posix_handle_georep_xattrs (call_frame_t *, const char *, int *, gf_boolean_t);
|
|
|
21ab4e |
void
|
|
|
21ab4e |
posix_gfid_unset (xlator_t *this, dict_t *xdata);
|
|
|
21ab4e |
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|