Whamcloud - gitweb
Fix typo "lusre" -> "lustre"
[fs/lustre-release.git] / lustre / tests / runfailure-mds
1 #!/bin/sh
2
3 SRCDIR="`dirname $0`"
4 . $SRCDIR/common.sh
5
6 NETWORK=tcp
7 LOCALHOST=localhost
8 SERVER=localhost
9 PORT=1234
10
11 setup
12 setup_portals
13
14 new_fs ext2 /tmp/ost 10000
15 OST=$LOOPDEV
16 MDSFS=ext3
17 new_fs ${MDSFS} /tmp/mds 10000
18 MDS=$LOOPDEV
19
20 echo 0xffffffff > /proc/sys/portals/debug
21
22 $OBDCTL <<EOF
23 device 0
24 attach mds
25 setup ${MDS} ${MDSFS}
26 device 1
27 attach obdext2
28 setup ${OST}
29 device 2
30 attach ost
31 setup 1
32 device 3
33 attach osc
34 setup -1
35 quit
36 EOF
37
38 MOUNT='mount -t lustre_lite -o device=3 none /mnt/lustre'
39 $MOUNT
40
41 test_fail() {
42         echo $1 > /proc/sys/lustre/fail_loc
43         shift
44         echo "Running '$*'"
45         $* 
46
47         echo "Cleaning up and restarting MDS"
48         umount /mnt/lustre
49         $OBDCTL <<- EOF
50         device 0
51         cleanup
52         detach
53         quit
54         EOF
55
56         echo 0 > /proc/sys/lustre/fail_loc
57
58         $OBDCTL <<- EOF
59         device 0
60         attach mds
61         setup ${MDS} ${MDSFS}
62         quit
63         EOF
64         $MOUNT
65 }
66
67 #set -vx
68
69 touch /mnt/lustre/foo
70 chmod a+x /mnt/lustre/foo
71 sync
72
73 # OBD_FAIL_MDS_REINT_SETATTR_WRITE - MDS will discard data from setattr
74 test_fail 0x10a chmod 000 /mnt/lustre/foo
75 ls -l /mnt/lustre/foo
76 [ ! -x /mnt/lustre/foo ] && echo "/mnt/lustre/foo is not executable!" 1>&2 && exit -1
77
78 # OBD_FAIL_MDS_REINT_CREATE_WRITE - MDS will not create the file
79 test_fail 0x10c touch /mnt/lustre/bar
80 ls /mnt/lustre/bar
81 [ $? -eq 0 ] && echo "/mnt/lustre/bar was created!" 1>&2 && exit -1
82
83 # OBD_FAIL_MDS_REINT_UNLINK_WRITE - MDS will discard data from unlink
84 test_fail 0x10e rm /mnt/lustre/foo
85 ls /mnt/lustre/foo
86 [ $? -eq 1 ] && echo "/mnt/lustre/foo has been removed!" 1>&2 && exit -1
87
88 # OBD_FAIL_MDS_REINT_RENAME_WRITE - MDS will discard data from rename
89 test_fail 0x112 mv /mnt/lustre/foo /mnt/lustre/bar
90 ls /mnt/lustre/foo /mnt/lustre/bar
91 [ ! -f /mnt/lustre/foo -o -f /mnt/lustre/bar ] && \
92         echo "/mnt/lustre/foo has been renamed to bar!" 1>&2 && exit -1
93
94 echo "Done."