summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorSaravanakumar Arumugam <sarumuga@redhat.com>2016-07-08 19:10:45 +0530
committerRaghavendra Talur <rtalur@redhat.com>2017-05-03 09:04:51 +0000
commit4ae86b077d1ef4cd0cb3f73397bb474026b3362f (patch)
treea878e7ca7144352d72cdc36a4b625ef398d971d0 /xlators/storage
parente5a3aecd2d98339d77f89f51ce9c3a38ccc8a825 (diff)
geo-rep: filter out xtime attribute during getxattr
georep gsyncd's xtime needs to filtered irrespective of any process access. This way, we can avoid (unnecessarily)syncing xtime attribute to slave, which may raise permission denied errors. test case modified to check for xtime xattr only in backend. Back port of> >BUG: 1353952 >Signed-off-by: Saravanakumar Arumugam <sarumuga@redhat.com> >Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> >Reviewed-on: https://review.gluster.org/14880 >Smoke: Gluster Build System <jenkins@build.gluster.org> >Reviewed-by: Kotresh HR <khiremat@redhat.com> >Tested-by: Kotresh HR <khiremat@redhat.com> >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> >CentOS-regression: Gluster Build System <jenkins@build.gluster.org> >Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Change-Id: I2390b703048d5cc747d91fa2ae884dc55de58669 BUG: 1441576 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: https://review.gluster.org/17046 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c53
-rw-r--r--xlators/storage/posix/src/posix.c13
-rw-r--r--xlators/storage/posix/src/posix.h3
3 files changed, 61 insertions, 8 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index cc862c259ca..eef1546cc69 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -96,6 +96,57 @@ out:
return flag;
}
+int
+posix_handle_georep_xattrs (call_frame_t *frame, const char *name,
+ int *op_errno, gf_boolean_t is_getxattr)
+{
+
+ int i = 0;
+ int ret = 0;
+ int pid = 1;
+ gf_boolean_t filter_xattr = _gf_true;
+ static const char *georep_xattr[] = { "*.glusterfs.*.stime",
+ "*.glusterfs.*.xtime",
+ "*.glusterfs.*.entry_stime",
+ NULL
+ };
+ if (frame && frame->root) {
+ pid = frame->root->pid;
+ }
+
+ if (!name) {
+ /* No need to do anything here */
+ ret = 0;
+ goto out;
+ }
+
+ if (pid == GF_CLIENT_PID_GSYNCD && is_getxattr) {
+ filter_xattr = _gf_false;
+
+ /* getxattr from gsyncd process should return all the
+ * internal xattr. In other cases ignore such xattrs
+ */
+ }
+
+ for (i = 0; filter_xattr && georep_xattr[i]; i++) {
+ if (fnmatch (georep_xattr[i] , name, FNM_PERIOD) == 0) {
+ ret = -1;
+ if (op_errno)
+ *op_errno = ENOATTR;
+
+ gf_msg_debug ("posix", ENOATTR,
+ "Ignoring the key %s as an internal "
+ "xattrs.", name);
+ goto out;
+ }
+ }
+
+ ret = 0;
+out:
+ return ret;
+}
+
+
static gf_boolean_t
_is_in_array (char **str_array, char *str)
{
@@ -720,7 +771,7 @@ _handle_list_xattr (dict_t *xattr_req, const char *real_path, int fdnum,
if (posix_special_xattr (marker_xattrs, key))
goto next;
- if (!fnmatch (GF_XATTR_STIME_PATTERN, key, 0))
+ if (posix_handle_georep_xattrs (NULL, key, NULL, _gf_false))
goto next;
if (dict_get (filler->xattr, key))
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index e8aeced59f9..f53207fc5a8 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -4396,11 +4396,10 @@ 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) {
+ ret = posix_handle_georep_xattrs (frame, name, &op_errno, _gf_true);
+ if (ret == -1) {
op_ret = -1;
- op_errno = ENOATTR;
+ /* errno should be set from the above function*/
goto out;
}
@@ -4713,8 +4712,10 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
list_offset = 0;
while (remaining_size > 0) {
strncpy (keybuffer, list + list_offset, sizeof(keybuffer));
- if (frame->root->pid != GF_CLIENT_PID_GSYNCD &&
- fnmatch ("*.glusterfs.*.stime", keybuffer, FNM_PERIOD) == 0)
+
+ ret = posix_handle_georep_xattrs (frame, keybuffer, NULL,
+ _gf_false);
+ if (ret == -1)
goto ignore;
size = sys_lgetxattr (real_path, keybuffer, NULL, 0);
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index 4e43b1f2d32..febd4326aa1 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -275,7 +275,8 @@ int
posix_get_ancestry (xlator_t *this, inode_t *leaf_inode,
gf_dirent_t *head, char **path, int type, int32_t *op_errno,
dict_t *xdata);
-
+int
+posix_handle_georep_xattrs (call_frame_t *, const char *, int *, gf_boolean_t);
void
posix_gfid_unset (xlator_t *this, dict_t *xdata);