2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Lakshmipathi.G All Rights Reserved.
9 # 1) create ext3 filesystem & populate it.
10 # 2) upgrade ext3 filesystem to ext4.
12 # 4) source has combination of non-extent and extent files.
13 # 5) convert it to btrfs, mount and verify contents.
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
33 # remove previous $seqres.full before test
36 # real QA test starts here
38 # Modify as appropriate.
41 _require_scratch_nocheck
43 _require_command "$BTRFS_CONVERT_PROG" btrfs-convert
44 _require_command "$MKFS_EXT4_PROG" mkfs.ext4
45 _require_command "$E2FSCK_PROG" e2fsck
46 _require_command "$TUNE2FS_PROG" tune2fs
50 BLOCK_SIZE=`_get_block_size $TEST_DIR`
51 EXT_MD5SUM="$tmp.ext43"
52 BTRFS_MD5SUM="$tmp.btrfs"
57 args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $data_path`
58 echo "Run fsstress $args" >>$seqres.full
59 $FSSTRESS_PROG $args >/dev/null 2>&1 &
64 # Create & populate an ext3 filesystem
65 $MKFS_EXT4_PROG -F -t ext3 -b $BLOCK_SIZE $SCRATCH_DEV > $seqres.full 2>&1 || \
66 _notrun "Could not create ext3 filesystem"
68 # mount and populate non-extent file
69 mount -t ext3 $SCRATCH_DEV $SCRATCH_MNT
70 populate_data "$SCRATCH_MNT/ext3_ext4_data/ext3"
74 $TUNE2FS_PROG -O extents,uninit_bg,dir_index $SCRATCH_DEV >> $seqres.full 2>&1
75 # After Conversion, its highly recommended to run e2fsck.
76 $E2FSCK_PROG -fyD $SCRATCH_DEV >> $seqres.full 2>&1
78 # mount and populate extent file
79 mount -t ext4 $SCRATCH_DEV $SCRATCH_MNT
80 populate_data "$SCRATCH_MNT/ext3_ext4_data/ext4"
82 # Compute md5 of ext3,ext4 files.
83 find "$SCRATCH_MNT/ext3_ext4_data" -type f -fprint "$EXT_MD5SUM"
84 sort "$EXT_MD5SUM" -o "$EXT_MD5SUM"
87 # Convert non-extent & extent data to btrfs, mount it, verify the data
88 $BTRFS_CONVERT_PROG $SCRATCH_DEV >> $seqres.full 2>&1 || \
89 _fail "btrfs-convert failed"
90 _try_scratch_mount || _fail "Could not mount new btrfs fs"
92 # Compute md5 for converted files.
93 find "$SCRATCH_MNT/ext3_ext4_data" -type f -fprint "$BTRFS_MD5SUM"
94 sort "$BTRFS_MD5SUM" -o "$BTRFS_MD5SUM"
96 # Compare two md5sum files.
97 btrfs_perm=`md5sum "$BTRFS_MD5SUM" | cut -f1 -d' '`
98 ext_perm=`md5sum "$EXT_MD5SUM" | cut -f1 -d' '`
100 if [ "$btrfs_perm" != "$ext_perm" ];then
101 echo "md5sum mismatch"
105 echo "Silence is golden"