Whamcloud - gitweb
landing b_cmobd_merge on HEAD
[fs/lustre-release.git] / lustre / tests / cobd_test.sh
1 #export PATH=`dirname $0`/../utils:/r/sbin/:/r/usr/bin/:$PATH
2 export PATH=./../utils:/r/sbin/:/r/usr/bin/:$PATH
3
4 LCTL=${LCTL:-"lctl"}
5 TMP=${TMP:-"/tmp"}
6 TARBALL=${TARBALL:-doc.tgz}
7 DEBUGFS=${DEBUGFS:-debugfs}
8 MNTPATH=${MNTPATH:-"/mnt/lustre"}
9 TARCMD=${TARCMD:-"tar"}
10 UNTARCMD=${UNTARCMD:-"tar -zxvf"}
11 CPCMD=${CPCMD:-"cp -f"}
12 CACHEMDS=${CACHEMDS:-$TMP/mds1-uml}
13 REALMDS=${REALMDS:-$TMP/mds2-uml}
14
15 CACHEOST=${CACHEOST:-$TMP/ost1-uml}
16 REALOST=${REALOST:-$TMP/ost2-uml}
17
18 MDS_CMOBD_INDEX=${MDS_CMOBD_INDEX:-22}
19 OST_CMOBD_INDEX=${OST_CMOBD_INDEX:-20}
20
21 MDS_COBD_INDEX=${MDS_COBD_INDEX:-17}
22 OST_COBD_INDEX=${OST_COBD_INDEX:-14}
23
24
25 if ! [ -e "$TMP/$TARBALL" ]; then
26         echo "$TARBALL did not exist, please give a tar ball for test in your $TMP"
27 fi
28
29 show_filesystem() {
30         local cache_mds=$1
31         local cache_ost=$2
32
33         echo "sleep 20 secs sync fs for show the usages of fs"
34         sync
35         sleep 20 
36         sync
37         echo cache_mds: $1
38         string=`${DEBUGFS} -R stats $cache_mds | tail -n 2`
39         echo $string
40         echo cache_ost: $2
41         string=`${DEBUGFS} -R stats $cache_ost | tail -n 2`
42         echo $string
43 }
44
45 flush_cache() {
46 ${LCTL} << EOF
47 device $OST_CMOBD_INDEX
48 lsync
49 device $MDS_CMOBD_INDEX
50 lsync 
51 EOF
52 }
53
54 cobd_cache_off() {
55 ${LCTL} << EOF
56 device $OST_COBD_INDEX
57 cache_off
58 device $MDS_COBD_INDEX
59 cache_off
60 EOF
61 }
62
63 cobd_cache_on() {
64
65 ${LCTL} << EOF
66 device $OST_COBD_INDEX
67 cache_on
68 device $MDS_COBD_INDEX
69 cache_on
70 EOF
71
72 }
73 cobd_cache_on
74 echo "before test ...."
75 show_filesystem $CACHEMDS $CACHEOST  
76
77 #first step cp the tar to cache dev and untar it
78 echo "cp $TARBALL to lustre dir and untar ..."
79 ${CPCMD} $TMP/${TARBALL} ${MNTPATH}     || exit 1
80 ${UNTARCMD} ${MNTPATH}/${TARBALL} -C ${MNTPATH} > /dev/null || exit 2 
81 #show status of the filesystem
82 echo after cp show the filsystem....
83 show_filesystem $CACHEMDS $CACHEOST  
84 echo .... done!
85
86 #second step flush and cache off these file to the real dev
87 cobd_cache_off
88 flush_cache  || exit 1
89 echo "flush these tar and files....."
90 show_filesystem $CACHEMDS $CACHEOST  
91 echo .... done!
92
93 #third step and write files to real dev
94 mkdir -p $MNTPATH/new
95 $CPCMD -f $TMP/$TARBALL $MNTPATH/new    || exit 1
96 $UNTARCMD $MNTPATH/new/$TARBALL -C $MNTPATH/new > /dev/null || exit 2
97 show_filesystem $CACHEMDS $CACHEOST  
98 echo .... done!
99
100
101