generic/554: hide permision warning on exfat
[xfstests-dev.git] / tests / generic / 326
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. 326
6 #
7 # Ensure that quota charges us for reflinking a file and that we're not
8 # charged for directio copy on write.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     cd /
22     rm -rf $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29 . ./common/quota
30
31 # real QA test starts here
32 _require_scratch_reflink
33 _require_cp_reflink
34 _require_xfs_io_command "fiemap"
35 _require_quota
36 _require_nobody
37 _require_odirect
38 _require_user
39
40 rm -f $seqres.full
41
42 echo "Format and mount"
43 _scratch_mkfs > $seqres.full 2>&1
44 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
45 _scratch_mount >> $seqres.full 2>&1
46 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
47 quotaon $SCRATCH_MNT 2> /dev/null
48
49 testdir=$SCRATCH_MNT/test-$seq
50 mkdir $testdir
51
52 sz=1048576
53 echo "Create the original files"
54 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
55 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
56 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
57 touch $testdir/urk
58 chown nobody $testdir/urk
59 touch $testdir/erk
60 chown $qa_user $testdir/erk
61 _report_quota_blocks $SCRATCH_MNT
62 _scratch_cycle_mount
63
64 echo "Change file ownership"
65 chown $qa_user $testdir/file1
66 chown $qa_user $testdir/file2
67 chown $qa_user $testdir/file3
68 _report_quota_blocks $SCRATCH_MNT
69
70 echo "CoW one of the files"
71 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" $testdir/file2 >> $seqres.full
72 _report_quota_blocks $SCRATCH_MNT
73
74 echo "Remount the FS to see if accounting changes"
75 _scratch_cycle_mount
76 _report_quota_blocks $SCRATCH_MNT
77
78 echo "Chown one of the files"
79 chown nobody $testdir/file3
80 _report_quota_blocks $SCRATCH_MNT
81
82 # success, all done
83 status=0
84 exit