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.
40 _require_scratch_nocheck
42 _require_command "$BTRFS_CONVERT_PROG" btrfs-convert
43 _require_command "$MKFS_EXT4_PROG" mkfs.ext4
44 _require_command "$E2FSCK_PROG" e2fsck
45 _require_command "$TUNE2FS_PROG" tune2fs
49 BLOCK_SIZE=`_get_block_size $TEST_DIR`
50 EXT_MD5SUM="$tmp.ext43"
51 BTRFS_MD5SUM="$tmp.btrfs"
56 args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $data_path`
57 echo "Run fsstress $args" >>$seqres.full
58 $FSSTRESS_PROG $args >/dev/null 2>&1 &
63 # Create & populate an ext3 filesystem
64 $MKFS_EXT4_PROG -F -t ext3 -b $BLOCK_SIZE $SCRATCH_DEV > $seqres.full 2>&1 || \
65 _notrun "Could not create ext3 filesystem"
67 # mount and populate non-extent file
68 mount -t ext3 $SCRATCH_DEV $SCRATCH_MNT
69 populate_data "$SCRATCH_MNT/ext3_ext4_data/ext3"
73 $TUNE2FS_PROG -O extents,uninit_bg,dir_index $SCRATCH_DEV >> $seqres.full 2>&1
74 # After Conversion, its highly recommended to run e2fsck.
75 $E2FSCK_PROG -fyD $SCRATCH_DEV >> $seqres.full 2>&1
77 # mount and populate extent file
78 mount -t ext4 $SCRATCH_DEV $SCRATCH_MNT
79 populate_data "$SCRATCH_MNT/ext3_ext4_data/ext4"
81 # Compute md5 of ext3,ext4 files.
82 find "$SCRATCH_MNT/ext3_ext4_data" -type f -fprint "$EXT_MD5SUM"
83 sort "$EXT_MD5SUM" -o "$EXT_MD5SUM"
86 # Convert non-extent & extent data to btrfs, mount it, verify the data
87 $BTRFS_CONVERT_PROG $SCRATCH_DEV >> $seqres.full 2>&1 || \
88 _fail "btrfs-convert failed"
89 _try_scratch_mount || _fail "Could not mount new btrfs fs"
91 # Compute md5 for converted files.
92 find "$SCRATCH_MNT/ext3_ext4_data" -type f -fprint "$BTRFS_MD5SUM"
93 sort "$BTRFS_MD5SUM" -o "$BTRFS_MD5SUM"
95 # Compare two md5sum files.
96 btrfs_perm=`md5sum "$BTRFS_MD5SUM" | cut -f1 -d' '`
97 ext_perm=`md5sum "$EXT_MD5SUM" | cut -f1 -d' '`
99 if [ "$btrfs_perm" != "$ext_perm" ];then
100 echo "md5sum mismatch"
104 echo "Silence is golden"