diff options
author | Ravishankar N <ravishankar@redhat.com> | 2015-10-21 21:05:46 +0530 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2015-10-28 06:39:42 -0700 |
commit | 641b3a9164227db52df1aab05795c90d06b315f2 (patch) | |
tree | e2a55cb4aed7e6376f6a6da55c6493247d99c366 /tests/basic | |
parent | 8e5a7632edd040031e4942134331172805bc8eff (diff) |
afr: write zeros to sink for non-sparse files
Problem: If a file is created with zeroes ('dd', 'fallocate' etc.) when
a brick is down, the self-heal does not write the zeroes to the sink
after it comes up. Consequenty, there is a mismatch in disk-usage
amongst the bricks of the replica.
Fix: If we definitely know that the file is not sparse, then write the
zeroes to the sink even if the checksums match.
Change-Id: Ic739b3da5dbf47d99801c0e1743bb13aeb3af864
BUG: 1272460
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/12371
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'tests/basic')
-rw-r--r-- | tests/basic/afr/sparse-file-self-heal.t | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/basic/afr/sparse-file-self-heal.t b/tests/basic/afr/sparse-file-self-heal.t index 026ada7fe5e..d540ef786d1 100644 --- a/tests/basic/afr/sparse-file-self-heal.t +++ b/tests/basic/afr/sparse-file-self-heal.t @@ -2,6 +2,8 @@ #This file checks if self-heal of files with holes is working properly or not #bigger is 2M, big is 1M, small is anything less +#Also tests if non-sparse files with zeroes in it are healed correctly w.r.t +#disk usage. . $(dirname $0)/../../include.rc . $(dirname $0)/../../volume.rc @@ -43,6 +45,9 @@ big2bigger_md5sum=$(md5sum $M0/big2bigger | awk '{print $1}') TEST dd if=/dev/urandom of=$M0/FILE count=1 bs=131072 TEST truncate -s 1G $M0/FILE +#Create a non-sparse file containing zeroes. +TEST dd if=/dev/zero of=$M0/zeroedfile bs=1024 count=1024 + $CLI volume start $V0 force EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0 EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status @@ -79,6 +84,13 @@ EXPECT "1" has_holes $B0/${V0}0/big2bigger #Check that self-heal has not written 0s to sink and made it non-sparse. USED_KB=`du -s $B0/${V0}0/FILE|cut -f1` TEST [ $USED_KB -lt 1000000 ] + +#Check that the non-sparse file consumes the same disk space in both bricks post +#self-heal +USED_KB1=`du -s $B0/${V0}0/zeroedfile|cut -f1` +USED_KB2=`du -s $B0/${V0}1/zeroedfile|cut -f1` +TEST [ $USED_KB1 -eq $USED_KB2 ] + TEST rm -f $M0/* #check the same tests with diff self-heal @@ -113,6 +125,9 @@ big2bigger_md5sum=$(md5sum $M0/big2bigger | awk '{print $1}') TEST dd if=/dev/urandom of=$M0/FILE count=1 bs=131072 TEST truncate -s 1G $M0/FILE +#Create a non-sparse file containing zeroes. +TEST dd if=/dev/zero of=$M0/zeroedfile bs=1024 count=1024 + $CLI volume start $V0 force EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0 EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status @@ -145,4 +160,10 @@ EXPECT "0" has_holes $B0/${V0}0/small USED_KB=`du -s $B0/${V0}0/FILE|cut -f1` TEST [ $USED_KB -lt 1000000 ] +#Check that the non-sparse file consumes the same disk space in both bricks post +#self-heal. +USED_KB1=`du -s $B0/${V0}0/zeroedfile|cut -f1` +USED_KB2=`du -s $B0/${V0}1/zeroedfile|cut -f1` +TEST [ $USED_KB1 -eq $USED_KB2 ] + cleanup |