|
|
c5d8c8 |
From 2c6c4ad77ba5511a62846af932840deb5bc389ae Mon Sep 17 00:00:00 2001
|
|
|
c5d8c8 |
From: Tamar Shacked <tshacked@redhat.com>
|
|
|
c5d8c8 |
Date: Mon, 7 Jun 2021 12:25:57 +0300
|
|
|
c5d8c8 |
Subject: [PATCH 584/584] dht - fixing xattr inconsistency
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
The scenario of setting an xattr to a dir, killing one of the bricks,
|
|
|
c5d8c8 |
removing the xattr, bringing back the brick results in xattr
|
|
|
c5d8c8 |
inconsistency - The downed brick will still have the xattr, but the rest
|
|
|
c5d8c8 |
won't.
|
|
|
c5d8c8 |
This patch add a mechanism that will remove the extra xattrs during
|
|
|
c5d8c8 |
lookup.
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
Backport of:
|
|
|
c5d8c8 |
> Upstream-patch-link: https://review.gluster.org/#/c/glusterfs/+/24687/
|
|
|
c5d8c8 |
> fixes: #1324
|
|
|
c5d8c8 |
> Change-Id: Ifec0b7aea6cd40daa8b0319b881191cf83e031d1
|
|
|
c5d8c8 |
> Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
BUG: 1600379
|
|
|
c5d8c8 |
Change-Id: I588f69b283e5354cd362d74486d6ec6d226ecc96
|
|
|
c5d8c8 |
Signed-off-by: Tamar Shacked <tshacked@redhat.com>
|
|
|
c5d8c8 |
Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
|
|
|
c5d8c8 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/245560
|
|
|
c5d8c8 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
c5d8c8 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
c5d8c8 |
---
|
|
|
c5d8c8 |
libglusterfs/src/common-utils.c | 20 +++++++-
|
|
|
c5d8c8 |
libglusterfs/src/glusterfs/common-utils.h | 6 +++
|
|
|
c5d8c8 |
tests/bugs/distribute/bug-1600379.t | 54 ++++++++++++++++++++
|
|
|
c5d8c8 |
xlators/cluster/dht/src/dht-common.c | 14 ++----
|
|
|
c5d8c8 |
xlators/cluster/dht/src/dht-common.h | 4 --
|
|
|
c5d8c8 |
xlators/cluster/dht/src/dht-helper.c | 4 ++
|
|
|
c5d8c8 |
xlators/cluster/dht/src/dht-selfheal.c | 11 ++++
|
|
|
c5d8c8 |
xlators/storage/posix/src/posix-helpers.c | 19 +++++++
|
|
|
c5d8c8 |
xlators/storage/posix/src/posix-inode-fd-ops.c | 69 ++++++++++++++++++++++++++
|
|
|
c5d8c8 |
xlators/storage/posix/src/posix.h | 3 ++
|
|
|
c5d8c8 |
10 files changed, 189 insertions(+), 15 deletions(-)
|
|
|
c5d8c8 |
create mode 100644 tests/bugs/distribute/bug-1600379.t
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
|
|
|
c5d8c8 |
index c2dfe28..d8b7c6e 100644
|
|
|
c5d8c8 |
--- a/libglusterfs/src/common-utils.c
|
|
|
c5d8c8 |
+++ b/libglusterfs/src/common-utils.c
|
|
|
c5d8c8 |
@@ -54,6 +54,7 @@
|
|
|
c5d8c8 |
#include "xxhash.h"
|
|
|
c5d8c8 |
#include <ifaddrs.h>
|
|
|
c5d8c8 |
#include "glusterfs/libglusterfs-messages.h"
|
|
|
c5d8c8 |
+#include "glusterfs/glusterfs-acl.h"
|
|
|
c5d8c8 |
#include "protocol-common.h"
|
|
|
c5d8c8 |
#ifdef __FreeBSD__
|
|
|
c5d8c8 |
#include <pthread_np.h>
|
|
|
c5d8c8 |
@@ -82,12 +83,21 @@ gf_boolean_t gf_signal_on_assert = false;
|
|
|
c5d8c8 |
typedef int32_t (*rw_op_t)(int32_t fd, char *buf, int32_t size);
|
|
|
c5d8c8 |
typedef int32_t (*rwv_op_t)(int32_t fd, const struct iovec *buf, int32_t size);
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
-void gf_assert(void)
|
|
|
c5d8c8 |
+char *xattrs_to_heal[] = {"user.",
|
|
|
c5d8c8 |
+ POSIX_ACL_ACCESS_XATTR,
|
|
|
c5d8c8 |
+ POSIX_ACL_DEFAULT_XATTR,
|
|
|
c5d8c8 |
+ QUOTA_LIMIT_KEY,
|
|
|
c5d8c8 |
+ QUOTA_LIMIT_OBJECTS_KEY,
|
|
|
c5d8c8 |
+ GF_SELINUX_XATTR_KEY,
|
|
|
c5d8c8 |
+ GF_XATTR_MDATA_KEY,
|
|
|
c5d8c8 |
+ NULL};
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+void
|
|
|
c5d8c8 |
+gf_assert(void)
|
|
|
c5d8c8 |
{
|
|
|
c5d8c8 |
if (gf_signal_on_assert) {
|
|
|
c5d8c8 |
raise(SIGCONT);
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
-
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
void
|
|
|
c5d8c8 |
@@ -5430,3 +5440,9 @@ gf_d_type_from_ia_type(ia_type_t type)
|
|
|
c5d8c8 |
return DT_UNKNOWN;
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+char **
|
|
|
c5d8c8 |
+get_xattrs_to_heal()
|
|
|
c5d8c8 |
+{
|
|
|
c5d8c8 |
+ return xattrs_to_heal;
|
|
|
c5d8c8 |
+}
|
|
|
c5d8c8 |
diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h
|
|
|
c5d8c8 |
index bd48b6f..8439bb6 100644
|
|
|
c5d8c8 |
--- a/libglusterfs/src/glusterfs/common-utils.h
|
|
|
c5d8c8 |
+++ b/libglusterfs/src/glusterfs/common-utils.h
|
|
|
c5d8c8 |
@@ -183,6 +183,12 @@ enum _gf_xlator_ipc_targets {
|
|
|
c5d8c8 |
typedef enum _gf_special_pid gf_special_pid_t;
|
|
|
c5d8c8 |
typedef enum _gf_xlator_ipc_targets _gf_xlator_ipc_targets_t;
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
+/* Array to hold custom xattr keys */
|
|
|
c5d8c8 |
+extern char *xattrs_to_heal[];
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+char **
|
|
|
c5d8c8 |
+get_xattrs_to_heal();
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
/* The DHT file rename operation is not a straightforward rename.
|
|
|
c5d8c8 |
* It involves creating linkto and linkfiles, and can unlink or rename the
|
|
|
c5d8c8 |
* source file depending on the hashed and cached subvols for the source
|
|
|
c5d8c8 |
diff --git a/tests/bugs/distribute/bug-1600379.t b/tests/bugs/distribute/bug-1600379.t
|
|
|
c5d8c8 |
new file mode 100644
|
|
|
c5d8c8 |
index 0000000..8d2f615
|
|
|
c5d8c8 |
--- /dev/null
|
|
|
c5d8c8 |
+++ b/tests/bugs/distribute/bug-1600379.t
|
|
|
c5d8c8 |
@@ -0,0 +1,54 @@
|
|
|
c5d8c8 |
+#!/bin/bash
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+. $(dirname $0)/../../include.rc
|
|
|
c5d8c8 |
+. $(dirname $0)/../../volume.rc
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Initialize
|
|
|
c5d8c8 |
+#------------------------------------------------------------
|
|
|
c5d8c8 |
+cleanup;
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Start glusterd
|
|
|
c5d8c8 |
+TEST glusterd;
|
|
|
c5d8c8 |
+TEST pidof glusterd;
|
|
|
c5d8c8 |
+TEST $CLI volume info;
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Create a volume
|
|
|
c5d8c8 |
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Verify volume creation
|
|
|
c5d8c8 |
+EXPECT "$V0" volinfo_field $V0 'Volume Name';
|
|
|
c5d8c8 |
+EXPECT 'Created' volinfo_field $V0 'Status';
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Start volume and verify successful start
|
|
|
c5d8c8 |
+TEST $CLI volume start $V0;
|
|
|
c5d8c8 |
+EXPECT 'Started' volinfo_field $V0 'Status';
|
|
|
c5d8c8 |
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0;
|
|
|
c5d8c8 |
+#------------------------------------------------------------
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Test case - Remove xattr from killed brick on lookup
|
|
|
c5d8c8 |
+#------------------------------------------------------------
|
|
|
c5d8c8 |
+# Create a dir and set custom xattr
|
|
|
c5d8c8 |
+TEST mkdir $M0/testdir
|
|
|
c5d8c8 |
+TEST setfattr -n user.attr -v val $M0/testdir
|
|
|
c5d8c8 |
+xattr_val=`getfattr -d $B0/${V0}2/testdir | awk '{print $1}'`;
|
|
|
c5d8c8 |
+TEST ${xattr_val}='user.attr="val"';
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Kill 2nd brick process
|
|
|
c5d8c8 |
+TEST kill_brick $V0 $H0 $B0/${V0}2
|
|
|
c5d8c8 |
+EXPECT_WITHIN ${PROCESS_UP_TIMEOUT} "1" online_brick_count
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Remove custom xattr
|
|
|
c5d8c8 |
+TEST setfattr -x user.attr $M0/testdir
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Bring up the killed brick process
|
|
|
c5d8c8 |
+TEST $CLI volume start $V0 force
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Perform lookup
|
|
|
c5d8c8 |
+sleep 5
|
|
|
c5d8c8 |
+TEST ls $M0/testdir
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+# Check brick xattrs
|
|
|
c5d8c8 |
+xattr_val_2=`getfattr -d $B0/${V0}2/testdir`;
|
|
|
c5d8c8 |
+TEST [ ${xattr_val_2} = ''] ;
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+cleanup;
|
|
|
c5d8c8 |
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
|
|
|
c5d8c8 |
index ce0fbbf..edfc6e7 100644
|
|
|
c5d8c8 |
--- a/xlators/cluster/dht/src/dht-common.c
|
|
|
c5d8c8 |
+++ b/xlators/cluster/dht/src/dht-common.c
|
|
|
c5d8c8 |
@@ -19,6 +19,7 @@
|
|
|
c5d8c8 |
#include <glusterfs/byte-order.h>
|
|
|
c5d8c8 |
#include <glusterfs/quota-common-utils.h>
|
|
|
c5d8c8 |
#include <glusterfs/upcall-utils.h>
|
|
|
c5d8c8 |
+#include <glusterfs/common-utils.h>
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
#include <sys/time.h>
|
|
|
c5d8c8 |
#include <libgen.h>
|
|
|
c5d8c8 |
@@ -127,15 +128,6 @@ dht_read_iatt_from_xdata(xlator_t *this, dict_t *xdata, struct iatt *stbuf)
|
|
|
c5d8c8 |
int
|
|
|
c5d8c8 |
dht_rmdir_unlock(call_frame_t *frame, xlator_t *this);
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
-char *xattrs_to_heal[] = {"user.",
|
|
|
c5d8c8 |
- POSIX_ACL_ACCESS_XATTR,
|
|
|
c5d8c8 |
- POSIX_ACL_DEFAULT_XATTR,
|
|
|
c5d8c8 |
- QUOTA_LIMIT_KEY,
|
|
|
c5d8c8 |
- QUOTA_LIMIT_OBJECTS_KEY,
|
|
|
c5d8c8 |
- GF_SELINUX_XATTR_KEY,
|
|
|
c5d8c8 |
- GF_XATTR_MDATA_KEY,
|
|
|
c5d8c8 |
- NULL};
|
|
|
c5d8c8 |
-
|
|
|
c5d8c8 |
char *dht_dbg_vxattrs[] = {DHT_DBG_HASHED_SUBVOL_PATTERN, NULL};
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
/* Return true if key exists in array
|
|
|
c5d8c8 |
@@ -143,6 +135,8 @@ char *dht_dbg_vxattrs[] = {DHT_DBG_HASHED_SUBVOL_PATTERN, NULL};
|
|
|
c5d8c8 |
static gf_boolean_t
|
|
|
c5d8c8 |
dht_match_xattr(const char *key)
|
|
|
c5d8c8 |
{
|
|
|
c5d8c8 |
+ char **xattrs_to_heal = get_xattrs_to_heal();
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
return gf_get_index_by_elem(xattrs_to_heal, (char *)key) >= 0;
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
@@ -5399,11 +5393,13 @@ dht_dir_common_set_remove_xattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
|
|
|
c5d8c8 |
int call_cnt = 0;
|
|
|
c5d8c8 |
dht_local_t *local = NULL;
|
|
|
c5d8c8 |
char gfid_local[GF_UUID_BUF_SIZE] = {0};
|
|
|
c5d8c8 |
+ char **xattrs_to_heal;
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
conf = this->private;
|
|
|
c5d8c8 |
local = frame->local;
|
|
|
c5d8c8 |
call_cnt = conf->subvolume_cnt;
|
|
|
c5d8c8 |
local->flags = flags;
|
|
|
c5d8c8 |
+ xattrs_to_heal = get_xattrs_to_heal();
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
if (!gf_uuid_is_null(local->gfid)) {
|
|
|
c5d8c8 |
gf_uuid_unparse(local->gfid, gfid_local);
|
|
|
c5d8c8 |
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
|
|
|
c5d8c8 |
index 132b3b3..b856c68 100644
|
|
|
c5d8c8 |
--- a/xlators/cluster/dht/src/dht-common.h
|
|
|
c5d8c8 |
+++ b/xlators/cluster/dht/src/dht-common.h
|
|
|
c5d8c8 |
@@ -54,10 +54,6 @@
|
|
|
c5d8c8 |
#define DHT_DBG_HASHED_SUBVOL_PATTERN "dht.file.hashed-subvol.*"
|
|
|
c5d8c8 |
#define DHT_DBG_HASHED_SUBVOL_KEY "dht.file.hashed-subvol."
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
-/* Array to hold custom xattr keys
|
|
|
c5d8c8 |
- */
|
|
|
c5d8c8 |
-extern char *xattrs_to_heal[];
|
|
|
c5d8c8 |
-
|
|
|
c5d8c8 |
/* Rebalance nodeuuid flags */
|
|
|
c5d8c8 |
#define REBAL_NODEUUID_MINE 0x01
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
|
|
|
c5d8c8 |
index 4f7370d..4c3940a 100644
|
|
|
c5d8c8 |
--- a/xlators/cluster/dht/src/dht-helper.c
|
|
|
c5d8c8 |
+++ b/xlators/cluster/dht/src/dht-helper.c
|
|
|
c5d8c8 |
@@ -2289,6 +2289,7 @@ dht_dir_set_heal_xattr(xlator_t *this, dht_local_t *local, dict_t *dst,
|
|
|
c5d8c8 |
int luret = -1;
|
|
|
c5d8c8 |
int luflag = -1;
|
|
|
c5d8c8 |
int i = 0;
|
|
|
c5d8c8 |
+ char **xattrs_to_heal;
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
if (!src || !dst) {
|
|
|
c5d8c8 |
gf_msg(this->name, GF_LOG_WARNING, EINVAL, DHT_MSG_DICT_SET_FAILED,
|
|
|
c5d8c8 |
@@ -2305,6 +2306,9 @@ dht_dir_set_heal_xattr(xlator_t *this, dht_local_t *local, dict_t *dst,
|
|
|
c5d8c8 |
and set it to dst dict, here index start from 1 because
|
|
|
c5d8c8 |
user xattr already checked in previous statement
|
|
|
c5d8c8 |
*/
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ xattrs_to_heal = get_xattrs_to_heal();
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
for (i = 1; xattrs_to_heal[i]; i++) {
|
|
|
c5d8c8 |
keyval = dict_get(src, xattrs_to_heal[i]);
|
|
|
c5d8c8 |
if (keyval) {
|
|
|
c5d8c8 |
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
|
|
|
c5d8c8 |
index f4e17d1..8af7301 100644
|
|
|
c5d8c8 |
--- a/xlators/cluster/dht/src/dht-selfheal.c
|
|
|
c5d8c8 |
+++ b/xlators/cluster/dht/src/dht-selfheal.c
|
|
|
c5d8c8 |
@@ -2315,6 +2315,15 @@ dht_dir_heal_xattrs(void *data)
|
|
|
c5d8c8 |
if (subvol == mds_subvol)
|
|
|
c5d8c8 |
continue;
|
|
|
c5d8c8 |
if (uret || uflag) {
|
|
|
c5d8c8 |
+ /* Custom xattr heal is required - let posix handle it */
|
|
|
c5d8c8 |
+ ret = dict_set_int8(xdata, "sync_backend_xattrs", _gf_true);
|
|
|
c5d8c8 |
+ if (ret) {
|
|
|
c5d8c8 |
+ gf_smsg(this->name, GF_LOG_WARNING, 0, DHT_MSG_DICT_SET_FAILED,
|
|
|
c5d8c8 |
+ "path=%s", local->loc.path, "key=%s",
|
|
|
c5d8c8 |
+ "sync_backend_xattrs", NULL);
|
|
|
c5d8c8 |
+ goto out;
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
ret = syncop_setxattr(subvol, &local->loc, user_xattr, 0, xdata,
|
|
|
c5d8c8 |
NULL);
|
|
|
c5d8c8 |
if (ret) {
|
|
|
c5d8c8 |
@@ -2325,6 +2334,8 @@ dht_dir_heal_xattrs(void *data)
|
|
|
c5d8c8 |
"user xattr on path %s on "
|
|
|
c5d8c8 |
"subvol %s, gfid = %s ",
|
|
|
c5d8c8 |
local->loc.path, subvol->name, gfid);
|
|
|
c5d8c8 |
+ } else {
|
|
|
c5d8c8 |
+ dict_del(xdata, "sync_backend_xattrs");
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
|
|
|
c5d8c8 |
index 16351d8..40a9ee4 100644
|
|
|
c5d8c8 |
--- a/xlators/storage/posix/src/posix-helpers.c
|
|
|
c5d8c8 |
+++ b/xlators/storage/posix/src/posix-helpers.c
|
|
|
c5d8c8 |
@@ -3656,3 +3656,22 @@ out:
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
return is_stale;
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+/* Delete user xattr from the file at the file-path specified by data and from
|
|
|
c5d8c8 |
+ * dict */
|
|
|
c5d8c8 |
+int
|
|
|
c5d8c8 |
+posix_delete_user_xattr(dict_t *dict, char *k, data_t *v, void *data)
|
|
|
c5d8c8 |
+{
|
|
|
c5d8c8 |
+ int ret;
|
|
|
c5d8c8 |
+ char *real_path = data;
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ ret = sys_lremovexattr(real_path, k);
|
|
|
c5d8c8 |
+ if (ret) {
|
|
|
c5d8c8 |
+ gf_msg("posix-helpers", GF_LOG_ERROR, P_MSG_XATTR_NOT_REMOVED, errno,
|
|
|
c5d8c8 |
+ "removexattr failed. key %s path %s", k, real_path);
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ dict_del(dict, k);
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ return ret;
|
|
|
c5d8c8 |
+}
|
|
|
c5d8c8 |
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
|
|
|
c5d8c8 |
index 4c2983a..be22c5e 100644
|
|
|
c5d8c8 |
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
|
|
|
c5d8c8 |
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
|
|
|
c5d8c8 |
@@ -62,6 +62,7 @@
|
|
|
c5d8c8 |
#include <glusterfs/events.h>
|
|
|
c5d8c8 |
#include "posix-gfid-path.h"
|
|
|
c5d8c8 |
#include <glusterfs/compat-uuid.h>
|
|
|
c5d8c8 |
+#include <glusterfs/common-utils.h>
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
extern char *marker_xattrs[];
|
|
|
c5d8c8 |
#define ALIGN_SIZE 4096
|
|
|
c5d8c8 |
@@ -2733,6 +2734,7 @@ posix_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
|
|
|
c5d8c8 |
int32_t ret = 0;
|
|
|
c5d8c8 |
ssize_t acl_size = 0;
|
|
|
c5d8c8 |
dict_t *xattr = NULL;
|
|
|
c5d8c8 |
+ dict_t *subvol_xattrs = NULL;
|
|
|
c5d8c8 |
posix_xattr_filler_t filler = {
|
|
|
c5d8c8 |
0,
|
|
|
c5d8c8 |
};
|
|
|
c5d8c8 |
@@ -2748,6 +2750,10 @@ posix_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
|
|
|
c5d8c8 |
struct mdata_iatt mdata_iatt = {
|
|
|
c5d8c8 |
0,
|
|
|
c5d8c8 |
};
|
|
|
c5d8c8 |
+ int8_t sync_backend_xattrs = _gf_false;
|
|
|
c5d8c8 |
+ data_pair_t *custom_xattrs;
|
|
|
c5d8c8 |
+ data_t *keyval = NULL;
|
|
|
c5d8c8 |
+ char **xattrs_to_heal = get_xattrs_to_heal();
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
DECLARE_OLD_FS_ID_VAR;
|
|
|
c5d8c8 |
SET_FS_ID(frame->root->uid, frame->root->gid);
|
|
|
c5d8c8 |
@@ -2930,6 +2936,66 @@ posix_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
|
|
|
c5d8c8 |
goto out;
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
+ ret = dict_get_int8(xdata, "sync_backend_xattrs", &sync_backend_xattrs);
|
|
|
c5d8c8 |
+ if (ret) {
|
|
|
c5d8c8 |
+ gf_msg_debug(this->name, -ret, "Unable to get sync_backend_xattrs");
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ if (sync_backend_xattrs) {
|
|
|
c5d8c8 |
+ /* List all custom xattrs */
|
|
|
c5d8c8 |
+ subvol_xattrs = dict_new();
|
|
|
c5d8c8 |
+ if (!subvol_xattrs)
|
|
|
c5d8c8 |
+ goto out;
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ ret = dict_set_int32_sizen(xdata, "list-xattr", 1);
|
|
|
c5d8c8 |
+ if (ret) {
|
|
|
c5d8c8 |
+ gf_msg(this->name, GF_LOG_ERROR, 0, ENOMEM,
|
|
|
c5d8c8 |
+ "Unable to set list-xattr in dict ");
|
|
|
c5d8c8 |
+ goto out;
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ subvol_xattrs = posix_xattr_fill(this, real_path, loc, NULL, -1, xdata,
|
|
|
c5d8c8 |
+ NULL);
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ /* Remove all user xattrs from the file */
|
|
|
c5d8c8 |
+ dict_foreach_fnmatch(subvol_xattrs, "user.*", posix_delete_user_xattr,
|
|
|
c5d8c8 |
+ real_path);
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ /* Remove all custom xattrs from the file */
|
|
|
c5d8c8 |
+ for (i = 1; xattrs_to_heal[i]; i++) {
|
|
|
c5d8c8 |
+ keyval = dict_get(subvol_xattrs, xattrs_to_heal[i]);
|
|
|
c5d8c8 |
+ if (keyval) {
|
|
|
c5d8c8 |
+ ret = sys_lremovexattr(real_path, xattrs_to_heal[i]);
|
|
|
c5d8c8 |
+ if (ret) {
|
|
|
c5d8c8 |
+ gf_msg(this->name, GF_LOG_ERROR, P_MSG_XATTR_NOT_REMOVED,
|
|
|
c5d8c8 |
+ errno, "removexattr failed. key %s path %s",
|
|
|
c5d8c8 |
+ xattrs_to_heal[i], loc->path);
|
|
|
c5d8c8 |
+ goto out;
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ dict_del(subvol_xattrs, xattrs_to_heal[i]);
|
|
|
c5d8c8 |
+ keyval = NULL;
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ /* Set custom xattrs based on info provided by DHT */
|
|
|
c5d8c8 |
+ custom_xattrs = dict->members_list;
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ while (custom_xattrs != NULL) {
|
|
|
c5d8c8 |
+ ret = sys_lsetxattr(real_path, custom_xattrs->key,
|
|
|
c5d8c8 |
+ custom_xattrs->value->data,
|
|
|
c5d8c8 |
+ custom_xattrs->value->len, flags);
|
|
|
c5d8c8 |
+ if (ret) {
|
|
|
c5d8c8 |
+ op_errno = errno;
|
|
|
c5d8c8 |
+ gf_log(this->name, GF_LOG_ERROR, "setxattr failed - %s %d",
|
|
|
c5d8c8 |
+ custom_xattrs->key, ret);
|
|
|
c5d8c8 |
+ goto out;
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
+ custom_xattrs = custom_xattrs->next;
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+ }
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
xattr = dict_new();
|
|
|
c5d8c8 |
if (!xattr)
|
|
|
c5d8c8 |
goto out;
|
|
|
c5d8c8 |
@@ -3037,6 +3103,9 @@ out:
|
|
|
c5d8c8 |
if (xattr)
|
|
|
c5d8c8 |
dict_unref(xattr);
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
+ if (subvol_xattrs)
|
|
|
c5d8c8 |
+ dict_unref(subvol_xattrs);
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
return 0;
|
|
|
c5d8c8 |
}
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
|
|
|
c5d8c8 |
index 4be979c..b357d34 100644
|
|
|
c5d8c8 |
--- a/xlators/storage/posix/src/posix.h
|
|
|
c5d8c8 |
+++ b/xlators/storage/posix/src/posix.h
|
|
|
c5d8c8 |
@@ -686,4 +686,7 @@ posix_update_iatt_buf(struct iatt *buf, int fd, char *loc, dict_t *xdata);
|
|
|
c5d8c8 |
gf_boolean_t
|
|
|
c5d8c8 |
posix_is_layout_stale(dict_t *xdata, char *par_path, xlator_t *this);
|
|
|
c5d8c8 |
|
|
|
c5d8c8 |
+int
|
|
|
c5d8c8 |
+posix_delete_user_xattr(dict_t *dict, char *k, data_t *v, void *data);
|
|
|
c5d8c8 |
+
|
|
|
c5d8c8 |
#endif /* _POSIX_H */
|
|
|
c5d8c8 |
--
|
|
|
c5d8c8 |
1.8.3.1
|
|
|
c5d8c8 |
|