Rename _scratch_mount to _scratch_cycle_mount
[xfstests-dev.git] / tests / xfs / 213
1 #! /bin/bash
2 # FS QA Test No. 213
3 #
4 # Ensure that quota charges us for reflnking a file and that we're not
5 # charged for buffered copy on write.  Same test as g/305, but we get to
6 # play with cowextsz.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #-----------------------------------------------------------------------
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1    # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     rm -rf $tmp.*
38 }
39
40 # get standard environment, filters and checks
41 . ./common/rc
42 . ./common/filter
43 . ./common/reflink
44 . ./common/quota
45
46 # real QA test starts here
47 _supported_os Linux
48 _supported_fs xfs
49 _require_scratch_reflink
50 _require_cp_reflink
51 _require_fiemap
52 _require_quota
53 _require_nobody
54 _require_xfs_io_command "cowextsize"
55
56 _repquota() {
57         repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)'
58 }
59 rm -f $seqres.full
60
61 echo "Format and mount"
62 _scratch_mkfs > $seqres.full 2>&1
63 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
64 _scratch_mount >> $seqres.full 2>&1
65 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
66 quotaon $SCRATCH_MNT 2> /dev/null
67
68 testdir=$SCRATCH_MNT/test-$seq
69 mkdir $testdir
70
71 sz=1048576
72 blksz=65536
73 echo "Create the original files"
74 $XFS_IO_PROG -c "cowextsize $((sz/2))" $testdir >> $seqres.full
75 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
76 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
77 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
78 touch $testdir/urk
79 chown nobody $testdir/urk
80 touch $testdir/erk
81 chown fsgqa $testdir/erk
82 _repquota
83 _scratch_cycle_mount
84
85 echo "Change file ownership"
86 chown fsgqa $testdir/file1
87 chown fsgqa $testdir/file2
88 chown fsgqa $testdir/file3
89 _repquota
90
91 echo "CoW one of the files"
92 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" $testdir/file2 >> $seqres.full
93 _repquota
94
95 echo "Remount the FS to see if accounting changes"
96 _scratch_cycle_mount
97 _repquota
98
99 echo "Chown one of the files"
100 chown nobody $testdir/file3
101 _repquota
102
103 # success, all done
104 status=0
105 exit