Merge branch 'master' of git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev
[xfstests-dev.git] / 272
1 #! /bin/bash
2 # FSQA Test No. 272
3 #
4 # Test data journaling flag switch for a single file  
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24 # creator
25 owner=dmonakhov@openvz.org
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38 _workout()
39 {
40         echo ""
41         echo " Switch data journalling mode"
42         echo ""
43         write_opt_list="iflag=noatime conv=notrunc conv=fsync oflag=direct"
44         chattr_opt_list="+j -j +jS -j"
45         idx=0
46         #
47         for write_opt in $write_opt_list
48         do
49                 idx=$((idx + 1))
50                 for chattr_opt in $chattr_opt_list
51                 do
52                     
53                         echo "OP write_opt: $write_opt 4M, \
54 chattr_opt: $chattr_opt"
55                         dd if=/dev/zero of=$SCRATCH_MNT/file.$idx \
56                                 bs=1M count=4 $write_opt \
57                                 >> $seq.full 2>&1 || exit
58                         chattr $chattr_opt $SCRATCH_MNT/file.$idx >> $seq.full \
59                                 || exit
60                 done
61         done
62         sync
63         # Same as previous test, but for one file,
64         # and with ENOSPC triggering
65         for write_opt in $write_opt_list
66         do
67                 idx=$((idx + 1))
68                 for chattr_opt in $chattr_opt_list
69                 do
70
71                         echo "OP write_opt: $write_opt ENOSPC, \
72 chattr_opt: $chattr_opt"
73                         dd if=/dev/zero of=$SCRATCH_MNT/file.$idx \
74                                 bs=1M $write_opt >> $seq.full 2>&1
75                         chattr $chattr_opt $SCRATCH_MNT/file.$idx \
76                                 >> $seq.full || exit
77                 done
78                 sync
79                 unlink $SCRATCH_MNT/file.$idx
80         done
81 }
82
83 # real QA test starts here
84 _supported_fs ext3 ext4
85 _supported_os Linux
86 _need_to_be_root
87 _require_scratch
88
89 _scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seq.full 2>&1
90 _scratch_mount
91
92 if ! _workout; then
93         echo "workout failed"
94         _scratch_unmount
95         status=1
96         exit
97 fi
98
99 if ! _scratch_unmount; then
100         echo "failed to umount"
101         status=1
102         exit
103 fi
104 echo "Check filesystem"
105 _check_scratch_fs
106 status=$?
107 exit