blob: 3d91db22c8d713e4de37d6b9aa0fd13d1b2c9ade (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Google, Inc. All Rights Reserved.
#
# FS QA Test ext4/032
#
# Ext4 online resize tests of small and crucial resizes with bigalloc
# feature.
#
. ./common/preamble
_begin_fstest auto quick ioctl resize
BLK_SIZ=4096
CLUSTER_SIZ=4096
IMG_FILE=$SCRATCH_MNT/$seq.fs
IMG_MNT=$SCRATCH_MNT/$seq.mnt
## Num clusters to blocks.
c2b()
{
local clusters=$1
echo $(($clusters * $CLUSTER_SIZ / $BLK_SIZ))
}
ext4_online_resize()
{
## sizes are in number of blocks.
local original_size=$1
local final_size=$2
local check_if_supported=${3:-0}
## Start with a clean image file.
echo "" > ${IMG_FILE}
echo "+++ truncate image file to $final_size" | \
tee -a $seqres.full
$XFS_IO_PROG -f -c "truncate $(($final_size * $BLK_SIZ))" ${IMG_FILE}
LOOP_DEVICE=`_create_loop_device $IMG_FILE`
echo "+++ create fs on image file $original_size" | \
tee -a $seqres.full
${MKFS_PROG} -t ${FSTYP} -F -O bigalloc,resize_inode -C $CLUSTER_SIZ \
-b $BLK_SIZ ${LOOP_DEVICE} $original_size >> \
$seqres.full 2>&1 || _fail "mkfs failed"
echo "+++ mount image file" | tee -a $seqres.full
$MOUNT_PROG -t ${FSTYP} ${LOOP_DEVICE} ${IMG_MNT} > \
/dev/null 2>&1 || _fail "mount failed"
echo "+++ resize fs to $final_size" | tee -a $seqres.full
$RESIZE2FS_PROG -f ${LOOP_DEVICE} $final_size >$tmp.resize2fs 2>&1
if [ $? -ne 0 ]; then
if [ $check_if_supported -eq 1 ]; then
grep -iq "operation not supported" $tmp.resize2fs \
&& _notrun "online resizing not supported with bigalloc"
fi
_fail "resize failed"
fi
cat $tmp.resize2fs >> $seqres.full
echo "+++ umount fs" | tee -a $seqres.full
$UMOUNT_PROG ${IMG_MNT}
echo "+++ check fs" | tee -a $seqres.full
_check_generic_filesystem $LOOP_DEVICE >> $seqres.full 2>&1 || \
_fail "fsck should not fail"
_destroy_loop_device $LOOP_DEVICE && LOOP_DEVICE=
}
# Override the default cleanup function.
_cleanup()
{
cd /
[ -n "$LOOP_DEVICE" ] && _destroy_loop_device $LOOP_DEVICE > /dev/null 2>&1
rm -f $tmp.*
$UMOUNT_PROG ${IMG_MNT} > /dev/null 2>&1
rm -f ${IMG_FILE} > /dev/null 2>&1
}
# get standard environment and checks
# real QA test starts here
_supported_fs ext4
_require_loop
_require_scratch
# We use resize_inode to make sure that block group descriptor table
# can be extended.
_require_scratch_ext4_feature "bigalloc,resize_inode"
_require_command "$RESIZE2FS_PROG" resize2fs
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
mkdir -p $IMG_MNT || _fail "cannot create loopback mount point"
# Check if online resizing with bigalloc is supported by the kernel
ext4_online_resize 4096 8192 1
## We perform resizing to various multiples of block group sizes to
## ensure that we cover maximum edge cases in the kernel code.
for CLUSTER_SIZ in 4096 16384 65536; do
echo "++ set cluster size to $CLUSTER_SIZ" | tee -a $seqres.full
##
## Extend last group tests
##
## Extending a 1/2 block group to a 2/3 block group.
ext4_online_resize $(c2b 16384) $(c2b 24576)
## Extending a 2/3rd block group to one cluster less than a
## full block group.
ext4_online_resize $(c2b 24576) $(c2b 32767)
## Extending a 2/3rd block group to a full block group.
ext4_online_resize $(c2b 24576) $(c2b 32768)
##
## Extend last group and add more block groups.
##
## Extending a 2/3rd block group to 2 block groups.
ext4_online_resize $(c2b 24576) $(c2b 65536)
## Extending a 2/3rd block group to 15 block groups and one
## cluster.
ext4_online_resize $(c2b 24576) $(c2b 491521)
## Extending a 2/3rd block group to 15 and a half block groups.
ext4_online_resize $(c2b 24576) $(c2b 507904)
## Extending a 2/3rd block group to 16 block groups.
ext4_online_resize $(c2b 24576) $(c2b 524288)
## Extending a 2/3rd block group to 160 block groups.
ext4_online_resize $(c2b 24576) $(c2b 5242880)
##
## Convert to meta_bg.
##
## Extending a 2/3rd block group to 1280 block groups.
ext4_online_resize $(c2b 24576) $(c2b 41943040)
done
status=0
exit
|