Re: [PATCH] btrfs: add test case for rwf_nowait writes

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Wed, Oct 21, 2020 at 3:39 PM Josef Bacik <josef@xxxxxxxxxxxxxx> wrote:
>
> On 10/20/20 10:43 AM, fdmanana@xxxxxxxxxx wrote:
> > From: Filipe Manana <fdmanana@xxxxxxxx>
> >
> > Test several scenarios for RWF_NOWAIT writes, to verify we don't regress
> > on btrfs specific behaviour (snapshots, cow files, reflinks, holes,
> > prealloc extent beyond eof).
> >
> > We had some bugs in the past related to RWF_NOWAIT writes not failing on
> > btrfs when they should or failing when they shouldn't, these were fixed by
> > the following kernel commits:
> >
> >    4b1946284dd6 ("btrfs: fix failure of RWF_NOWAIT write into prealloc extent beyond eof")
> >    260a63395f90 ("btrfs: fix RWF_NOWAIT write not failling when we need to cow")
> >
> > Signed-off-by: Filipe Manana <fdmanana@xxxxxxxx>
> > ---
> >   tests/btrfs/225     | 140 ++++++++++++++++++++++++++++++++++++++++++++
> >   tests/btrfs/225.out |  70 ++++++++++++++++++++++
> >   tests/btrfs/group   |   1 +
> >   3 files changed, 211 insertions(+)
> >   create mode 100755 tests/btrfs/225
> >   create mode 100644 tests/btrfs/225.out
> >
> > diff --git a/tests/btrfs/225 b/tests/btrfs/225
> > new file mode 100755
> > index 00000000..f55e8c80
> > --- /dev/null
> > +++ b/tests/btrfs/225
> > @@ -0,0 +1,140 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
> > +#
> > +# FS QA Test No. btrfs/225
> > +#
> > +# Test several (btrfs specific) scenarios with RWF_NOWAIT writes, cases where
> > +# they should fail and cases where they should succeed.
> > +#
> > +seq=`basename $0`
> > +seqres=$RESULT_DIR/$seq
> > +echo "QA output created by $seq"
> > +
> > +tmp=/tmp/$$
> > +status=1     # failure is the default!
> > +trap "_cleanup; exit \$status" 0 1 2 3 15
> > +
> > +_cleanup()
> > +{
> > +     cd /
> > +     rm -f $tmp.*
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +. ./common/reflink
> > +
> > +# real QA test starts here
> > +_supported_fs btrfs
> > +_require_scratch_reflink
> > +_require_chattr C
> > +_require_odirect
> > +_require_xfs_io_command pwrite -N
> > +_require_xfs_io_command falloc -k
> > +_require_xfs_io_command fpunch
> > +
> > +rm -f $seqres.full
> > +
> > +_scratch_mkfs >>$seqres.full 2>&1
> > +_scratch_mount
> > +
> > +# Test a write against COW file/extent - should fail with -EAGAIN. Disable the
> > +# NOCOW attribute of the file just in case MOUNT_OPTIONS has "-o nodatacow".
> > +echo "Testing write against COW file"
> > +touch $SCRATCH_MNT/f1
> > +$CHATTR_PROG -C $SCRATCH_MNT/f1
> > +$XFS_IO_PROG -s -c "pwrite -S 0xab 0 128K" $SCRATCH_MNT/f1 | _filter_xfs_io
> > +$XFS_IO_PROG -d -c "pwrite -N -V 1 -S 0xff 32K 64K" $SCRATCH_MNT/f1
>
> Should we do something like
>
> expected_to_fail_command > /dev/null 2>&1 || echo "FAILED!"
>
> so we don't get screwed by error strings changing in the future or some such
> other nonsense?  Thanks,

1) That's generally considered an anti-pattern in fstests.

2) More importantly, I want to make sure the failure reason is -EAGAIN
("Resource temporarily unavailable") and not something else, in which
case it means we have a regression and we want to notice it.

Thanks

>
> Josef



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux