glusterfs
76 строк · 1.8 Кб
1#!/bin/bash
2#
3# Bug <915554>
4#
5# This test checks for a condition where a rebalance migrates a file and does
6# not preserve the original file size. This can occur due to hole preservation
7# logic in the file migration code. If a file size is aligned to a disk sector
8# boundary (512b) and the tail portion of the file is zero-filled, the file
9# may end up truncated to the end of the last data region in the file.
10#
11###
12
13. $(dirname $0)/../../include.rc
14. $(dirname $0)/../../dht.rc
15. $(dirname $0)/../../volume.rc
16
17cleanup;
18
19TEST glusterd
20TEST pidof glusterd
21
22BRICK_COUNT=3
23# create, start and mount a two brick DHT volume
24TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2
25TEST $CLI volume start $V0
26
27TEST glusterfs --attribute-timeout=0 --entry-timeout=0 --gid-timeout=0 -s $H0 --volfile-id $V0 $M0;
28
29i=1
30# Write some data to a file and extend such that the file is sparse to a sector
31# aligned boundary.
32echo test > $M0/$i
33TEST truncate -s 1M $M0/$i
34
35# cache the original size
36SIZE1=`stat -c %s $M0/$i`
37
38# rename till file gets a linkfile
39
40while [ $i -ne 0 ]
41do
42test=`mv $M0/$i $M0/$(( $i+1 )) 2>/dev/null`
43if [ $? -ne 0 ]
44then
45echo "rename failed"
46break
47fi
48let i++
49file_has_linkfile $i
50has_link=$?
51if [ $has_link -eq 2 ]
52then
53break;
54fi
55done
56
57# start a rebalance (force option to overide checks) to trigger migration of
58# file
59
60TEST $CLI volume rebalance $V0 start force
61
62# check if rebalance has completed for up to 15 secs
63
64EXPECT_WITHIN $REBALANCE_TIMEOUT "0" rebalance_completed
65
66# validate the file size after the migration
67SIZE2=`stat -c %s $M0/$i`
68
69TEST [ $SIZE1 -eq $SIZE2 ]
70
71TEST rm -f $M0/$i
72EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
73TEST $CLI volume stop $V0
74TEST $CLI volume delete $V0
75
76cleanup;
77