From: Ariel Miculas <ariel.miculas@gmail.com>
To: linux-bcachefs@vger.kernel.org
Cc: Ariel Miculas <ariel.miculas@gmail.com>
Subject: [PATCH] tests/bcachefs/single_device: test bcachefs format from source
Date: Thu, 6 Jun 2024 18:28:04 +0300 [thread overview]
Message-ID: <20240606152804.866509-1-ariel.miculas@gmail.com> (raw)
Add a test which checks formatting and initializing a bcachefs
filesystem from a source directory:
`bcachefs format --source=source_dir`
Create a new `prepare_fs` function shared by both `migrate_from_fs` and
`build_from_fs`.
Other changes:
- add `ro` mount options when `nochanges` is supplied
- add a function which checks rsync's --itemize-changes output
- pass the --hard-links options to rsync when comparing changes
- avoid creating hardlinks for symlinks
Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
---
tests/bcachefs/single_device.ktest | 101 +++++++++++++++++++++++++++--
1 file changed, 94 insertions(+), 7 deletions(-)
diff --git a/tests/bcachefs/single_device.ktest b/tests/bcachefs/single_device.ktest
index 8e9b5a3..4c9caa7 100755
--- a/tests/bcachefs/single_device.ktest
+++ b/tests/bcachefs/single_device.ktest
@@ -1252,11 +1252,8 @@ disabled_test_swapfile()
check_counters ${ktest_scratch_dev[0]}
}
-# migrate from other filesystems in place:
-
-migrate_from_fs()
+prepare_source_fs()
{
- set_watchdog 180
local fstype=$1
if [[ $fstype = ext4 ]]; then
@@ -1270,10 +1267,97 @@ migrate_from_fs()
cp -a /usr /mnt
for i in /mnt/usr/bin/*; do
+ if [ ! -L $i ]; then
ln $i ${i}-migrate2
- setfattr -n user.foo -v test $i
+ fi
+ setfattr -n user.foo -v test $i
done
+}
+
+check_rsync_log()
+{
+ # rsync itemized output
+ # https://jhpce.jhu.edu/files/rsync-itemize-table/
+ # .: the item is not being updated (though it might have attributes that are being modified)
+
+ # We don't expect any lines to start with anything other than a dot
+ # Ideally the output should be empty, but the lost+found/ directory is
+ # ignored and the mountpoints themselves could have a modified time
+ # Sample expected output:
+ # .d..t...... ./
+ # .d..t...... lost+found/
+ ! grep -E '^[^.]' $1
+}
+
+# build a filesystem from a source
+
+build_from_fs()
+{
+ set_watchdog 180
+
+ prepare_source_fs $1
+
+ bcachefs format \
+ --source=/mnt ${ktest_scratch_dev[1]} | tee /root/buildlog
+
+ echo "Attempting to mount bcachefs filesystem"
+
+ if true; then
+ mkdir -p /mnt2
+ mount -t bcachefs -o noexcl,nochanges,ro ${ktest_scratch_dev[1]} /mnt2
+
+ rsync --archive \
+ --acls \
+ --xattrs \
+ --checksum \
+ --hard-links \
+ --dry-run \
+ --itemize-changes \
+ /mnt/ /mnt2/ > /root/rsynclog-build
+
+ check_rsync_log /root/rsynclog-build
+
+ umount /mnt2
+ echo "rsync passed"
+ fi
+
+ umount /mnt
+
+ bcachefs fsck -ny ${ktest_scratch_dev[1]}
+ check_counters ${ktest_scratch_dev[1]}
+}
+
+test_build_from_ext4()
+{
+ build_from_fs ext4
+}
+
+require-kernel-config XFS_FS
+test_build_from_xfs()
+{
+ build_from_fs xfs
+}
+
+require-kernel-config BTRFS_FS
+test_build_from_btrfs()
+{
+ build_from_fs btrfs
+}
+
+test_build_from_bcachefs()
+{
+ build_from_fs bcachefs
+}
+
+# migrate from other filesystems in place:
+
+migrate_from_fs()
+{
+ set_watchdog 180
+
+ prepare_source_fs $1
+
bcachefs migrate \
--encrypted \
--no_passphrase \
@@ -1287,16 +1371,19 @@ migrate_from_fs()
if true; then
mkdir -p /mnt2
- mount -t bcachefs -o noexcl,nochanges,sb=$offset ${ktest_scratch_dev[0]} /mnt2
+ mount -t bcachefs -o noexcl,nochanges,ro,sb=$offset ${ktest_scratch_dev[0]} /mnt2
rsync --archive \
--acls \
--xattrs \
--checksum \
+ --hard-links \
--exclude=/bcachefs \
--dry-run \
--itemize-changes \
- /mnt/ /mnt2/ > /root/rsynclog
+ /mnt/ /mnt2/ > /root/rsynclog-migrate
+
+ check_rsync_log /root/rsynclog-migrate
umount /mnt2
echo "rsync passed"
--
2.34.1
next reply other threads:[~2024-06-06 15:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 15:28 Ariel Miculas [this message]
2024-06-06 15:51 ` [PATCH] tests/bcachefs/single_device: test bcachefs format from source Kent Overstreet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240606152804.866509-1-ariel.miculas@gmail.com \
--to=ariel.miculas@gmail.com \
--cc=linux-bcachefs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox