generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 305
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 305
6 #
7 # Ensure that quota charges us for reflinking a file and that we're not
8 # charged for buffered copy on write.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick clone
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/reflink
16 . ./common/quota
17
18 # real QA test starts here
19 _require_scratch_reflink
20 _require_cp_reflink
21 _require_xfs_io_command "fiemap"
22 _require_quota
23 _require_nobody
24 _require_user
25
26 echo "Format and mount"
27 _scratch_mkfs > $seqres.full 2>&1
28 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
29 _scratch_mount >> $seqres.full 2>&1
30 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
31 quotaon $SCRATCH_MNT 2> /dev/null
32
33 testdir=$SCRATCH_MNT/test-$seq
34 mkdir $testdir
35
36 sz=1048576
37 echo "Create the original files"
38 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
39 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
40 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
41 touch $testdir/urk
42 chown nobody $testdir/urk
43 touch $testdir/erk
44 chown $qa_user $testdir/erk
45 _report_quota_blocks $SCRATCH_MNT
46 _scratch_cycle_mount
47
48 echo "Change file ownership"
49 chown $qa_user $testdir/file1
50 chown $qa_user $testdir/file2
51 chown $qa_user $testdir/file3
52 _report_quota_blocks $SCRATCH_MNT
53
54 echo "CoW one of the files"
55 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" $testdir/file2 >> $seqres.full
56 _report_quota_blocks $SCRATCH_MNT
57
58 echo "Remount the FS to see if accounting changes"
59 _scratch_cycle_mount
60 _report_quota_blocks $SCRATCH_MNT
61
62 echo "Chown one of the files"
63 chown nobody $testdir/file3
64 _report_quota_blocks $SCRATCH_MNT
65
66 # success, all done
67 status=0
68 exit