xfstests: rename configure.in to configure.ac
[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 # ext3 doesn't support direct IO in journalling mode
36 write_opt_list="iflag=noatime conv=notrunc conv=fsync"
37 # For filesystems that can handle it, add also direct IO test
38 [ $FSTYP = "ext4" ] && write_opt_list="$write_opt_list oflag=direct"
39
40 # get standard environment, filters and checks
41 . ./common.rc
42 . ./common.filter
43 _workout()
44 {
45         echo "Switch data journalling mode. Silence is golden."
46         chattr_opt_list="+j -j +jS -j"
47         idx=0
48         #
49         for write_opt in $write_opt_list
50         do
51                 idx=$((idx + 1))
52                 for chattr_opt in $chattr_opt_list
53                 do
54                     
55                         echo "OP write_opt: $write_opt 4M, \
56 chattr_opt: $chattr_opt" >>$seq.full
57                         dd if=/dev/zero of=$SCRATCH_MNT/file.$idx \
58                                 bs=1M count=4 $write_opt \
59                                 >> $seq.full 2>&1 || exit
60                         chattr $chattr_opt $SCRATCH_MNT/file.$idx >> $seq.full \
61                                 || exit
62                 done
63         done
64         sync
65         # Same as previous test, but for one file,
66         # and with ENOSPC triggering
67         for write_opt in $write_opt_list
68         do
69                 idx=$((idx + 1))
70                 for chattr_opt in $chattr_opt_list
71                 do
72
73                         echo "OP write_opt: $write_opt ENOSPC, \
74 chattr_opt: $chattr_opt" >>$seq.full
75                         dd if=/dev/zero of=$SCRATCH_MNT/file.$idx \
76                                 bs=1M $write_opt >> $seq.full 2>&1
77                         chattr $chattr_opt $SCRATCH_MNT/file.$idx \
78                                 >> $seq.full || exit
79                 done
80                 sync
81                 unlink $SCRATCH_MNT/file.$idx
82         done
83 }
84
85 # real QA test starts here
86 _supported_fs ext3 ext4
87 _supported_os Linux
88 _need_to_be_root
89 _require_scratch
90
91 _scratch_mkfs_sized $((64 * 1024 * 1024)) >> $seq.full 2>&1
92 _scratch_mount
93
94 if ! _workout; then
95         echo "workout failed"
96         _scratch_unmount
97         status=1
98         exit
99 fi
100
101 if ! _scratch_unmount; then
102         echo "failed to umount"
103         status=1
104         exit
105 fi
106 echo "Check filesystem"
107 _check_scratch_fs
108 status=$?
109 exit