Re: [PATCH fstests v2] generic: test Btrfs fsync vs. size-extending prealloc write crash

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



On Fri, Jun 7, 2024 at 11:04 AM Zorro Lang <zlang@xxxxxxxxxx> wrote:
>
> On Fri, Jun 07, 2024 at 10:43:47AM +0100, Filipe Manana wrote:
> > On Fri, Jun 7, 2024 at 6:12 AM Zorro Lang <zlang@xxxxxxxxxx> wrote:
> > >
> > > On Sun, May 26, 2024 at 12:47:49PM +0100, Filipe Manana wrote:
> > > > On Fri, May 24, 2024 at 9:58 PM Omar Sandoval <osandov@xxxxxxxxxxx> wrote:
> > > > >
> > > > > From: Omar Sandoval <osandov@xxxxxx>
> > > > >
> > > > > This is a regression test for a Btrfs bug, but there's nothing
> > > > > Btrfs-specific about it. Since it's a race, we just try to make the race
> > > > > happen in a loop and pass if it doesn't crash after all of our attempts.
> > > > >
> > > > > Signed-off-by: Omar Sandoval <osandov@xxxxxx>
> > > > > ---
> > > > > Changes from v1 [1]:
> > > > >
> > > > > - Added missing groups and requires.
> > > > > - Simplified $XFS_IO_PROG calls.
> > > > > - Removed -i flag from $XFS_IO_PROG to make race reproduce more
> > > > >   reliably.
> > > > > - Removed all of the file creation and dump-tree parsing since the only
> > > > >   file on a fresh filesystem is guaranteed to be at the end of a leaf
> > > > >   anyways.
> > > > > - Rewrote to be a generic test.
> > > > >
> > > > > 1: https://lore.kernel.org/linux-btrfs/297da2b53ce9b697d82d89afd322b2cc0d0f392d.1716492850.git.osandov@xxxxxxxxxxx/
> > > > >
> > > > >  tests/generic/745     | 44 +++++++++++++++++++++++++++++++++++++++++++
> > > > >  tests/generic/745.out |  2 ++
> > > > >  2 files changed, 46 insertions(+)
> > > > >  create mode 100755 tests/generic/745
> > > > >  create mode 100644 tests/generic/745.out
> > > > >
> > > > > diff --git a/tests/generic/745 b/tests/generic/745
> > > > > new file mode 100755
> > > > > index 00000000..925adba9
> > > > > --- /dev/null
> > > > > +++ b/tests/generic/745
> > > >
> > > > Btw, generic/745 already exists in the for-next branch (development is
> > > > based against that branch nowadays).
> > > >
> > > > > @@ -0,0 +1,44 @@
> > > > > +#! /bin/bash
> > > > > +# SPDX-License-Identifier: GPL-2.0
> > > > > +# Copyright (c) Meta Platforms, Inc. and affiliates.
> > > > > +#
> > > > > +# FS QA Test 745
> > > > > +#
> > > > > +# Repeatedly prealloc beyond i_size, set an xattr, direct write into the
> > > > > +# prealloc while extending i_size, then fdatasync. This is a regression test
> > > > > +# for a Btrfs crash.
> > > > > +#
> > > > > +. ./common/preamble
> > > > > +. ./common/attr
> > > > > +_begin_fstest auto quick log preallocrw dangerous
> > > > > +
> > > > > +_supported_fs generic
> > > > > +_require_scratch
> > > > > +_require_attrs
> > > > > +_require_xfs_io_command falloc -k
> > > >
> > > > Since this is now a generic test and we're using direct IO, also:
> > > >
> > > > _require_odirect
> > > >
> > > > > +_fixed_by_kernel_commit XXXXXXXXXXXX \
> > > > > +       "btrfs: fix crash on racing fsync and size-extending write into prealloc"
> > > >
> > > > Because it's now a generic test, it should be:
> > > >
> > > > [ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit ....
> > > >
> > > > Otherwise it looks good to me, so with that:
> > > >
> > > > Reviewed-by: Filipe Manana <fdmanana@xxxxxxxx>
> > >
> > > Thanks Filipe, merged this patch with above review points, more details refer to
> > > "patches-in-queue" branch. Feel free to have more review points before I push
> > > to for-next :)
> >
> > Btw, there's a v3 with all that addressed:
> >
> > https://lore.kernel.org/fstests/8c91247dd109bb94e8df36f2812274b5de2a7183.1716916346.git.osandov@xxxxxxxxxxx/
> >
> > Also, looking at patches-in-queue, the test was added twice, once as
> > generic/748 and once as generic/749, in two different commits.
>
> Oh, I've merged this test case last week... sorry I forgot that. I'll keep
> the g/748, and remove the g/749.
>
> >
> > Also, unrelated, but this commit:
> >
> > https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/commit/?h=patches-in-queue&id=b4c4ba99435aa7fd4f8a6e3c02938e357e137ec9
> >
> > As a Signed-off-by tag for David Disseldorp instead of Reviewed-by.
>
> Oh, this Signed-off-by tag is generated automatically by:
>
> https://lore.kernel.org/fstests/c9e54af5-4370-4d45-a8ed-4098b06b2629@xxxxxxxx/T/#m8fc24d233b2cf3a323c94c2b8039c0f043e09023
>
> if it's a mistake, I'll change it to Reviewed-by:

That I didn't notice, odd that David replied with Signed-off-by and
not Reviewed-by.
(cc'ing him)

Thanks.

>
> Thanks,
> Zorro
>
> >
> > Thanks.
> >
> > >
> > > Thanks,
> > > Zorro
> > >
> > > >
> > > > Thanks.
> > > >
> > > > > +
> > > > > +# -i slows down xfs_io startup and makes the race much less reliable.
> > > > > +export XFS_IO_PROG="$(echo "$XFS_IO_PROG" | sed 's/ -i\b//')"
> > > > > +
> > > > > +_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
> > > > > +_scratch_mount
> > > > > +
> > > > > +blksz=$(_get_block_size "$SCRATCH_MNT")
> > > > > +
> > > > > +# On Btrfs, since this is the only file on the filesystem, its metadata is at
> > > > > +# the end of a B-tree leaf. We want an ordered extent completion to add an
> > > > > +# extent item at the end of the leaf while we're logging prealloc extents
> > > > > +# beyond i_size after an xattr was set.
> > > > > +for ((i = 0; i < 5000; i++)); do
> > > > > +       $XFS_IO_PROG -ftd -c "falloc -k 0 $((blksz * 3))" -c "pwrite -q -w 0 $blksz" "$SCRATCH_MNT/file"
> > > > > +       $SETFATTR_PROG -n user.a -v a "$SCRATCH_MNT/file"
> > > > > +       $XFS_IO_PROG -d -c "pwrite -q -w $blksz $blksz" "$SCRATCH_MNT/file"
> > > > > +done
> > > > > +
> > > > > +# If it didn't crash, we're good.
> > > > > +
> > > > > +echo "Silence is golden"
> > > > > +status=0
> > > > > +exit
> > > > > diff --git a/tests/generic/745.out b/tests/generic/745.out
> > > > > new file mode 100644
> > > > > index 00000000..fce6b7f5
> > > > > --- /dev/null
> > > > > +++ b/tests/generic/745.out
> > > > > @@ -0,0 +1,2 @@
> > > > > +QA output created by 745
> > > > > +Silence is golden
> > > > > --
> > > > > 2.45.1
> > > > >
> > > > >
> > > >
> > >
> >
>





[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