1 test_description="test prezeroed storage metadata allocation"
8 if test "$(id -u)" -ne 0 ; then
9 echo "$test_name: $test_description: skipped (not root)"
10 elif ! command -v losetup >/dev/null ; then
11 echo "$test_name: $test_description: skipped (no losetup)"
13 dd if=/dev/zero of=$TMPFILE bs=1 count=0 seek=$FILE_SIZE >> $LOG 2>&1
15 LOOP=$(losetup --show -f $TMPFILE)
16 if [ ! -b "$LOOP" ]; then
17 echo "$test_name: $DESCRIPTION: skipped (no loop devices)"
22 cmd="$MKE2FS -o Linux -t ext4 -b 4096"
23 echo "$cmd $LOOP" >> $LOG
24 $cmd $LOOP >> $LOG 2>&1
27 stat $TMPFILE >> $LOG 2>&1
28 BLOCKS_DEF=$(stat -c "%b" $TMPFILE)
31 dd if=/dev/zero of=$TMPFILE bs=1 count=0 seek=$FILE_SIZE >> $LOG 2>&1
32 LOOP=$(losetup --show -f $TMPFILE)
33 if [ ! -b "$LOOP" ]; then
34 echo "$test_name: $DESCRIPTION: skipped (no loop devices)"
39 cmd+=" -E assume_storage_prezeroed=1"
40 echo "$cmd $LOOP" >> $LOG
41 $cmd $TMPFILE >> $LOG 2>&1
44 stat $TMPFILE >> $LOG 2>&1
45 BLOCKS_ASP=$(stat -c "%b" $TMPFILE)
47 echo "blocks_dev: $BLOCKS_DEF blocks_asp: ${BLOCKS_ASP}" >> $LOG
49 # should use less than 1/20 of the blocks with assume_storage_prezeroed
50 if (( $BLOCKS_DEF > $BLOCKS_ASP * 40 )) ; then
51 echo "$test_name: $test_description: ok"
54 echo "$test_name: $test_description: failed"
55 cat $LOG > $test_name.failed
56 diff $EXP $OUT >> $test_name.failed
59 unset LOG OUT EXP FILE_SIZE LOOP