2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Liu Bo, Alibaba. All Rights Reserved.
7 # Regression test for a ENOSPC warning when both quota and
8 # "-o dioread_nolock,nodelalloc" is used.
10 # The bug was fixed by commit
11 # "ext4: make sure enough credits are reserved for dioread_nolock writes"
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
33 # remove previous $seqres.full before test
36 # real QA test starts here
38 # Modify as appropriate.
43 _require_xfs_io_command "falloc"
44 _require_xfs_io_command "fiemap"
45 _require_xfs_io_command "syncfs"
47 echo "Format and mount"
48 _scratch_mkfs "-O quota" > $seqres.full 2>&1
49 _scratch_mount "-o dioread_nolock,nodelalloc" > $seqres.full 2>&1
51 echo "Create the original file"
52 touch $SCRATCH_MNT/foobar >> $seqres.full
53 chown nobody $SCRATCH_MNT/foobar >> $seqres.full
56 setquota -u nobody 0 10M 0 0 $SCRATCH_MNT
57 _report_quota_blocks $SCRATCH_MNT >> $seqres.full
59 echo "Create 2 level extent tree (btree) for foobar with a unwritten extent"
60 $XFS_IO_PROG -f -c "pwrite 0 4k" -c "falloc 4k 4k" -c "pwrite 8k 4k" \
61 -c "pwrite 20k 4k" -c "pwrite 28k 4k" -c "pwrite 36k 4k" \
62 -c "fsync" $SCRATCH_MNT/foobar >> $seqres.full
64 $XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar >> $seqres.full
66 echo "Convert unwritten extent to written and collapse extent tree to inode"
67 $XFS_IO_PROG -c "pwrite 4k 4k" $SCRATCH_MNT/foobar >> $seqres.full
69 echo "Create a new file and do fsync to force a jbd2 commit"
70 $XFS_IO_PROG -f -c "pwrite 0 4k" -c "fsync" $SCRATCH_MNT/dummy >> $seqres.full
72 # Use 'syncfs' instead of 'sync' here as 'sync' could have dirtied quota files
73 # ahead of writeback and could not reproduce the bug.
74 echo "sync $SCRATCH_MNT to writeback" | _filter_scratch
75 $XFS_IO_PROG -c "syncfs" $SCRATCH_MNT >> $seqres.full