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