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 _begin_fstest auto quick quota
16 # Import common functions.
20 # real QA test starts here
22 # Modify as appropriate.
27 _require_xfs_io_command "falloc"
28 _require_xfs_io_command "fiemap"
29 _require_xfs_io_command "syncfs"
31 echo "Format and mount"
32 _scratch_mkfs "-O quota" > $seqres.full 2>&1
33 _scratch_mount "-o dioread_nolock,nodelalloc" > $seqres.full 2>&1
35 echo "Create the original file"
36 touch $SCRATCH_MNT/foobar >> $seqres.full
37 chown nobody $SCRATCH_MNT/foobar >> $seqres.full
40 setquota -u nobody 0 10M 0 0 $SCRATCH_MNT
41 _report_quota_blocks $SCRATCH_MNT >> $seqres.full
43 echo "Create 2 level extent tree (btree) for foobar with a unwritten extent"
44 $XFS_IO_PROG -f -c "pwrite 0 4k" -c "falloc 4k 4k" -c "pwrite 8k 4k" \
45 -c "pwrite 20k 4k" -c "pwrite 28k 4k" -c "pwrite 36k 4k" \
46 -c "fsync" $SCRATCH_MNT/foobar >> $seqres.full
48 $XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar >> $seqres.full
50 echo "Convert unwritten extent to written and collapse extent tree to inode"
51 $XFS_IO_PROG -c "pwrite 4k 4k" $SCRATCH_MNT/foobar >> $seqres.full
53 echo "Create a new file and do fsync to force a jbd2 commit"
54 $XFS_IO_PROG -f -c "pwrite 0 4k" -c "fsync" $SCRATCH_MNT/dummy >> $seqres.full
56 # Use 'syncfs' instead of 'sync' here as 'sync' could have dirtied quota files
57 # ahead of writeback and could not reproduce the bug.
58 echo "sync $SCRATCH_MNT to writeback" | _filter_scratch
59 $XFS_IO_PROG -c "syncfs" $SCRATCH_MNT >> $seqres.full