|
|
12a457 |
From 7b65a8599465354462ec420f9124a3e4b0aa03dc Mon Sep 17 00:00:00 2001
|
|
|
12a457 |
From: Raghavendra G <rgowdapp@redhat.com>
|
|
|
12a457 |
Date: Wed, 11 May 2016 17:49:10 +0530
|
|
|
12a457 |
Subject: [PATCH 157/158] cluster/distribute: use a linked inode in directory heal codepath
|
|
|
12a457 |
|
|
|
12a457 |
This is needed for following reasons:
|
|
|
12a457 |
* healing is done in lookup and mkdir codepath where inode is not
|
|
|
12a457 |
linked _yet_ as normally linking is done in interface layers
|
|
|
12a457 |
(fuse-bridge, gfapi, nfsv3 etc).
|
|
|
12a457 |
|
|
|
12a457 |
* healing consists of non-lookup fops like inodelk, setattr, setxattr
|
|
|
12a457 |
etc. All non-lookup fops expect a linked inode.
|
|
|
12a457 |
|
|
|
12a457 |
Change-Id: I1bda157baabe58431b7f6f6fffee0abfe5225342
|
|
|
12a457 |
BUG: 1325760
|
|
|
12a457 |
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
12a457 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/74412
|
|
|
12a457 |
---
|
|
|
12a457 |
xlators/cluster/dht/src/dht-common.c | 2 +-
|
|
|
12a457 |
xlators/cluster/dht/src/dht-selfheal.c | 67 +++++++++++++++++++++++++++-----
|
|
|
12a457 |
2 files changed, 58 insertions(+), 11 deletions(-)
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
|
|
|
12a457 |
index e9fcf47..10d47de 100644
|
|
|
12a457 |
--- a/xlators/cluster/dht/src/dht-common.c
|
|
|
12a457 |
+++ b/xlators/cluster/dht/src/dht-common.c
|
|
|
12a457 |
@@ -1605,7 +1605,7 @@ unwind_hashed_and_cached:
|
|
|
12a457 |
DHT_STRIP_PHASE1_FLAGS (&local->stbuf);
|
|
|
12a457 |
dht_set_fixed_dir_stat (&local->postparent);
|
|
|
12a457 |
DHT_STACK_UNWIND (lookup, frame, local->op_ret, local->op_errno,
|
|
|
12a457 |
- local->loc.inode, &local->stbuf, local->xattr,
|
|
|
12a457 |
+ local->inode, &local->stbuf, local->xattr,
|
|
|
12a457 |
&local->postparent);
|
|
|
12a457 |
return 0;
|
|
|
12a457 |
}
|
|
|
12a457 |
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
|
|
|
12a457 |
index a70b3f7..83bbd0a 100644
|
|
|
12a457 |
--- a/xlators/cluster/dht/src/dht-selfheal.c
|
|
|
12a457 |
+++ b/xlators/cluster/dht/src/dht-selfheal.c
|
|
|
12a457 |
@@ -1957,23 +1957,50 @@ dht_selfheal_new_directory (call_frame_t *frame,
|
|
|
12a457 |
dht_selfheal_dir_cbk_t dir_cbk,
|
|
|
12a457 |
dht_layout_t *layout)
|
|
|
12a457 |
{
|
|
|
12a457 |
- dht_local_t *local = NULL;
|
|
|
12a457 |
- int ret = 0;
|
|
|
12a457 |
+ dht_local_t *local = NULL;
|
|
|
12a457 |
+ int ret = 0;
|
|
|
12a457 |
+ inode_t *linked_inode = NULL, *inode = NULL;
|
|
|
12a457 |
+ loc_t *loc = NULL;
|
|
|
12a457 |
+ char pgfid[GF_UUID_BUF_SIZE] = {0};
|
|
|
12a457 |
+ char gfid[GF_UUID_BUF_SIZE] = {0};
|
|
|
12a457 |
+ int32_t op_errno = EIO;
|
|
|
12a457 |
|
|
|
12a457 |
local = frame->local;
|
|
|
12a457 |
|
|
|
12a457 |
+ loc = &local->loc;
|
|
|
12a457 |
+
|
|
|
12a457 |
+ gf_uuid_unparse(local->stbuf.ia_gfid, gfid);
|
|
|
12a457 |
+ gf_uuid_unparse(loc->parent->gfid, pgfid);
|
|
|
12a457 |
+
|
|
|
12a457 |
+ linked_inode = inode_link (loc->inode, loc->parent, loc->name,
|
|
|
12a457 |
+ &local->stbuf);
|
|
|
12a457 |
+ if (!linked_inode) {
|
|
|
12a457 |
+ gf_msg (frame->this->name, GF_LOG_WARNING, 0,
|
|
|
12a457 |
+ DHT_MSG_DIR_SELFHEAL_FAILED,
|
|
|
12a457 |
+ "linking inode failed (%s/%s) => %s",
|
|
|
12a457 |
+ pgfid, loc->name, gfid);
|
|
|
12a457 |
+ ret = -1;
|
|
|
12a457 |
+ goto out;
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+
|
|
|
12a457 |
+ inode = loc->inode;
|
|
|
12a457 |
+ loc->inode = linked_inode;
|
|
|
12a457 |
+ inode_unref (inode);
|
|
|
12a457 |
+
|
|
|
12a457 |
local->selfheal.dir_cbk = dir_cbk;
|
|
|
12a457 |
local->selfheal.layout = dht_layout_ref (frame->this, layout);
|
|
|
12a457 |
|
|
|
12a457 |
dht_layout_sort_volname (layout);
|
|
|
12a457 |
dht_selfheal_layout_new_directory (frame, &local->loc, layout);
|
|
|
12a457 |
|
|
|
12a457 |
+ op_errno = ENOMEM;
|
|
|
12a457 |
ret = dht_selfheal_layout_lock (frame, layout, _gf_true,
|
|
|
12a457 |
dht_selfheal_dir_xattr,
|
|
|
12a457 |
dht_should_heal_layout);
|
|
|
12a457 |
|
|
|
12a457 |
+out:
|
|
|
12a457 |
if (ret < 0) {
|
|
|
12a457 |
- dir_cbk (frame, NULL, frame->this, -1, ENOMEM, NULL);
|
|
|
12a457 |
+ dir_cbk (frame, NULL, frame->this, -1, op_errno, NULL);
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
return 0;
|
|
|
12a457 |
@@ -2011,17 +2038,37 @@ int
|
|
|
12a457 |
dht_selfheal_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk,
|
|
|
12a457 |
loc_t *loc, dht_layout_t *layout)
|
|
|
12a457 |
{
|
|
|
12a457 |
- dht_local_t *local = NULL;
|
|
|
12a457 |
- uint32_t down = 0;
|
|
|
12a457 |
- uint32_t misc = 0;
|
|
|
12a457 |
- int ret = 0;
|
|
|
12a457 |
- xlator_t *this = NULL;
|
|
|
12a457 |
- char gfid[GF_UUID_BUF_SIZE] = {0};
|
|
|
12a457 |
+ dht_local_t *local = NULL;
|
|
|
12a457 |
+ uint32_t down = 0;
|
|
|
12a457 |
+ uint32_t misc = 0;
|
|
|
12a457 |
+ int ret = 0;
|
|
|
12a457 |
+ xlator_t *this = NULL;
|
|
|
12a457 |
+ char pgfid[GF_UUID_BUF_SIZE] = {0};
|
|
|
12a457 |
+ char gfid[GF_UUID_BUF_SIZE] = {0};
|
|
|
12a457 |
+ inode_t *linked_inode = NULL, *inode = NULL;
|
|
|
12a457 |
|
|
|
12a457 |
local = frame->local;
|
|
|
12a457 |
this = frame->this;
|
|
|
12a457 |
|
|
|
12a457 |
- gf_uuid_unparse(loc->gfid, gfid);
|
|
|
12a457 |
+ if (!__is_root_gfid (local->stbuf.ia_gfid)) {
|
|
|
12a457 |
+ gf_uuid_unparse(local->stbuf.ia_gfid, gfid);
|
|
|
12a457 |
+ gf_uuid_unparse(loc->parent->gfid, pgfid);
|
|
|
12a457 |
+
|
|
|
12a457 |
+ linked_inode = inode_link (loc->inode, loc->parent, loc->name,
|
|
|
12a457 |
+ &local->stbuf);
|
|
|
12a457 |
+ if (!linked_inode) {
|
|
|
12a457 |
+ gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
12a457 |
+ DHT_MSG_DIR_SELFHEAL_FAILED,
|
|
|
12a457 |
+ "linking inode failed (%s/%s) => %s",
|
|
|
12a457 |
+ pgfid, loc->name, gfid);
|
|
|
12a457 |
+ ret = 0;
|
|
|
12a457 |
+ goto sorry_no_fix;
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+
|
|
|
12a457 |
+ inode = loc->inode;
|
|
|
12a457 |
+ loc->inode = linked_inode;
|
|
|
12a457 |
+ inode_unref (inode);
|
|
|
12a457 |
+ }
|
|
|
12a457 |
|
|
|
12a457 |
dht_layout_anomalies (this, loc, layout,
|
|
|
12a457 |
&local->selfheal.hole_cnt,
|
|
|
12a457 |
--
|
|
|
12a457 |
1.7.1
|
|
|
12a457 |
|