2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2021 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. btrfs/234
7 # Test cases where a direct IO write, with O_DSYNC, can not be done and has to
8 # fallback to a buffered write.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
29 # real QA test starts here
37 _scratch_mkfs >>$seqres.full 2>&1
40 # Create a test file with compression enabled (chattr +c).
41 touch $SCRATCH_MNT/foo
42 $CHATTR_PROG +c $SCRATCH_MNT/foo
44 # Now do a buffered write to create compressed extents.
45 $XFS_IO_PROG -s -c "pwrite -S 0xab -b 1M 0 1M" $SCRATCH_MNT/foo | _filter_xfs_io
47 # Now do the direct IO write with O_DSYNC into a file range that contains
48 # compressed extents. It should fallback to buffered IO and succeed.
49 $XFS_IO_PROG -d -s -c "pwrite -S 0xcd 512K 512K" $SCRATCH_MNT/foo | _filter_xfs_io
51 # Now try doing a direct IO write, with O_DSYNC, for a range that starts with
52 # non-aligned offset. It should also fallback to buffered IO and succeed.
53 $XFS_IO_PROG -f -d -s -c "pwrite -S 0xef 1111 512K" $SCRATCH_MNT/bar | _filter_xfs_io
55 # Unmount, mount again, and verify we have the expected data.
59 od -A d -t x1 $SCRATCH_MNT/foo
61 od -A d -t x1 $SCRATCH_MNT/bar