d1681e
From 92d3d162567828c15f9e3aa7bd2cb70c7d058efb Mon Sep 17 00:00:00 2001
d1681e
From: N Balachandran <nbalacha@redhat.com>
d1681e
Date: Fri, 9 Feb 2018 13:49:44 +0530
d1681e
Subject: [PATCH 146/148] cluster/dht: Cleanup on fallocate failure
d1681e
d1681e
It looks like fallocate leaves a non-empty
d1681e
file behind in case of some failures. We now
d1681e
truncate the file to 0 bytes on failure in
d1681e
__dht_rebalance_create_dst_file.
d1681e
d1681e
upstream patch: https://review.gluster.org/#/c/19514/
d1681e
d1681e
> Change-Id: Ia4ad7b94bb3624a301fcc87d9e36c4dc751edb59
d1681e
> BUG: 1541916
d1681e
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
d1681e
d1681e
Change-Id: I0c67f62a638300d98b93710dedde438e69edb7f4
d1681e
BUG: 1540961
d1681e
Signed-off-by: N Balachandran <nbalacha@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/129923
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
d1681e
Reviewed-by: Susant Palai <spalai@redhat.com>
d1681e
---
d1681e
 xlators/cluster/dht/src/dht-rebalance.c | 16 +++++++++++++++-
d1681e
 1 file changed, 15 insertions(+), 1 deletion(-)
d1681e
d1681e
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
d1681e
index 3343a2b..f9a25fb 100644
d1681e
--- a/xlators/cluster/dht/src/dht-rebalance.c
d1681e
+++ b/xlators/cluster/dht/src/dht-rebalance.c
d1681e
@@ -668,6 +668,7 @@ __dht_rebalance_create_dst_file (xlator_t *this, xlator_t *to, xlator_t *from,
d1681e
                                  int *fop_errno)
d1681e
 {
d1681e
         int          ret  = -1;
d1681e
+        int          ret2 = -1;
d1681e
         fd_t        *fd   = NULL;
d1681e
         struct iatt  new_stbuf = {0,};
d1681e
         struct iatt  check_stbuf= {0,};
d1681e
@@ -803,7 +804,7 @@ __dht_rebalance_create_dst_file (xlator_t *this, xlator_t *to, xlator_t *from,
d1681e
 
d1681e
         if (-ret == ENOENT) {
d1681e
                 gf_msg (this->name, GF_LOG_ERROR, -ret,
d1681e
-                        DHT_MSG_MIGRATE_FILE_FAILED, "%s: file does not exists"
d1681e
+                        DHT_MSG_MIGRATE_FILE_FAILED, "%s: file does not exist "
d1681e
                         "on %s", loc->path, to->name);
d1681e
                 *fop_errno = -ret;
d1681e
                 ret = -1;
d1681e
@@ -831,6 +832,19 @@ __dht_rebalance_create_dst_file (xlator_t *this, xlator_t *to, xlator_t *from,
d1681e
                                 DHT_MSG_MIGRATE_FILE_FAILED,
d1681e
                                 "fallocate failed for %s on %s",
d1681e
                                 loc->path, to->name);
d1681e
+
d1681e
+                        /* fallocate does not release the space in some cases
d1681e
+                         */
d1681e
+
d1681e
+                        ret2 = syncop_ftruncate (to, fd, 0,
d1681e
+                                                 NULL, NULL);
d1681e
+                        if (ret2 < 0) {
d1681e
+                                gf_msg (this->name, GF_LOG_WARNING, -ret2,
d1681e
+                                        DHT_MSG_MIGRATE_FILE_FAILED,
d1681e
+                                        "ftruncate failed for %s on %s",
d1681e
+                                        loc->path, to->name);
d1681e
+                        }
d1681e
+                        *fop_errno = -ret;
d1681e
                         ret = -1;
d1681e
                         goto out;
d1681e
                 }
d1681e
-- 
d1681e
1.8.3.1
d1681e