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