diff options
author | Amar Tumballi <amar@gluster.com> | 2011-04-06 05:46:44 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-04-08 01:18:56 -0700 |
commit | 0d440ddb80c55320fe9deda15cecec8e31cab2c1 (patch) | |
tree | 25cab4890eed7376c16734892014593d3e7bb93d /xlators/mgmt/glusterd | |
parent | 12de69e4204c0dced7cccc8450954ad2e20c1075 (diff) |
gluster rebalance: don't depend on the sticky bit for validating link file.
do the getxattr() with 'trusted.distribute.linkinfo' key, which
returns success only if the file has a link. With this we can preserve
the exact same permission as old file.
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@gluster.com>
BUG: 2530 (Rebalance not working properly (file permission issues))
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2530
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index d5048549b..969dffbf1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -43,17 +43,18 @@ int gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir) { - int ret = -1; - int dst_fd = -1; - int src_fd = -1; - DIR *fd = NULL; - glusterd_defrag_info_t *defrag = NULL; - struct dirent *entry = NULL; - struct stat stbuf = {0,}; - struct stat new_stbuf = {0,}; - char full_path[1024] = {0,}; - char tmp_filename[1024] = {0,}; - char value[16] = {0,}; + int ret = -1; + int dst_fd = -1; + int src_fd = -1; + DIR *fd = NULL; + glusterd_defrag_info_t *defrag = NULL; + struct dirent *entry = NULL; + struct stat stbuf = {0,}; + struct stat new_stbuf = {0,}; + char full_path[PATH_MAX] = {0,}; + char tmp_filename[PATH_MAX] = {0,}; + char value[16] = {0,}; + char linkinfo[PATH_MAX] = {0,}; if (!volinfo->defrag) goto out; @@ -70,7 +71,7 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir) if (!strcmp (entry->d_name, ".") || !strcmp (entry->d_name, "..")) continue; - snprintf (full_path, 1024, "%s/%s", dir, entry->d_name); + snprintf (full_path, PATH_MAX, "%s/%s", dir, entry->d_name); ret = stat (full_path, &stbuf); if (ret == -1) @@ -79,8 +80,13 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir) if (S_ISREG (stbuf.st_mode)) defrag->num_files_lookedup += 1; - if (!(S_ISREG (stbuf.st_mode) && - ((stbuf.st_mode & S_ISVTX) == S_ISVTX))) + /* if distribute is present, it will honor this key. + -1 is returned if distribute is not present or file doesn't + have a link-file. If file has link-file, the path of + link-file will be the value */ + ret = sys_lgetxattr (full_path, GF_XATTR_LINKINFO_KEY, + &linkinfo, PATH_MAX); + if (ret <= 0) continue; /* If the file is open, don't run rebalance on it */ @@ -91,11 +97,11 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir) /* If its a regular file, and sticky bit is set, we need to rebalance that */ - snprintf (tmp_filename, 1024, "%s/.%s.gfs%llu", dir, + snprintf (tmp_filename, PATH_MAX, "%s/.%s.gfs%llu", dir, entry->d_name, (unsigned long long)stbuf.st_size); - dst_fd = creat (tmp_filename, (stbuf.st_mode & ~S_ISVTX)); + dst_fd = creat (tmp_filename, stbuf.st_mode); if (dst_fd == -1) continue; @@ -130,13 +136,6 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir) continue; } - ret = fchmod (dst_fd, stbuf.st_mode & ~S_ISVTX); - if (ret) { - gf_log ("", GF_LOG_WARNING, - "failed to set the mode of file %s: %s", - tmp_filename, strerror (errno)); - } - ret = fchown (dst_fd, stbuf.st_uid, stbuf.st_gid); if (ret) { gf_log ("", GF_LOG_WARNING, @@ -556,12 +555,11 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, goto out; } - snprintf (cmd_str, sizeof (cmd_str), "%s/sbin/glusterfs -s localhost " - "--volfile-id %s --volume-name %s-quick-read " - "--xlator-option *dht.unhashed-sticky-bit=yes " + snprintf (cmd_str, sizeof (cmd_str), + "%s/sbin/glusterfs -s localhost --volfile-id %s " "--xlator-option *dht.use-readdirp=yes " "--xlator-option *dht.lookup-unhashed=yes %s", - GFS_PREFIX, volinfo->volname, volinfo->volname, + GFS_PREFIX, volinfo->volname, defrag->mount); ret = gf_system (cmd_str); if (ret) { |