|
|
256ebe |
From 884ba13ee47888b5de9b6d6acaf051e895f55053 Mon Sep 17 00:00:00 2001
|
|
|
256ebe |
From: N Balachandran <nbalacha@redhat.com>
|
|
|
256ebe |
Date: Wed, 10 Apr 2019 14:28:55 +0530
|
|
|
256ebe |
Subject: [PATCH 127/141] cluster/dht: Refactor dht lookup functions
|
|
|
256ebe |
|
|
|
256ebe |
Part 2: Modify dht_revalidate_cbk to call
|
|
|
256ebe |
dht_selfheal_directory instead of separate calls
|
|
|
256ebe |
to heal attrs and xattrs.
|
|
|
256ebe |
|
|
|
256ebe |
upstream: https://review.gluster.org/#/c/glusterfs/+/22542/
|
|
|
256ebe |
|
|
|
256ebe |
> Change-Id: Id41ac6c4220c2c35484812bbfc6157fc3c86b142
|
|
|
256ebe |
> updates: bz#1590385
|
|
|
256ebe |
|
|
|
256ebe |
Change-Id: Id53962306dd142efc741de838b585fa5c78f9b1f
|
|
|
256ebe |
BUG:1703897
|
|
|
256ebe |
Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
256ebe |
Reviewed-on: https://code.engineering.redhat.com/gerrit/169038
|
|
|
256ebe |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
256ebe |
Reviewed-by: Susant Palai <spalai@redhat.com>
|
|
|
256ebe |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
256ebe |
---
|
|
|
256ebe |
xlators/cluster/dht/src/dht-common.c | 104 ++++++++++-------------------------
|
|
|
256ebe |
1 file changed, 30 insertions(+), 74 deletions(-)
|
|
|
256ebe |
|
|
|
256ebe |
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
|
|
|
256ebe |
index d3e900c..183872f 100644
|
|
|
256ebe |
--- a/xlators/cluster/dht/src/dht-common.c
|
|
|
256ebe |
+++ b/xlators/cluster/dht/src/dht-common.c
|
|
|
256ebe |
@@ -1365,7 +1365,6 @@ dht_lookup_dir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
256ebe |
if (local->inode == NULL)
|
|
|
256ebe |
local->inode = inode_ref(inode);
|
|
|
256ebe |
|
|
|
256ebe |
- /* This could be a problem */
|
|
|
256ebe |
dht_iatt_merge(this, &local->stbuf, stbuf);
|
|
|
256ebe |
dht_iatt_merge(this, &local->postparent, postparent);
|
|
|
256ebe |
|
|
|
256ebe |
@@ -1509,8 +1508,6 @@ dht_revalidate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
256ebe |
int is_dir = 0;
|
|
|
256ebe |
int is_linkfile = 0;
|
|
|
256ebe |
int follow_link = 0;
|
|
|
256ebe |
- call_frame_t *copy = NULL;
|
|
|
256ebe |
- dht_local_t *copy_local = NULL;
|
|
|
256ebe |
char gfid[GF_UUID_BUF_SIZE] = {0};
|
|
|
256ebe |
uint32_t vol_commit_hash = 0;
|
|
|
256ebe |
xlator_t *subvol = NULL;
|
|
|
256ebe |
@@ -1538,17 +1535,16 @@ dht_revalidate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
256ebe |
|
|
|
256ebe |
gf_uuid_unparse(local->loc.gfid, gfid);
|
|
|
256ebe |
|
|
|
256ebe |
+ gf_msg_debug(this->name, op_errno,
|
|
|
256ebe |
+ "%s: revalidate lookup on %s returned op_ret %d",
|
|
|
256ebe |
+ local->loc.path, prev->name, op_ret);
|
|
|
256ebe |
+
|
|
|
256ebe |
LOCK(&frame->lock);
|
|
|
256ebe |
{
|
|
|
256ebe |
if (gf_uuid_is_null(local->gfid)) {
|
|
|
256ebe |
memcpy(local->gfid, local->loc.gfid, 16);
|
|
|
256ebe |
}
|
|
|
256ebe |
|
|
|
256ebe |
- gf_msg_debug(this->name, op_errno,
|
|
|
256ebe |
- "revalidate lookup of %s "
|
|
|
256ebe |
- "returned with op_ret %d",
|
|
|
256ebe |
- local->loc.path, op_ret);
|
|
|
256ebe |
-
|
|
|
256ebe |
if (op_ret == -1) {
|
|
|
256ebe |
local->op_errno = op_errno;
|
|
|
256ebe |
|
|
|
256ebe |
@@ -1580,6 +1576,8 @@ dht_revalidate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
256ebe |
local->loc.path);
|
|
|
256ebe |
|
|
|
256ebe |
local->need_lookup_everywhere = 1;
|
|
|
256ebe |
+ } else if (IA_ISDIR(local->loc.inode->ia_type)) {
|
|
|
256ebe |
+ local->need_selfheal = 1;
|
|
|
256ebe |
}
|
|
|
256ebe |
}
|
|
|
256ebe |
|
|
|
256ebe |
@@ -1638,15 +1636,16 @@ dht_revalidate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
256ebe |
(local->stbuf.ia_uid != stbuf->ia_uid) ||
|
|
|
256ebe |
is_permission_different(&local->stbuf.ia_prot,
|
|
|
256ebe |
&stbuf->ia_prot)) {
|
|
|
256ebe |
- local->need_selfheal = 1;
|
|
|
256ebe |
+ local->need_attrheal = 1;
|
|
|
256ebe |
}
|
|
|
256ebe |
}
|
|
|
256ebe |
|
|
|
256ebe |
if (!dict_get(xattr, conf->mds_xattr_key)) {
|
|
|
256ebe |
gf_msg_debug(this->name, 0,
|
|
|
256ebe |
- "internal xattr %s is not present"
|
|
|
256ebe |
- " on path %s gfid is %s ",
|
|
|
256ebe |
- conf->mds_xattr_key, local->loc.path, gfid);
|
|
|
256ebe |
+ "%s: internal xattr %s is not present"
|
|
|
256ebe |
+ " on subvol %s(gfid is %s)",
|
|
|
256ebe |
+ local->loc.path, conf->mds_xattr_key, prev->name,
|
|
|
256ebe |
+ gfid);
|
|
|
256ebe |
} else {
|
|
|
256ebe |
check_mds = dht_dict_get_array(xattr, conf->mds_xattr_key,
|
|
|
256ebe |
mds_xattr_val, 1, &errst);
|
|
|
256ebe |
@@ -1734,71 +1733,28 @@ unlock:
|
|
|
256ebe |
local->need_xattr_heal = 0;
|
|
|
256ebe |
|
|
|
256ebe |
if (IA_ISDIR(local->stbuf.ia_type)) {
|
|
|
256ebe |
- /* Code to update all extended attributed from hashed
|
|
|
256ebe |
- subvol to local->xattr and call heal code to heal
|
|
|
256ebe |
- custom xattr from hashed subvol to non-hashed subvol
|
|
|
256ebe |
- */
|
|
|
256ebe |
- if (local->need_xattr_heal && (local->mds_xattr)) {
|
|
|
256ebe |
- dht_dir_set_heal_xattr(this, local, local->xattr,
|
|
|
256ebe |
- local->mds_xattr, NULL, NULL);
|
|
|
256ebe |
- dict_unref(local->mds_xattr);
|
|
|
256ebe |
- local->mds_xattr = NULL;
|
|
|
256ebe |
- local->need_xattr_heal = 0;
|
|
|
256ebe |
- ret = dht_dir_xattr_heal(this, local);
|
|
|
256ebe |
- if (ret)
|
|
|
256ebe |
- gf_msg(this->name, GF_LOG_ERROR, ret,
|
|
|
256ebe |
- DHT_MSG_DIR_XATTR_HEAL_FAILED,
|
|
|
256ebe |
- "xattr heal failed for directory %s "
|
|
|
256ebe |
- " gfid %s ",
|
|
|
256ebe |
- local->loc.path, gfid);
|
|
|
256ebe |
- } else {
|
|
|
256ebe |
- /* Call function to save hashed subvol on inode
|
|
|
256ebe |
- ctx if internal mds xattr is not present and
|
|
|
256ebe |
- all subvols are up
|
|
|
256ebe |
- */
|
|
|
256ebe |
- if (inode && !__is_root_gfid(inode->gfid) && (!local->op_ret))
|
|
|
256ebe |
- (void)dht_common_mark_mdsxattr(frame, NULL, 1);
|
|
|
256ebe |
- }
|
|
|
256ebe |
- }
|
|
|
256ebe |
- if (local->need_selfheal) {
|
|
|
256ebe |
- local->need_selfheal = 0;
|
|
|
256ebe |
- if (!__is_root_gfid(inode->gfid)) {
|
|
|
256ebe |
- gf_uuid_copy(local->gfid, local->mds_stbuf.ia_gfid);
|
|
|
256ebe |
- local->stbuf.ia_gid = local->mds_stbuf.ia_gid;
|
|
|
256ebe |
- local->stbuf.ia_uid = local->mds_stbuf.ia_uid;
|
|
|
256ebe |
- local->stbuf.ia_prot = local->mds_stbuf.ia_prot;
|
|
|
256ebe |
- } else {
|
|
|
256ebe |
- gf_uuid_copy(local->gfid, local->stbuf.ia_gfid);
|
|
|
256ebe |
- local->stbuf.ia_gid = local->prebuf.ia_gid;
|
|
|
256ebe |
- local->stbuf.ia_uid = local->prebuf.ia_uid;
|
|
|
256ebe |
- local->stbuf.ia_prot = local->prebuf.ia_prot;
|
|
|
256ebe |
- }
|
|
|
256ebe |
+ if (!__is_root_gfid(local->loc.inode->gfid) &&
|
|
|
256ebe |
+ (!dict_get(local->xattr, conf->mds_xattr_key)))
|
|
|
256ebe |
+ local->need_selfheal = 1;
|
|
|
256ebe |
|
|
|
256ebe |
- copy = create_frame(this, this->ctx->pool);
|
|
|
256ebe |
- if (copy) {
|
|
|
256ebe |
- copy_local = dht_local_init(copy, &local->loc, NULL, 0);
|
|
|
256ebe |
- if (!copy_local) {
|
|
|
256ebe |
- DHT_STACK_DESTROY(copy);
|
|
|
256ebe |
- goto cont;
|
|
|
256ebe |
- }
|
|
|
256ebe |
- copy_local->stbuf = local->stbuf;
|
|
|
256ebe |
- copy_local->mds_stbuf = local->mds_stbuf;
|
|
|
256ebe |
- copy_local->mds_subvol = local->mds_subvol;
|
|
|
256ebe |
- copy->local = copy_local;
|
|
|
256ebe |
- FRAME_SU_DO(copy, dht_local_t);
|
|
|
256ebe |
- ret = synctask_new(this->ctx->env, dht_dir_attr_heal,
|
|
|
256ebe |
- dht_dir_attr_heal_done, copy, copy);
|
|
|
256ebe |
- if (ret) {
|
|
|
256ebe |
- gf_msg(this->name, GF_LOG_ERROR, ENOMEM,
|
|
|
256ebe |
- DHT_MSG_DIR_ATTR_HEAL_FAILED,
|
|
|
256ebe |
- "Synctask creation failed to heal attr "
|
|
|
256ebe |
- "for path %s gfid %s ",
|
|
|
256ebe |
- local->loc.path, local->gfid);
|
|
|
256ebe |
- DHT_STACK_DESTROY(copy);
|
|
|
256ebe |
+ if (dht_needs_selfheal(frame, this)) {
|
|
|
256ebe |
+ if (!__is_root_gfid(local->loc.inode->gfid)) {
|
|
|
256ebe |
+ local->stbuf.ia_gid = local->mds_stbuf.ia_gid;
|
|
|
256ebe |
+ local->stbuf.ia_uid = local->mds_stbuf.ia_uid;
|
|
|
256ebe |
+ local->stbuf.ia_prot = local->mds_stbuf.ia_prot;
|
|
|
256ebe |
+ } else {
|
|
|
256ebe |
+ local->stbuf.ia_gid = local->prebuf.ia_gid;
|
|
|
256ebe |
+ local->stbuf.ia_uid = local->prebuf.ia_uid;
|
|
|
256ebe |
+ local->stbuf.ia_prot = local->prebuf.ia_prot;
|
|
|
256ebe |
}
|
|
|
256ebe |
+
|
|
|
256ebe |
+ layout = local->layout;
|
|
|
256ebe |
+ dht_selfheal_directory(frame, dht_lookup_selfheal_cbk,
|
|
|
256ebe |
+ &local->loc, layout);
|
|
|
256ebe |
+ return 0;
|
|
|
256ebe |
}
|
|
|
256ebe |
}
|
|
|
256ebe |
- cont:
|
|
|
256ebe |
+
|
|
|
256ebe |
if (local->layout_mismatch) {
|
|
|
256ebe |
/* Found layout mismatch in the directory, need to
|
|
|
256ebe |
fix this in the inode context */
|
|
|
256ebe |
@@ -1814,7 +1770,7 @@ unlock:
|
|
|
256ebe |
dht_layout_unref(this, local->layout);
|
|
|
256ebe |
local->layout = NULL;
|
|
|
256ebe |
|
|
|
256ebe |
- /* We know that current cached subvol is no more
|
|
|
256ebe |
+ /* We know that current cached subvol is no longer
|
|
|
256ebe |
valid, get the new one */
|
|
|
256ebe |
local->cached_subvol = NULL;
|
|
|
256ebe |
if (local->xattr_req) {
|
|
|
256ebe |
--
|
|
|
256ebe |
1.8.3.1
|
|
|
256ebe |
|