summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-diskusage.c
diff options
context:
space:
mode:
authorSusant Palai <spalai@redhat.com>2017-04-17 13:00:54 +0530
committerRaghavendra G <rgowdapp@redhat.com>2017-04-19 01:35:14 -0400
commitb350bcd6a3db2e92d1baa47a5ec02efd09f76f16 (patch)
treeaf5f3a473131a7978bbda2bdd74582904d0d0ab2 /xlators/cluster/dht/src/dht-diskusage.c
parente3d9018f2ddc28548c0aa18960a3a524521c9ad7 (diff)
cluster/dht: Skip file migration if the subvol that meets min-free-disk
criteria happens to be the same subvol containing data-file Rebalance need to figure out a new subvol in case the hashed subvol does not have enough space. In the process of figuring out the new subvol, we need to ignore the source subvol, otherwise it will lead to data loss. Test: Manual Ran the following sizeof /tmp/1: 1.5GB sizeof /brick/1: 16GB sizeof /tmp/2: 1.5GB <start> glusterd; gluster v create test1 vm1:/brick/1 vm1:/tmp/1; gluster v start test1; mount -t glusterfs vm1:test1 /mnt; for i in {1..2000} do dd if=/dev/zero of=/mnt/file$i bs=1KB count=1 &> /dev/null; done gluster v add-brick test1 vm1:/tmp/2 gluster v set test1 min-free-disk 12GB gluster v remove-brick test1 vm1:/tmp/1 star <end> file count and data were intact. Change-Id: Ib8fc8467a3d48a7c12958824c4f0b88e160b86c1 BUG: 1441508 Signed-off-by: Susant Palai <spalai@redhat.com> Reviewed-on: https://review.gluster.org/17064 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-diskusage.c')
-rw-r--r--xlators/cluster/dht/src/dht-diskusage.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/xlators/cluster/dht/src/dht-diskusage.c b/xlators/cluster/dht/src/dht-diskusage.c
index 13698a9616d..05592154e30 100644
--- a/xlators/cluster/dht/src/dht-diskusage.c
+++ b/xlators/cluster/dht/src/dht-diskusage.c
@@ -315,7 +315,7 @@ dht_free_disk_available_subvol (xlator_t *this, xlator_t *subvol,
LOCK (&conf->subvolume_lock);
{
- avail_subvol = dht_subvol_with_free_space_inodes(this, subvol,
+ avail_subvol = dht_subvol_with_free_space_inodes(this, subvol, NULL,
layout, 0);
if(!avail_subvol)
{
@@ -340,8 +340,8 @@ out:
}
static inline
-int32_t dht_subvol_has_err (dht_conf_t *conf, xlator_t *this,
- dht_layout_t *layout)
+int32_t dht_subvol_has_err (dht_conf_t *conf, xlator_t *this, xlator_t *ignore,
+ dht_layout_t *layout)
{
int ret = -1;
int i = 0;
@@ -349,6 +349,13 @@ int32_t dht_subvol_has_err (dht_conf_t *conf, xlator_t *this,
if (!this || !layout)
goto out;
+ /* this check is meant for rebalance process. The source of the file
+ * should be ignored for space check */
+ if (this == ignore) {
+ goto out;
+ }
+
+
/* check if subvol has layout errors, before selecting it */
for (i = 0; i < layout->cnt; i++) {
if (!strcmp (layout->list[i].xlator->name, this->name) &&
@@ -376,7 +383,7 @@ out:
/*Get subvolume which has both space and inodes more than the min criteria*/
xlator_t *
-dht_subvol_with_free_space_inodes(xlator_t *this, xlator_t *subvol,
+dht_subvol_with_free_space_inodes(xlator_t *this, xlator_t *subvol, xlator_t *ignore,
dht_layout_t *layout, uint64_t filesize)
{
int i = 0;
@@ -398,7 +405,7 @@ dht_subvol_with_free_space_inodes(xlator_t *this, xlator_t *subvol,
/* check if subvol has layout errors and also it is not a
* decommissioned brick, before selecting it */
ignore_subvol = dht_subvol_has_err (conf, conf->subvolumes[i],
- layout);
+ ignore, layout);
if (ignore_subvol)
continue;
@@ -463,7 +470,7 @@ dht_subvol_maxspace_nonzeroinode (xlator_t *this, xlator_t *subvol,
/* check if subvol has layout errors and also it is not a
* decommissioned brick, before selecting it*/
- ignore_subvol = dht_subvol_has_err (conf, conf->subvolumes[i],
+ ignore_subvol = dht_subvol_has_err (conf, conf->subvolumes[i], NULL,
layout);
if (ignore_subvol)
continue;