summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-07-12 01:10:58 +0000
committerAnand Avati <avati@gluster.com>2011-07-12 00:07:18 -0700
commit3ac3584a55c500230e747c101c7040792a53813d (patch)
tree8a1a469fba7a0547a6e4e66e881fae2c4b69b1ea /xlators
parent36ffb14bef1a297a9ecd5d73b4f74be444a675ea (diff)
glusterd rebalance: bring in feature to migrate extended attributes too
currently when a file gets migrated, the extended attributes of the files are getting lost (which should be treated as data-loss). Change-Id: I7068e6b67e614f2016e6eae92c247990ae01e74a Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 3069 ('gluster rebalance' doesn't preserve any of the extended attributes of the migrated file) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3069
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index 59d4963d42b..6119ad34d23 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -40,6 +40,60 @@
#include "syscall.h"
#include "cli1.h"
+static int
+migrate_xattrs_of_file (int src, int dst)
+{
+ int ret = -1;
+ ssize_t len = 0;
+ ssize_t size = 0;
+ ssize_t size_processed = 0;
+ char *key = NULL;
+ char value[4096] = {0,};
+ char list[4096] = {0,};
+
+ /* Get the size of xattr list */
+ size = flistxattr (src, list, 4096);
+ if (size < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to fetch the extended attribute list (%s)",
+ strerror (errno));
+ goto out;
+ }
+ if (size == 0) {
+ gf_log (THIS->name, GF_LOG_DEBUG,
+ "there are no extended attributes for the file");
+ ret = 0;
+ goto out;
+ }
+
+ while (size > size_processed) {
+ key = &list[size_processed];
+ len = fgetxattr (src, key, value, 4096);
+ if (len < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to get the xattr for key %s (%s)",
+ key, strerror (errno));
+ goto out;
+ }
+
+ ret = fsetxattr (dst, key, value, len, 0);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to set the xattr for key %s (%s)",
+ key, strerror (errno));
+ goto out;
+ }
+ /* Exclude the NULL character */
+ size_processed += strlen (key) + 1;
+ }
+
+ ret = 0;
+out:
+
+ return ret;
+}
+
+
int
gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir)
{
@@ -141,6 +195,13 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir)
continue;
}
+ ret = migrate_xattrs_of_file (src_fd, dst_fd);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_WARNING,
+ "failed to copy the extended attributes "
+ "from source file %s", full_path);
+ }
+
ret = fchown (dst_fd, stbuf.st_uid, stbuf.st_gid);
if (ret) {
gf_log ("", GF_LOG_WARNING,