|
|
3604df |
From 2ca340c34e820ef4232ee20f1084fe4803ca2140 Mon Sep 17 00:00:00 2001
|
|
|
3604df |
From: moagrawa <moagrawa@redhat.com>
|
|
|
3604df |
Date: Tue, 29 Nov 2016 11:12:00 +0530
|
|
|
3604df |
Subject: [PATCH 206/206] cluster/dht: A hard link is lost during rebalance +
|
|
|
3604df |
lookup
|
|
|
3604df |
|
|
|
3604df |
Problem: A hard link is lost during rebalance + lookup.Rebalance skip
|
|
|
3604df |
files if file has hardlink.In dht_migrate_file
|
|
|
3604df |
__is_file_migratable () function checks if a file has hardlink,
|
|
|
3604df |
if yes file is not migrated but if link is created after call
|
|
|
3604df |
this function then link will lost.
|
|
|
3604df |
|
|
|
3604df |
Solution: Call __check_file_has_hardlink to check hardlink existence
|
|
|
3604df |
after (S+T) bits in migration process ,if file has hardlink
|
|
|
3604df |
then skip the file for migrate rebalance process.
|
|
|
3604df |
|
|
|
3604df |
> BUG: 1396048
|
|
|
3604df |
> Change-Id: Ia53c07ef42f1128c2eedf959a757e8df517b9d12
|
|
|
3604df |
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
3604df |
> Reviewed-on: http://review.gluster.org/15866
|
|
|
3604df |
> Reviewed-by: Susant Palai <spalai@redhat.com>
|
|
|
3604df |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> Reviewed-by: N Balachandran <nbalacha@redhat.com>
|
|
|
3604df |
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
3604df |
> (cherry picked from commit 71dd2e914d4a537bf74e1ec3a24512fc83bacb1d)
|
|
|
3604df |
|
|
|
3604df |
BUG: 1392837
|
|
|
3604df |
Change-Id: I7d96c56e497c0cefe40093c4588c53ef8540fc3d
|
|
|
3604df |
Signed-off-by: moagrawa <moagrawa@redhat.com>
|
|
|
3604df |
Reviewed-on: https://code.engineering.redhat.com/gerrit/91494
|
|
|
3604df |
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
|
|
|
3604df |
---
|
|
|
3604df |
xlators/cluster/dht/src/dht-rebalance.c | 101 ++++++++++++++++++++------------
|
|
|
3604df |
1 file changed, 62 insertions(+), 39 deletions(-)
|
|
|
3604df |
|
|
|
3604df |
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
3604df |
index 2373e9d..c82700e 100644
|
|
|
3604df |
--- a/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
3604df |
+++ b/xlators/cluster/dht/src/dht-rebalance.c
|
|
|
3604df |
@@ -464,6 +464,50 @@ out:
|
|
|
3604df |
return ret;
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
+
|
|
|
3604df |
+static int
|
|
|
3604df |
+__check_file_has_hardlink (xlator_t *this, loc_t *loc,
|
|
|
3604df |
+ struct iatt *stbuf, dict_t *xattrs, int flags,
|
|
|
3604df |
+ gf_defrag_info_t *defrag)
|
|
|
3604df |
+{
|
|
|
3604df |
+ int ret = 0;
|
|
|
3604df |
+
|
|
|
3604df |
+ if (flags == GF_DHT_MIGRATE_HARDLINK_IN_PROGRESS) {
|
|
|
3604df |
+ ret = 0;
|
|
|
3604df |
+ return ret;
|
|
|
3604df |
+ }
|
|
|
3604df |
+ if (stbuf->ia_nlink > 1) {
|
|
|
3604df |
+ /* support for decomission */
|
|
|
3604df |
+ if (flags == GF_DHT_MIGRATE_HARDLINK) {
|
|
|
3604df |
+ synclock_lock (&defrag->link_lock);
|
|
|
3604df |
+ ret = gf_defrag_handle_hardlink
|
|
|
3604df |
+ (this, loc, xattrs, stbuf);
|
|
|
3604df |
+ synclock_unlock (&defrag->link_lock);
|
|
|
3604df |
+ /*
|
|
|
3604df |
+ Returning zero will force the file to be remigrated.
|
|
|
3604df |
+ Checkout gf_defrag_handle_hardlink for more
|
|
|
3604df |
+ information.
|
|
|
3604df |
+ */
|
|
|
3604df |
+ if (ret && ret != -2) {
|
|
|
3604df |
+ gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
3604df |
+ DHT_MSG_MIGRATE_FILE_FAILED,
|
|
|
3604df |
+ "Migrate file failed:"
|
|
|
3604df |
+ "%s: failed to migrate file with link",
|
|
|
3604df |
+ loc->path);
|
|
|
3604df |
+ }
|
|
|
3604df |
+ } else {
|
|
|
3604df |
+ gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
3604df |
+ DHT_MSG_MIGRATE_FILE_FAILED,
|
|
|
3604df |
+ "Migrate file failed:"
|
|
|
3604df |
+ "%s: file has hardlinks", loc->path);
|
|
|
3604df |
+ ret = -ENOTSUP;
|
|
|
3604df |
+ }
|
|
|
3604df |
+ }
|
|
|
3604df |
+
|
|
|
3604df |
+ return ret;
|
|
|
3604df |
+}
|
|
|
3604df |
+
|
|
|
3604df |
+
|
|
|
3604df |
/*
|
|
|
3604df |
return values
|
|
|
3604df |
0 : File will be migrated
|
|
|
3604df |
@@ -512,41 +556,9 @@ __is_file_migratable (xlator_t *this, loc_t *loc,
|
|
|
3604df |
}
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
- if (flags == GF_DHT_MIGRATE_HARDLINK_IN_PROGRESS) {
|
|
|
3604df |
- ret = 0;
|
|
|
3604df |
- goto out;
|
|
|
3604df |
- }
|
|
|
3604df |
-
|
|
|
3604df |
- if (stbuf->ia_nlink > 1) {
|
|
|
3604df |
- /* support for decomission */
|
|
|
3604df |
- if (flags == GF_DHT_MIGRATE_HARDLINK) {
|
|
|
3604df |
- synclock_lock (&defrag->link_lock);
|
|
|
3604df |
- ret = gf_defrag_handle_hardlink
|
|
|
3604df |
- (this, loc, xattrs, stbuf);
|
|
|
3604df |
- synclock_unlock (&defrag->link_lock);
|
|
|
3604df |
- /*
|
|
|
3604df |
- Returning zero will force the file to be remigrated.
|
|
|
3604df |
- Checkout gf_defrag_handle_hardlink for more information.
|
|
|
3604df |
- */
|
|
|
3604df |
- if (ret && ret != -2) {
|
|
|
3604df |
- gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
3604df |
- DHT_MSG_MIGRATE_FILE_FAILED,
|
|
|
3604df |
- "Migrate file failed:"
|
|
|
3604df |
- "%s: failed to migrate file with link",
|
|
|
3604df |
- loc->path);
|
|
|
3604df |
- }
|
|
|
3604df |
- } else {
|
|
|
3604df |
- gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
3604df |
- DHT_MSG_MIGRATE_FILE_FAILED,
|
|
|
3604df |
- "Migrate file failed:"
|
|
|
3604df |
- "%s: file has hardlinks", loc->path);
|
|
|
3604df |
- ret = -ENOTSUP;
|
|
|
3604df |
- }
|
|
|
3604df |
- goto out;
|
|
|
3604df |
- }
|
|
|
3604df |
-
|
|
|
3604df |
- ret = 0;
|
|
|
3604df |
-
|
|
|
3604df |
+ /* Check if file has hardlink*/
|
|
|
3604df |
+ ret = __check_file_has_hardlink (this, loc, stbuf, xattrs,
|
|
|
3604df |
+ flags, defrag);
|
|
|
3604df |
out:
|
|
|
3604df |
return ret;
|
|
|
3604df |
}
|
|
|
3604df |
@@ -1368,9 +1380,6 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
|
|
|
3604df |
goto out;
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
- /* we no more require this key */
|
|
|
3604df |
- dict_del (dict, conf->link_xattr_name);
|
|
|
3604df |
-
|
|
|
3604df |
/* preserve source mode, so set the same to the destination */
|
|
|
3604df |
src_ia_prot = stbuf.ia_prot;
|
|
|
3604df |
|
|
|
3604df |
@@ -1425,8 +1434,13 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
|
|
|
3604df |
goto out;
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
+ if (xattr_rsp) {
|
|
|
3604df |
+ /* we no more require this key */
|
|
|
3604df |
+ dict_del (dict, conf->link_xattr_name);
|
|
|
3604df |
+ dict_unref (xattr_rsp);
|
|
|
3604df |
+ }
|
|
|
3604df |
|
|
|
3604df |
- ret = syncop_fstat (from, src_fd, &stbuf, NULL, NULL);
|
|
|
3604df |
+ ret = syncop_fstat (from, src_fd, &stbuf, dict, &xattr_rsp);
|
|
|
3604df |
if (ret) {
|
|
|
3604df |
gf_msg (this->name, GF_LOG_ERROR, -ret,
|
|
|
3604df |
DHT_MSG_MIGRATE_FILE_FAILED,
|
|
|
3604df |
@@ -1436,6 +1450,15 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
|
|
|
3604df |
goto out;
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
+ /* Check again if file has hardlink */
|
|
|
3604df |
+ ret = __check_file_has_hardlink (this, loc, &stbuf, xattr_rsp,
|
|
|
3604df |
+ flag, defrag);
|
|
|
3604df |
+ if (ret) {
|
|
|
3604df |
+ if (ret == -2)
|
|
|
3604df |
+ ret = 0;
|
|
|
3604df |
+ goto out;
|
|
|
3604df |
+ }
|
|
|
3604df |
+
|
|
|
3604df |
/* Try to preserve 'holes' while migrating data */
|
|
|
3604df |
if (stbuf.ia_size > (stbuf.ia_blocks * GF_DISK_SECTOR_SIZE))
|
|
|
3604df |
file_has_holes = 1;
|
|
|
3604df |
--
|
|
|
3604df |
2.9.3
|
|
|
3604df |
|