Re: [PATCH] btrfs/239: call fsync to create tree-log dedicated block group for zoned mode

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



On Thu, Sep 21, 2023 at 8:39 PM Naohiro Aota <naohiro.aota@xxxxxxx> wrote:
>
> Running btrfs/239 on a zoned device often fails with the following error.
>
>   btrfs/239 5s ... - output mismatch (see /host/btrfs/239.out.bad)
>       --- tests/btrfs/239.out     2023-09-21 16:56:37.735204924 +0900
>       +++ /host/btrfs/239.out.bad  2023-09-21 18:22:45.401433408 +0900
>       @@ -1,4 +1,6 @@
>        QA output created by 239
>       +/testdir/dira still exists
>       +/dira does not exists
>        File SCRATCH_MNT/testdir/file1 data:
>        0000000 ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
>        *
>       ...
>
> This happens because "testdir" and "dira" are not logged on the first fsync
> (fsync $SCRATCH_MNT/testdir), but are written as a full commit. That
> prevents updating the log on "mv" time, leaving them pre-mv state.
>
> The full commit is induced by the creation of a new block group. On the
> zoned mode, we use a dedicated block group for tree-log. That block group
> is created on-demand or assigned to a metadata block group if there is
> none. On the first mount of a file system, we need to create one because
> there is only one metadata block group available for the regular
> metadata. That creation of a new block group forces tree-log to be a full
> commit on that transaction, which prevents logging "testdir" and "dira".
>
> Fix the issue by calling fsync before the first "sync", which creates the
> dedicated block group and let the files be properly logged.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@xxxxxxx>

Reviewed-by: Filipe Manana <fdmanana@xxxxxxxx>

Looks reasonable, thanks.

> ---
>  tests/btrfs/239 | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/tests/btrfs/239 b/tests/btrfs/239
> index 3fbeaedd2c39..5a2dbe58d5fb 100755
> --- a/tests/btrfs/239
> +++ b/tests/btrfs/239
> @@ -83,6 +83,18 @@ done
>  #
>  mkdir $SCRATCH_MNT/testdir/dira
>
> +# This fsync is for the zoned mode. On the zoned mode, we use a dedicated block
> +# group for tree-log. That block group is created on-demand or assigned to a
> +# metadata block group if there is none. On the first mount of a file system, we
> +# need to create one because there is only one metadata block group available
> +# for the regular metadata. That creation of a new block group forces tree-log
> +# to be a full commit on that transaction, which prevents logging "testdir" and
> +# "dira" and screws up the result.
> +#
> +# Calling fsync here will create the dedicated block group, and let them be
> +# logged.
> +$XFS_IO_PROG -c "fsync" $SCRATCH_MNT
> +
>  # Make sure everything done so far is durably persisted.
>  sync
>
> --
> 2.42.0
>




[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