diff options
author | Ravishankar N <ravishankar@redhat.com> | 2015-10-21 21:05:46 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-10-29 01:40:19 -0700 |
commit | 50646435b4076cfb30d7ebabf2d688f91c957cec (patch) | |
tree | 9ee11abc73bdb94492d42b0ed36e0ae11cf37ff2 /tests/basic | |
parent | 0ce29bbd6a1cc459d4f4ffc50a4658988ef52039 (diff) |
afr: write zeros to sink for non-sparse files
Backport of http://review.gluster.org/#/c/12371/
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: 1275921
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/12436
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.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 4101e6d1db7..a8fc095ad26 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 @@ -74,6 +79,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 @@ -108,6 +120,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 @@ -135,4 +150,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 |