cluster/afr: Club missing entry, missing gfid self-heals

Problem:
gfid-self-heal always assigns the gfid(GFID-1) it gets from lookup.
Between the time of lookup to triggering the gfid-self-heal the
entry could have changed. Now lets say there is a case where
one of the files of the replica subolumes already has a gfid
(GFID-2) and the other does not. In that case healing should
happen with GFID-2 instead of GFID-1.

Fix:
Missing-entry-self-heal already handles all these cases. So removed
separate handling of gfid-self-heal.

Change-Id: Ie96261e9036c8f3cb4cad89347f9bf7b681cdc1a
BUG: 767585
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/2670
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
Pranith Kumar K 2013-03-01 15:05:04 +05:30 committed by Vijay Bellur
parent d3e3a849dd
commit 273a42a421
2 changed files with 50 additions and 45 deletions

View File

@ -0,0 +1,42 @@
#!/bin/bash
. $(dirname $0)/../include.rc
. $(dirname $0)/../volume.rc
#Test cases to perform gfid-self-heal
#file 'a' should be assigned a fresh gfid
#file 'b' should be healed with gfid1 from brick1
#file 'c' should be healed with gfid2 from brick2
gfid1="0x8428b7193a764bf8be8046fb860b8993"
gfid2="0x85ad91afa2f74694bf52c3326d048209"
cleanup;
TEST glusterd
TEST pidof glusterd
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1
TEST $CLI volume start $V0
TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 --direct-io-mode=enable
touch $B0/${V0}0/a $B0/${V0}1/a
touch $B0/${V0}0/b $B0/${V0}1/b
touch $B0/${V0}0/c $B0/${V0}1/c
TEST setfattr -n trusted.gfid -v $gfid1 $B0/${V0}0/b
TEST setfattr -n trusted.gfid -v $gfid2 $B0/${V0}1/c
cd $M0
TEST ls -l a
TEST ls -l b
TEST ls -l c
TEST gf_get_gfid_xattr $B0/${V0}0/a
TEST gf_get_gfid_xattr $B0/${V0}1/a
EXPECT "$gfid1" gf_get_gfid_xattr $B0/${V0}0/b
EXPECT "$gfid1" gf_get_gfid_xattr $B0/${V0}1/b
EXPECT "$gfid2" gf_get_gfid_xattr $B0/${V0}0/c
EXPECT "$gfid2" gf_get_gfid_xattr $B0/${V0}1/c
cleanup;

View File

@ -1948,7 +1948,8 @@ afr_sh_common_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
int
afr_sh_post_nb_entrylk_conflicting_sh_cbk (call_frame_t *frame, xlator_t *this)
afr_sh_post_nb_entrylk_missing_entry_sh_cbk (call_frame_t *frame,
xlator_t *this)
{
afr_internal_lock_t *int_lock = NULL;
afr_local_t *local = NULL;
@ -1976,34 +1977,6 @@ afr_sh_post_nb_entrylk_conflicting_sh_cbk (call_frame_t *frame, xlator_t *this)
return 0;
}
int
afr_sh_post_nb_entrylk_gfid_sh_cbk (call_frame_t *frame, xlator_t *this)
{
afr_internal_lock_t *int_lock = NULL;
afr_local_t *local = NULL;
afr_self_heal_t *sh = NULL;
local = frame->local;
sh = &local->self_heal;
int_lock = &local->internal_lock;
if (int_lock->lock_op_ret < 0) {
gf_log (this->name, GF_LOG_INFO,
"Non blocking entrylks failed.");
afr_sh_missing_entries_done (frame, this);
} else {
gf_log (this->name, GF_LOG_DEBUG,
"Non blocking entrylks done. Proceeding to FOP");
afr_sh_common_lookup (frame, this, &local->loc,
afr_sh_missing_entries_lookup_done,
sh->sh_gfid_req, AFR_LOOKUP_FAIL_CONFLICTS|
AFR_LOOKUP_FAIL_MISSING_GFIDS,
NULL);
}
return 0;
}
int
afr_sh_entrylk (call_frame_t *frame, xlator_t *this, loc_t *loc,
char *base_name, afr_lock_cbk_t lock_cbk)
@ -2066,22 +2039,15 @@ out:
}
static int
afr_self_heal_conflicting_entries (call_frame_t *frame, xlator_t *this)
afr_self_heal_missing_entries (call_frame_t *frame, xlator_t *this)
{
afr_self_heal_parent_entrylk (frame, this,
afr_sh_post_nb_entrylk_conflicting_sh_cbk);
afr_sh_post_nb_entrylk_missing_entry_sh_cbk);
return 0;
}
static int
afr_self_heal_gfids (call_frame_t *frame, xlator_t *this)
{
afr_self_heal_parent_entrylk (frame, this,
afr_sh_post_nb_entrylk_gfid_sh_cbk);
return 0;
}
afr_local_t *afr_local_copy (afr_local_t *l, xlator_t *this)
afr_local_t*
afr_local_copy (afr_local_t *l, xlator_t *this)
{
afr_private_t *priv = NULL;
afr_local_t *lc = NULL;
@ -2337,11 +2303,8 @@ afr_self_heal (call_frame_t *frame, xlator_t *this, inode_t *inode)
}
FRAME_SU_DO (sh_frame, afr_local_t);
if (sh->do_missing_entry_self_heal) {
afr_self_heal_conflicting_entries (sh_frame, this);
} else if (sh->do_gfid_self_heal) {
GF_ASSERT (!uuid_is_null (sh->sh_gfid_req));
afr_self_heal_gfids (sh_frame, this);
if (sh->do_missing_entry_self_heal || sh->do_gfid_self_heal) {
afr_self_heal_missing_entries (sh_frame, this);
} else {
loc = &sh_local->loc;
if (uuid_is_null (loc->inode->gfid) && uuid_is_null (loc->gfid)) {