On Sat, Jul 12, 2025 at 07:42:55PM +0530, Ojaswin Mujoo wrote: > Test atomic writes with journal credit calculation. We take 2 cases > here: > > 1. Atomic writes on single mapping causing tree to collapse into > the inode > 2. Atomic writes on mixed mapping causing tree to collapse into the > inode > > This test is inspired by ext4/034. > > Suggested-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx> > Signed-off-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx> > --- > tests/ext4/064 | 75 ++++++++++++++++++++++++++++++++++++++++++++++ > tests/ext4/064.out | 2 ++ > 2 files changed, 77 insertions(+) > create mode 100755 tests/ext4/064 > create mode 100644 tests/ext4/064.out > > diff --git a/tests/ext4/064 b/tests/ext4/064 > new file mode 100755 > index 00000000..ec31f983 > --- /dev/null > +++ b/tests/ext4/064 > @@ -0,0 +1,75 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2025 IBM Corporation. All Rights Reserved. > +# > +# FS QA Test 034 > +# > +# Test proper credit reservation is done when performing > +# tree collapse during an aotmic write based allocation > +# > +. ./common/preamble > +. ./common/atomicwrites > +_begin_fstest auto quick quota fiemap prealloc atomicwrites > + > +# Import common functions. > + > + > +# Modify as appropriate. > +_exclude_fs ext2 > +_exclude_fs ext3 > +_require_xfs_io_command "falloc" > +_require_xfs_io_command "fiemap" > +_require_xfs_io_command "syncfs" > +_require_scratch_write_atomic_multi_fsblock > +_require_atomic_write_test_commands _require_metadata_journaling $SCRATCH_DEV ? > + > +echo "----- Testing with atomic write on non-mixed mapping -----" >> $seqres.full > + > +echo "Format and mount" >> $seqres.full > +_scratch_mkfs > $seqres.full 2>&1 > +_scratch_mount > $seqres.full 2>&1 > + > +echo "Create the original file" >> $seqres.full > +touch $SCRATCH_MNT/foobar >> $seqres.full > + > +echo "Create 2 level extent tree (btree) for foobar with a unwritten extent" >> $seqres.full > +$XFS_IO_PROG -f -c "pwrite 0 4k" -c "falloc 4k 4k" -c "pwrite 8k 4k" \ > + -c "pwrite 20k 4k" -c "pwrite 28k 4k" -c "pwrite 36k 4k" \ > + -c "fsync" $SCRATCH_MNT/foobar >> $seqres.full What happens if the block size isn't 4k? --D > + > +$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar >> $seqres.full > + > +echo "Convert unwritten extent to written and collapse extent tree to inode" >> $seqres.full > +$XFS_IO_PROG -dc "pwrite -A -V1 4k 4k" $SCRATCH_MNT/foobar >> $seqres.full > + > +echo "Create a new file and do fsync to force a jbd2 commit" >> $seqres.full > +$XFS_IO_PROG -f -c "pwrite 0 4k" -c "fsync" $SCRATCH_MNT/dummy >> $seqres.full > + > +echo "sync $SCRATCH_MNT to writeback" >> $seqres.full > +$XFS_IO_PROG -c "syncfs" $SCRATCH_MNT >> $seqres.full > + > +echo "----- Testing with atomi write on mixed mapping -----" >> $seqres.full > + > +echo "Create the original file" >> $seqres.full > +touch $SCRATCH_MNT/foobar2 >> $seqres.full > + > +echo "Create 2 level extent tree (btree) for foobar2 with a unwritten extent" >> $seqres.full > +$XFS_IO_PROG -f -c "pwrite 0 4k" -c "falloc 4k 4k" -c "pwrite 8k 4k" \ > + -c "pwrite 20k 4k" -c "pwrite 28k 4k" -c "pwrite 36k 4k" \ > + -c "fsync" $SCRATCH_MNT/foobar2 >> $seqres.full > + > +$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar2 >> $seqres.full > + > +echo "Convert unwritten extent to written and collapse extent tree to inode" >> $seqres.full > +$XFS_IO_PROG -dc "pwrite -A -V1 0k 12k" $SCRATCH_MNT/foobar2 >> $seqres.full > + > +echo "Create a new file and do fsync to force a jbd2 commit" >> $seqres.full > +$XFS_IO_PROG -f -c "pwrite 0 4k" -c "fsync" $SCRATCH_MNT/dummy2 >> $seqres.full > + > +echo "sync $SCRATCH_MNT to writeback" >> $seqres.full > +$XFS_IO_PROG -c "syncfs" $SCRATCH_MNT >> $seqres.full > + > +# success, all done > +echo "Silence is golden" > +status=0 > +exit > diff --git a/tests/ext4/064.out b/tests/ext4/064.out > new file mode 100644 > index 00000000..d9076546 > --- /dev/null > +++ b/tests/ext4/064.out > @@ -0,0 +1,2 @@ > +QA output created by 064 > +Silence is golden > -- > 2.49.0 > >