Skip to content

Commit

Permalink
features/index: Don't delete current xattrop index.
Browse files Browse the repository at this point in the history
Delete the base entry in indices/xattrop only when it is stale.

Change-Id: I675c1510dd8293d068e31b552b0de48f50aac658
BUG: 1101647
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/8119
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
  • Loading branch information
itisravi authored and Pranith Kumar Karampuri committed Jun 20, 2014
1 parent d0547a2 commit eba1fb0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
29 changes: 29 additions & 0 deletions tests/bugs/bug-1101647.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

. $(dirname $0)/../include.rc
. $(dirname $0)/../volume.rc
. $(dirname $0)/../afr.rc

cleanup;

TEST glusterd
TEST pidof glusterd
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2};
TEST $CLI volume start $V0;
TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0
EXPECT_WITHIN 20 "Y" glustershd_up_status

#Create base entry in indices/xattrop and indices/base_indices_holder
echo "Data">$M0/file

TEST $CLI volume heal $V0
#Entries from indices/xattrop and indices/base_indices_holder should not be cleared after a heal.
EXPECT 1 count_sh_entries $B0/$V0"1"
EXPECT 1 count_sh_entries $B0/$V0"2"

TEST kill_brick $V0 $H0 $B0/${V0}2
echo "More data">>$M0/file

EXPECT 1 echo `$CLI volume heal $V0 statistics heal-count|grep "Number of entries:"|head -n1|awk '{print $4}'`

cleanup;
2 changes: 1 addition & 1 deletion tests/bugs/bug-874498.t
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TEST $CLI volume heal $V0


##Expected number of entries are 0 in the .glusterfs/indices/xattrop directory
EXPECT_WITHIN $HEAL_TIMEOUT '0' count_sh_entries $FILEN;
EXPECT_WITHIN $HEAL_TIMEOUT '1' count_sh_entries $FILEN;

TEST $CLI volume stop $V0;
TEST $CLI volume delete $V0;
Expand Down
2 changes: 1 addition & 1 deletion tests/bugs/bug-957877.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
TEST $CLI volume heal $V0

# Wait for self-heal to complete
EXPECT_WITHIN $HEAL_TIMEOUT '0' count_sh_entries $BRICK;
EXPECT_WITHIN $HEAL_TIMEOUT '1' count_sh_entries $BRICK;

TEST getfattr -n "user.foo" $B0/${V0}0/f1;

Expand Down
13 changes: 13 additions & 0 deletions xlators/features/index/src/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ make_file_path (char *base, const char *subdir, const char *filename,
"/%s", filename);
}

static int
is_index_file_current (char *filename, uuid_t priv_index)
{
char *current_index = alloca (strlen ("xattrop-") + GF_UUID_BUF_SIZE);

sprintf (current_index, "xattrop-%s", uuid_utoa(priv_index));
return (!strcmp(filename, current_index));
}

static void
check_delete_stale_index_file (xlator_t *this, char *filename)
{
Expand All @@ -247,6 +256,10 @@ check_delete_stale_index_file (xlator_t *this, char *filename)
index_priv_t *priv = NULL;

priv = this->private;

if (is_index_file_current (filename, priv->index))
return;

make_file_path (priv->index_basepath, XATTROP_SUBDIR,
filename, filepath, sizeof (filepath));
ret = stat (filepath, &st);
Expand Down

0 comments on commit eba1fb0

Please sign in to comment.