msg="$2"
shift 3
echo " [TEST/conv] $msg, btrfs" "${features:-defaults}"
- echo "creating ext image with: $@" >> "$RESULTS"
+ echo "creating test image with: $@" >> "$RESULTS"
}
# prepare TEST_DEV before conversion, create filesystem and mount it, image
# $2+: free form, command to create the filesystem, with appended -F
convert_test_prep_fs() {
local fstype
+ local force
+ local mountopts
fstype="$1"
shift
run_check truncate -s 0 "$TEST_DEV"
# 256MB is the smallest acceptable btrfs image.
run_check truncate -s 512M "$TEST_DEV"
- run_check "$@" -F "$TEST_DEV"
+ force=
+ mountopts=
+ case "$fstype" in
+ ext[234])
+ force=-F ;;
+ reiserfs)
+ force=-ff
+ mountopts="-o acl,user_xattr,attrs" ;;
+ *)
+ _fail "unknown filesystem to convert: $fstype"
+ esac
+ run_check "$@" $force "$TEST_DEV"
# create a file to check btrfs-convert can convert regular file correct
- run_check_mount_convert_dev "$fstype"
+ run_check_mount_convert_dev "$fstype" $mountopts
# create a file inside the fs before convert, to make sure there is
# data covering btrfs backup superblock range (64M)
--- /dev/null
+#!/bin/bash
+
+source "$TOP/tests/common"
+source "$TOP/tests/common.convert"
+
+setup_root_helper
+prepare_test_dev 512M
+check_prereq btrfs-convert
+
+for feature in '' 'extref' 'skinny-metadata' 'no-holes'; do
+ convert_test reiserfs "$feature" "reiserfs 4k nodesize" 4096 mkreiserfs -b 4096
+ convert_test reiserfs "$feature" "reiserfs 8k nodesize" 8192 mkreiserfs -b 4096
+ convert_test reiserfs "$feature" "reiserfs 16k nodesize" 16384 mkreiserfs -b 4096
+ convert_test reiserfs "$feature" "reiserfs 32k nodesize" 32768 mkreiserfs -b 4096
+ convert_test reiserfs "$feature" "reiserfs 64k nodesize" 65536 mkreiserfs -b 4096
+done
--- /dev/null
+#!/bin/bash
+# create a base image, convert to btrfs, remove all files, rollback the reiserfs image
+
+source "$TOP/tests/common"
+source "$TOP/tests/common.convert"
+
+setup_root_helper
+prepare_test_dev 512M
+check_prereq btrfs-convert
+
+# simple wrapper for a convert test
+# $1: btrfs features, argument to -O
+# $2: message
+# $3: nodesize value
+# $4 + rest: command to create the reiserfs image
+do_test() {
+ local features
+ local msg
+ local nodesize
+ local CHECKSUMTMP
+ local here
+
+ features="$1"
+ msg="$2"
+ nodesize="$3"
+ shift 3
+ convert_test_preamble "$features" "$msg" "$nodesize" "$@"
+ convert_test_prep_fs reiserfs "$@"
+ populate_fs
+ CHECKSUMTMP=$(mktemp --tmpdir btrfs-progs-convert.XXXXXXXXXX)
+ convert_test_gen_checksums "$CHECKSUMTMP"
+
+ run_check_umount_test_dev
+
+ convert_test_do_convert "$features" "$nodesize"
+
+ run_check_mount_test_dev
+ convert_test_post_check_checksums "$CHECKSUMTMP"
+
+ here=$(pwd)
+ cd "$TEST_MNT" || _fail "cannot cd to TEST_MNT"
+ # reiserfs_saved/image must not be deleted
+ run_mayfail $SUDO_HELPER find "$TEST_MNT"/ -mindepth 1 -path '*reiserfs_saved' -prune -o -exec rm -vrf "{}" \;
+ cd "$here"
+ run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
+ run_check_umount_test_dev
+ convert_test_post_rollback
+
+ run_check_mount_convert_dev reiserfs
+ convert_test_post_check_checksums "$CHECKSUMTMP"
+ run_check_umount_test_dev
+
+ # mount again and verify checksums
+ run_check_mount_convert_dev reiserfs
+ convert_test_post_check_checksums "$CHECKSUMTMP"
+ run_check_umount_test_dev
+
+ rm "$CHECKSUMTMP"
+}
+
+for feature in '' 'extref' 'skinny-metadata' 'no-holes'; do
+ do_test "$feature" "reiserfs 4k nodesize" 4096 mkreiserfs -b 4096
+ do_test "$feature" "reiserfs 8k nodesize" 8192 mkreiserfs -b 4096
+ do_test "$feature" "reiserfs 16k nodesize" 16384 mkreiserfs -b 4096
+ do_test "$feature" "reiserfs 32k nodesize" 32768 mkreiserfs -b 4096
+ do_test "$feature" "reiserfs 64k nodesize" 65536 mkreiserfs -b 4096
+done
--- /dev/null
+#!/bin/bash
+# Create a base image with large hole extent, then convert to btrfs,
+# check the converted image.
+# Check if btrfs-convert can handle such large hole.
+# Fast pinpoint regression test. No options combination nor checksum
+# verification
+
+source "$TOP/tests/common"
+source "$TOP/tests/common.convert"
+
+setup_root_helper
+prepare_test_dev 512M
+check_prereq btrfs-convert
+
+default_mkfs="mkreiserfs -b 4096"
+convert_test_preamble '' 'large hole extent test' 16k "$default_mkfs"
+convert_test_prep_fs reiserfs $default_mkfs
+
+run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file" bs=1M \
+ count=1 seek=1024 > /dev/null 2>&1
+
+run_check_umount_test_dev
+convert_test_do_convert
--- /dev/null
+#!/bin/bash
+# Check if btrfs-convert can copy common inode flags like SYNC/IMMUTABLE
+
+source "$TOP/tests/common"
+source "$TOP/tests/common.convert"
+
+setup_root_helper
+prepare_test_dev 512M
+check_prereq btrfs-convert
+
+fail=0
+default_mkfs="mkreiserfs -b 4096"
+convert_test_preamble '' 'common inode flags test' 16k "$default_mkfs"
+convert_test_prep_fs reiserfs $default_mkfs
+
+# create file with specific flags
+run_check $SUDO_HELPER touch "$TEST_MNT/flag_test"
+run_check $SUDO_HELPER chattr +aAdSi "$TEST_MNT/flag_test"
+run_check lsattr "$TEST_MNT/flag_test"
+
+run_check_umount_test_dev
+convert_test_do_convert
+run_check_mount_test_dev
+
+# Log the status
+run_check lsattr "$TEST_MNT/flag_test"
+# Above flags should be copied to btrfs flags, and lsattr should get them
+run_check_stdout lsattr "$TEST_MNT/flag_test" | cut -f1 -d\ | grep "[aAdiS]" -q
+if [ $? -ne 0 ]; then
+ rm tmp_output
+ _fail "no common inode flags are copied after convert"
+fi
+
+run_check_umount_test_dev
+convert_test_post_rollback
--- /dev/null
+#!/bin/bash
+# Check the various combinations of real blocks, holes, and tails
+# Since it's possible to have a valid extent layout that check will
+# happily accept AND have garbage in the output, compare the results
+# as well.
+# We use separate inputs for tails and real blocks so we can determine
+# if there was a failure in copying either.
+
+source "$TOP/tests/common"
+source "$TOP/tests/common.convert"
+
+setup_root_helper
+prepare_test_dev 512M
+check_prereq btrfs-convert
+check_global_prereq md5sum
+
+perl -e "print 'a'x8192;" > input
+perl -e "print 'b'x8192;" > input2
+
+default_mkfs="mkreiserfs -b 4096"
+convert_test_preamble '' 'tail conversion test' 16k "$default_mkfs"
+convert_test_prep_fs reiserfs $default_mkfs
+
+# Hole alone
+run_check $SUDO_HELPER truncate -s 81920 "$TEST_MNT/hole"
+
+# Tail alone
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/1k" bs=1k count=1 \
+ > /dev/null 2>&1
+
+# Single indirect block
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k" bs=1k count=4 \
+ > /dev/null 2>&1
+
+# Indirect block + tail
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/5k" bs=1k count=4 \
+ > /dev/null 2>&1
+run_check $SUDO_HELPER dd if=input2 of="$TEST_MNT/5k" bs=1k count=1 \
+ seek=4 > /dev/null 2>&1
+
+# Hole followed by tail
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/hole-1k" bs=1k count=1 \
+ seek=4 > /dev/null 2>&1
+
+# Indirect block followed by hole
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k-hole" bs=1k count=4 \
+ > /dev/null 2>&1
+run_check $SUDO_HELPER truncate -s 81920 "$TEST_MNT/4k-hole"
+
+# Indirect block followed by hole followed by tail
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k-hole-1k" bs=1k count=4 \
+ > /dev/null 2>&1
+run_check $SUDO_HELPER truncate -s 8192 "$TEST_MNT/4k-hole-1k"
+run_check $SUDO_HELPER dd if=input2 of="$TEST_MNT/4k-hole-1k" bs=1k count=1 \
+ seek=8 > /dev/null 2>&1
+
+rm -f input input2
+
+declare -A SUMS
+for file in "$TEST_MNT"/*; do
+ SUM=$(md5sum "$file")
+ SUMS["$file"]=$SUM
+done
+
+run_check_umount_test_dev
+convert_test_do_convert
+
+run_check_mount_test_dev
+for file in "${!SUMS[@]}"; do
+ SUM=$(md5sum "$file")
+ run_check test "$SUM" = "${SUMS[$file]}"
+done
+run_check_umount_test_dev