summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-10-12 04:09:35 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-12 03:04:09 -0700
commit6e6b4b4fd002347ca08691f73e10b961f693d754 (patch)
treede58accf862f8a468e52b359054387f046c8a388
parentb9d6e0c879feb9d86cdadf4072a7ebeb5eb29798 (diff)
glusterd-rebalance: if file is open, don't do rebalancev3.1.0
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 971 (dynamic volume management) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c7
-rw-r--r--xlators/storage/posix/src/posix.c25
2 files changed, 32 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index 934fc70307a..f3c5b9591b5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -53,6 +53,7 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir)
struct stat new_stbuf = {0,};
char full_path[1024] = {0,};
char tmp_filename[1024] = {0,};
+ char value[16] = {0,};
if (!volinfo->defrag)
goto out;
@@ -82,6 +83,12 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir)
((stbuf.st_mode & 01000) == 01000)))
continue;
+ /* If the file is open, don't run rebalance on it */
+ ret = sys_lgetxattr (full_path, GLUSTERFS_OPEN_FD_COUNT,
+ &value, 16);
+ if ((ret < 0) || !strncmp (value, "1", 1))
+ continue;
+
/* If its a regular file, and sticky bit is set, we need to
rebalance that */
snprintf (tmp_filename, 1024, "%s/.%s.gfs%llu", dir,
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index fbdc2a13d77..28857b09fdf 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3031,6 +3031,22 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
goto out;
}
+ if (loc->inode && !strcmp (name, GLUSTERFS_OPEN_FD_COUNT)) {
+ if (!list_empty (&loc->inode->fd_list)) {
+ ret = dict_set_uint32 (dict, (char *)name, 1);
+ if (ret < 0)
+ gf_log (this->name, GF_LOG_WARNING,
+ "Failed to set dictionary value for %s",
+ name);
+ } else {
+ ret = dict_set_uint32 (dict, (char *)name, 0);
+ if (ret < 0)
+ gf_log (this->name, GF_LOG_WARNING,
+ "Failed to set dictionary value for %s",
+ name);
+ }
+ goto done;
+ }
if (loc->inode && IA_ISREG (loc->inode->ia_type) && name &&
(strcmp (name, GF_XATTR_PATHINFO_KEY) == 0)) {
snprintf (host_buf, 1024, "%s:%s", priv->hostname,
@@ -3171,6 +3187,15 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
goto out;
}
+ if (!strcmp (name, GLUSTERFS_OPEN_FD_COUNT)) {
+ ret = dict_set_uint32 (dict, (char *)name, 1);
+ if (ret < 0)
+ gf_log (this->name, GF_LOG_WARNING,
+ "Failed to set dictionary value for %s",
+ name);
+ goto done;
+ }
+
size = sys_flistxattr (_fd, NULL, 0);
if (size == -1) {
op_errno = errno;