|
|
cb8e9e |
From 94253b21f832ff12d1c545c5d87e6bc79465d090 Mon Sep 17 00:00:00 2001
|
|
|
cb8e9e |
From: Nithya Balachandran <nbalacha@redhat.com>
|
|
|
cb8e9e |
Date: Mon, 31 Aug 2015 15:52:04 +0530
|
|
|
cb8e9e |
Subject: [PATCH 319/320] cluster/dht: Don't set posix acls on linkto files
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Posix acls on a linkto file change the file's permission
|
|
|
cb8e9e |
bits and cause DHT to treat it as a non-linkto file.This
|
|
|
cb8e9e |
happens on the migration failure of a file on which posix
|
|
|
cb8e9e |
acls were set.
|
|
|
cb8e9e |
The fix prevents posix acls from being set on a linkto
|
|
|
cb8e9e |
file and copies them across only after a file has
|
|
|
cb8e9e |
been successfully migrated.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
backport of:
|
|
|
cb8e9e |
http://review.gluster.org/#/c/12025/
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Some tier.t upstream changes have not been merged downstream
|
|
|
cb8e9e |
so this backport does not include the changes the upstream
|
|
|
cb8e9e |
patch made to tier.t.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Change-Id: I7380cae9e847785534535c5d306574a231e21a10
|
|
|
cb8e9e |
BUG: 1234610
|
|
|
cb8e9e |
Signed-off-by: Nithya Balachandran <nbalacha@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/56696
|
|
|
cb8e9e |
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
|
|
|
cb8e9e |
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
|
|
|
cb8e9e |
---
|
|
|
cb8e9e |
tests/bugs/distribute/bug-1247563.t | 57 +++++++++++++++++++++++++++++
|
|
|
cb8e9e |
xlators/cluster/dht/src/dht-rebalance.c | 34 +++++++++++++++++
|
|
|
cb8e9e |
xlators/storage/posix/src/posix-helpers.c | 15 ++++++--
|
|
|
cb8e9e |
xlators/storage/posix/src/posix.c | 11 +++++-
|
|
|
cb8e9e |
xlators/storage/posix/src/posix.h | 4 +-
|
|
|
cb8e9e |
5 files changed, 114 insertions(+), 7 deletions(-)
|
|
|
cb8e9e |
create mode 100644 tests/bugs/distribute/bug-1247563.t
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/tests/bugs/distribute/bug-1247563.t b/tests/bugs/distribute/bug-1247563.t
|
|
|
cb8e9e |
new file mode 100644
|
|
|
cb8e9e |
index 0000000..f7f9258
|
|
|
cb8e9e |
--- /dev/null
|
|
|
cb8e9e |
+++ b/tests/bugs/distribute/bug-1247563.t
|
|
|
cb8e9e |
@@ -0,0 +1,57 @@
|
|
|
cb8e9e |
+#!/bin/bash
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+. $(dirname $0)/../../include.rc
|
|
|
cb8e9e |
+. $(dirname $0)/../../volume.rc
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+is_sticky_set () {
|
|
|
cb8e9e |
+ echo $1
|
|
|
cb8e9e |
+ if [ -k $1 ];
|
|
|
cb8e9e |
+ then
|
|
|
cb8e9e |
+ echo "yes"
|
|
|
cb8e9e |
+ else
|
|
|
cb8e9e |
+ echo "no"
|
|
|
cb8e9e |
+ fi
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+cleanup;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+#Basic checks
|
|
|
cb8e9e |
+TEST glusterd
|
|
|
cb8e9e |
+TEST pidof glusterd
|
|
|
cb8e9e |
+TEST $CLI volume info
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+#Create a distributed volume
|
|
|
cb8e9e |
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3};
|
|
|
cb8e9e |
+TEST $CLI volume start $V0
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+# Mount FUSE
|
|
|
cb8e9e |
+TEST glusterfs --acl -s $H0 --volfile-id $V0 $M0
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+TEST mkdir $M0/dir1
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+echo "Testing pacls on rebalance" > $M0/dir1/FILE1
|
|
|
cb8e9e |
+FPATH1=`find $B0/ -name FILE1`
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+# Rename the file to create a linkto, for rebalance to
|
|
|
cb8e9e |
+# act on the file
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+TEST mv $M0/dir1/FILE1 $M0/dir1/FILE2
|
|
|
cb8e9e |
+FPATH2=`find $B0/ -perm 1000 -name FILE2`
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+setfacl -m user:root:rwx $M0/dir1/FILE2
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+# Run rebalance without the force option to skip
|
|
|
cb8e9e |
+# the file migration
|
|
|
cb8e9e |
+TEST $CLI volume rebalance $V0 start
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+#Check that the file has been skipped,i.e., the linkto still exists
|
|
|
cb8e9e |
+EXPECT "yes" is_sticky_set $FPATH2
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+#The linkto file should not have any posix acls set
|
|
|
cb8e9e |
+COUNT=`getfacl $FPATH2 |grep -c "user:root:rwx"`
|
|
|
cb8e9e |
+EXPECT "0" echo $COUNT
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+cleanup;
|
|
|
cb8e9e |
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
cb8e9e |
index 012d86b..442b46a 100644
|
|
|
cb8e9e |
--- a/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
cb8e9e |
+++ b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
cb8e9e |
@@ -1196,6 +1196,40 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
|
|
|
cb8e9e |
ret = -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+ /* Posix acls are not set on DHT linkto files as part of the initial
|
|
|
cb8e9e |
+ * initial xattrs set on the dst file, so these need
|
|
|
cb8e9e |
+ * to be set on the dst file after the linkto attrs are removed.
|
|
|
cb8e9e |
+ * TODO: Optimize this.
|
|
|
cb8e9e |
+ */
|
|
|
cb8e9e |
+ if (xattr) {
|
|
|
cb8e9e |
+ dict_unref (xattr);
|
|
|
cb8e9e |
+ xattr = NULL;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = syncop_listxattr (from, loc, &xattr, NULL, NULL);
|
|
|
cb8e9e |
+ if (ret < 0) {
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ DHT_MSG_MIGRATE_FILE_FAILED,
|
|
|
cb8e9e |
+ "Migrate file failed:"
|
|
|
cb8e9e |
+ "%s: failed to get xattr from %s (%s)",
|
|
|
cb8e9e |
+ loc->path, from->name, strerror (-ret));
|
|
|
cb8e9e |
+ ret = -1;
|
|
|
cb8e9e |
+ } else {
|
|
|
cb8e9e |
+ ret = syncop_setxattr (to, loc, xattr, 0, NULL, NULL);
|
|
|
cb8e9e |
+ if (ret < 0) {
|
|
|
cb8e9e |
+ /* Potential problem here where Posix ACLs will
|
|
|
cb8e9e |
+ * not be set on the target file */
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ DHT_MSG_MIGRATE_FILE_FAILED,
|
|
|
cb8e9e |
+ "Migrate file failed:"
|
|
|
cb8e9e |
+ "%s: failed to set xattr on %s (%s)",
|
|
|
cb8e9e |
+ loc->path, to->name, strerror (-ret));
|
|
|
cb8e9e |
+ ret = -1;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
/* Make the source as a linkfile first before deleting it */
|
|
|
cb8e9e |
empty_iatt.ia_prot.sticky = 1;
|
|
|
cb8e9e |
ret = syncop_fsetattr (from, src_fd, &empty_iatt,
|
|
|
cb8e9e |
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
|
|
|
cb8e9e |
index cae56e7..082e74e 100644
|
|
|
cb8e9e |
--- a/xlators/storage/posix/src/posix-helpers.c
|
|
|
cb8e9e |
+++ b/xlators/storage/posix/src/posix-helpers.c
|
|
|
cb8e9e |
@@ -1072,7 +1072,7 @@ void posix_dump_buffer (xlator_t *this, const char *real_path, const char *key,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int
|
|
|
cb8e9e |
posix_handle_pair (xlator_t *this, const char *real_path,
|
|
|
cb8e9e |
- char *key, data_t *value, int flags)
|
|
|
cb8e9e |
+ char *key, data_t *value, int flags, struct iatt *stbuf)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
int sys_ret = -1;
|
|
|
cb8e9e |
int ret = 0;
|
|
|
cb8e9e |
@@ -1084,7 +1084,12 @@ posix_handle_pair (xlator_t *this, const char *real_path,
|
|
|
cb8e9e |
ret = posix_set_file_contents (this, real_path, key, value,
|
|
|
cb8e9e |
flags);
|
|
|
cb8e9e |
} else if (GF_POSIX_ACL_REQUEST (key)) {
|
|
|
cb8e9e |
+ if (stbuf && IS_DHT_LINKFILE_MODE (stbuf))
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
ret = posix_pacl_set (real_path, key, value->data);
|
|
|
cb8e9e |
+ } else if (!strncmp(key, POSIX_ACL_ACCESS_XATTR, strlen(key))
|
|
|
cb8e9e |
+ && stbuf && IS_DHT_LINKFILE_MODE (stbuf)) {
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
} else {
|
|
|
cb8e9e |
sys_ret = sys_lsetxattr (real_path, key, value->data,
|
|
|
cb8e9e |
value->len, flags);
|
|
|
cb8e9e |
@@ -1135,7 +1140,7 @@ out:
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int
|
|
|
cb8e9e |
posix_fhandle_pair (xlator_t *this, int fd,
|
|
|
cb8e9e |
- char *key, data_t *value, int flags)
|
|
|
cb8e9e |
+ char *key, data_t *value, int flags, struct iatt *stbuf)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
int sys_ret = -1;
|
|
|
cb8e9e |
int ret = 0;
|
|
|
cb8e9e |
@@ -1143,6 +1148,9 @@ posix_fhandle_pair (xlator_t *this, int fd,
|
|
|
cb8e9e |
if (XATTR_IS_PATHINFO (key)) {
|
|
|
cb8e9e |
ret = -EACCES;
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
+ } else if (!strncmp(key, POSIX_ACL_ACCESS_XATTR, strlen(key))
|
|
|
cb8e9e |
+ && stbuf && IS_DHT_LINKFILE_MODE (stbuf)) {
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
sys_ret = sys_fsetxattr (fd, key, value->data,
|
|
|
cb8e9e |
@@ -1525,7 +1533,7 @@ _handle_entry_create_keyvalue_pair (dict_t *d, char *k, data_t *v,
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = posix_handle_pair (filler->this, filler->real_path, k, v,
|
|
|
cb8e9e |
- XATTR_CREATE);
|
|
|
cb8e9e |
+ XATTR_CREATE, filler->stbuf);
|
|
|
cb8e9e |
if (ret < 0) {
|
|
|
cb8e9e |
errno = -ret;
|
|
|
cb8e9e |
return -1;
|
|
|
cb8e9e |
@@ -1546,6 +1554,7 @@ posix_entry_create_xattr_set (xlator_t *this, const char *path,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
filler.this = this;
|
|
|
cb8e9e |
filler.real_path = path;
|
|
|
cb8e9e |
+ filler.stbuf = NULL;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = dict_foreach (dict, _handle_entry_create_keyvalue_pair, &filler);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
|
|
|
cb8e9e |
index f1ebcc6..f7826fe 100644
|
|
|
cb8e9e |
--- a/xlators/storage/posix/src/posix.c
|
|
|
cb8e9e |
+++ b/xlators/storage/posix/src/posix.c
|
|
|
cb8e9e |
@@ -3198,7 +3198,7 @@ _handle_setxattr_keyvalue_pair (dict_t *d, char *k, data_t *v,
|
|
|
cb8e9e |
filler = tmp;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
return posix_handle_pair (filler->this, filler->real_path, k, v,
|
|
|
cb8e9e |
- filler->flags);
|
|
|
cb8e9e |
+ filler->flags, filler->stbuf);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
#ifdef GF_DARWIN_HOST_OS
|
|
|
cb8e9e |
@@ -3272,6 +3272,8 @@ posix_setxattr (call_frame_t *frame, xlator_t *this,
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+ posix_pstat(this, loc->gfid, real_path, &stbuf);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
op_ret = -1;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
dict_del (dict, GFID_XATTR_KEY);
|
|
|
cb8e9e |
@@ -3279,6 +3281,8 @@ posix_setxattr (call_frame_t *frame, xlator_t *this,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
filler.real_path = real_path;
|
|
|
cb8e9e |
filler.this = this;
|
|
|
cb8e9e |
+ filler.stbuf = &stbuf;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
#ifdef GF_DARWIN_HOST_OS
|
|
|
cb8e9e |
filler.flags = map_xattr_flags(flags);
|
|
|
cb8e9e |
#else
|
|
|
cb8e9e |
@@ -4443,7 +4447,7 @@ _handle_fsetxattr_keyvalue_pair (dict_t *d, char *k, data_t *v,
|
|
|
cb8e9e |
filler = tmp;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
return posix_fhandle_pair (filler->this, filler->fdnum, k, v,
|
|
|
cb8e9e |
- filler->flags);
|
|
|
cb8e9e |
+ filler->flags, filler->stbuf);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
@@ -4476,11 +4480,14 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
_fd = pfd->fd;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+ posix_fdstat (this, pfd->fd, &stbuf);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
dict_del (dict, GFID_XATTR_KEY);
|
|
|
cb8e9e |
dict_del (dict, GF_XATTR_VOL_ID_KEY);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
filler.fdnum = _fd;
|
|
|
cb8e9e |
filler.this = this;
|
|
|
cb8e9e |
+ filler.stbuf = &stbuf;
|
|
|
cb8e9e |
#ifdef GF_DARWIN_HOST_OS
|
|
|
cb8e9e |
filler.flags = map_xattr_flags(flags);
|
|
|
cb8e9e |
#else
|
|
|
cb8e9e |
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
|
|
|
cb8e9e |
index cf1465a..f8230be 100644
|
|
|
cb8e9e |
--- a/xlators/storage/posix/src/posix.h
|
|
|
cb8e9e |
+++ b/xlators/storage/posix/src/posix.h
|
|
|
cb8e9e |
@@ -207,9 +207,9 @@ int posix_pstat (xlator_t *this, uuid_t gfid, const char *real_path,
|
|
|
cb8e9e |
dict_t *posix_xattr_fill (xlator_t *this, const char *path, loc_t *loc,
|
|
|
cb8e9e |
fd_t *fd, int fdnum, dict_t *xattr, struct iatt *buf);
|
|
|
cb8e9e |
int posix_handle_pair (xlator_t *this, const char *real_path, char *key,
|
|
|
cb8e9e |
- data_t *value, int flags);
|
|
|
cb8e9e |
+ data_t *value, int flags, struct iatt *stbuf);
|
|
|
cb8e9e |
int posix_fhandle_pair (xlator_t *this, int fd, char *key, data_t *value,
|
|
|
cb8e9e |
- int flags);
|
|
|
cb8e9e |
+ int flags, struct iatt *stbuf);
|
|
|
cb8e9e |
void posix_spawn_janitor_thread (xlator_t *this);
|
|
|
cb8e9e |
int posix_get_file_contents (xlator_t *this, uuid_t pargfid,
|
|
|
cb8e9e |
const char *name, char **contents);
|
|
|
cb8e9e |
--
|
|
|
cb8e9e |
1.7.1
|
|
|
cb8e9e |
|