generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / ext4 / 034
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Liu Bo, Alibaba.  All Rights Reserved.
4 #
5 # FS QA Test 034
6 #
7 # Regression test for a ENOSPC warning when both quota and
8 # "-o dioread_nolock,nodelalloc" is used.
9 #
10 # The bug was fixed by commit
11 # "ext4: make sure enough credits are reserved for dioread_nolock writes"
12 #
13 . ./common/preamble
14 _begin_fstest auto quick quota
15
16 # Import common functions.
17 . ./common/filter
18 . ./common/quota
19
20 # real QA test starts here
21
22 # Modify as appropriate.
23 _supported_fs ext4
24 _require_scratch
25 _require_quota
26 _require_nobody
27 _require_xfs_io_command "falloc"
28 _require_xfs_io_command "fiemap"
29 _require_xfs_io_command "syncfs"
30
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
34
35 echo "Create the original file"
36 touch $SCRATCH_MNT/foobar >> $seqres.full
37 chown nobody $SCRATCH_MNT/foobar >> $seqres.full
38
39 echo "Set hard quota"
40 setquota -u nobody 0 10M 0 0 $SCRATCH_MNT
41 _report_quota_blocks $SCRATCH_MNT >> $seqres.full
42
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
47
48 $XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar >> $seqres.full
49
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
52
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
55
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
60
61 # success, all done
62 status=0
63 exit