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