diff options
-rw-r--r-- | tests/bugs/bug-767585-gfid.t | 42 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-common.c | 53 |
2 files changed, 50 insertions, 45 deletions
diff --git a/tests/bugs/bug-767585-gfid.t b/tests/bugs/bug-767585-gfid.t new file mode 100644 index 00000000000..0cb6e3cb708 --- /dev/null +++ b/tests/bugs/bug-767585-gfid.t @@ -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; diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 15675d635f4..2538f4c8bfd 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -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; @@ -1977,34 +1978,6 @@ afr_sh_post_nb_entrylk_conflicting_sh_cbk (call_frame_t *frame, xlator_t *this) } 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_parent_entrylk (frame, this, - afr_sh_post_nb_entrylk_conflicting_sh_cbk); - return 0; -} - -static int -afr_self_heal_gfids (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_gfid_sh_cbk); + afr_sh_post_nb_entrylk_missing_entry_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)) { |