Whamcloud - gitweb
- more checks and verbosity in test_16 of conf-sanity.sh to see what happens when...
[fs/lustre-release.git] / lustre / tests / conf-sanity.sh
1 #!/bin/bash
2 # requirement:
3 #       add uml1 uml2 uml3 in your /etc/hosts
4
5 # FIXME - there is no reason to use all of these different
6 #   return codes, espcially when most of them are mapped to something
7 #   else anyway.  The combination of test number and return code
8 #   figure out what failed.
9
10 set -e
11
12 SRCDIR=`dirname $0`
13 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
14
15 LUSTRE=${LUSTRE:-`dirname $0`/..}
16 RLUSTRE=${RLUSTRE:-$LUSTRE}
17 MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre}
18
19 . $LUSTRE/tests/test-framework.sh
20
21 init_test_env $@
22
23 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
24
25 gen_config() {
26         rm -f $XMLCONFIG
27
28         add_mds mds1 --dev $MDSDEV --size $MDSSIZE
29         add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES\
30             --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
31         add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
32         add_client client mds1 --lov lov1 --path $MOUNT
33 }
34
35 gen_second_config() {
36         rm -f $XMLCONFIG
37
38         add_mds mds2 --dev $MDSDEV --size $MDSSIZE
39         add_lov lov2 mds2 --stripe_sz $STRIPE_BYTES\
40             --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
41         add_ost ost2 --lov lov2 --dev $OSTDEV --size $OSTSIZE
42         add_client client --mds mds2 --lov lov2 --path $MOUNT2
43 }
44
45 start_mds() {
46         echo "start mds1 service on `facet_active_host mds1`"
47         start mds1 --reformat $MDSLCONFARGS  || return 94
48 }
49 stop_mds() {
50         echo "stop mds1 service on `facet_active_host mds1`"
51         stop mds1 $@  || return 97
52 }
53
54 start_ost() {
55         echo "start ost service on `facet_active_host ost`"
56         start ost --reformat $OSTLCONFARGS  || return 95
57 }
58
59 stop_ost() {
60         echo "stop ost service on `facet_active_host ost`"
61         stop ost $@  || return 98
62 }
63
64 mount_client() {
65         local MOUNTPATH=$1
66         echo "mount lustre on ${MOUNTPATH}....."
67         zconf_mount `hostname`  $MOUNTPATH  || return 96
68 }
69
70 umount_client() {
71         local MOUNTPATH=$1
72         echo "umount lustre on ${MOUNTPATH}....."
73         zconf_umount `hostname`  $MOUNTPATH || return 97
74 }
75
76 manual_umount_client(){
77         echo "manual umount lustre on ${MOUNTPATH}...."
78         do_facet  client "umount $MOUNT"
79 }
80
81 setup() {
82         start_ost
83         start_mds
84         mount_client $MOUNT
85 }
86
87 cleanup() {
88         umount_client $MOUNT || return 200
89         stop_mds || return 201
90         stop_ost || return 202
91         # catch case where these return just fine, but modules are still not unloaded
92         /sbin/lsmod | grep -q portals
93         if [ 1 -ne $? ]; then
94                 echo "modules still loaded..."
95                 return 203
96         fi
97 }
98
99 check_mount() {
100         do_facet client "touch $DIR/a" || return 71     
101         do_facet client "rm $DIR/a" || return 72        
102         echo "setup single mount lustre success"
103 }
104
105 check_mount2() {
106         do_facet client "touch $DIR/a" || return 71     
107         do_facet client "rm $DIR/a" || return 72        
108         do_facet client "touch $DIR2/a" || return 73    
109         do_facet client "rm $DIR2/a" || return 74       
110         echo "setup double mount lustre success"
111 }
112
113 build_test_filter
114
115 #create single point mountpoint
116
117 gen_config
118
119
120 test_0() {
121         start_ost
122         start_mds       
123         mount_client $MOUNT
124         check_mount || return 41
125         cleanup || return $?
126 }
127 run_test 0 "single mount setup"
128
129 test_1() {
130         start_ost
131         echo "start ost second time..."
132         start ost --reformat $OSTLCONFARGS
133         start_mds       
134         mount_client $MOUNT
135         check_mount || return 42
136         cleanup || return $?
137 }
138 run_test 1 "start up ost twice"
139
140 test_2() {
141         start_ost
142         start_mds       
143         echo "start mds second time.."
144         start mds1 --reformat $MDSLCONFARGS
145         
146         mount_client $MOUNT
147         check_mount || return 43
148         cleanup || return $?
149 }
150 run_test 2 "start up mds twice"
151
152 test_3() {
153         setup
154         mount_client $MOUNT
155
156         check_mount || return 44
157         
158         umount_client $MOUNT    
159         cleanup  || return $?
160 }
161 run_test 3 "mount client twice"
162
163 test_4() {
164         setup
165         touch $DIR/$tfile || return 85
166         stop_ost --force
167         cleanup
168         eno=$?
169         # ok for ost to fail shutdown
170         if [ 202 -ne $eno ]; then
171                 return $eno;
172         fi
173         return 0
174 }
175 run_test 4 "force cleanup ost, then cleanup"
176
177 test_5() {
178         setup
179         touch $DIR/$tfile || return 1
180         stop_mds --force || return 2
181
182         # cleanup may return an error from the failed
183         # disconnects; for now I'll consider this successful
184         # if all the modules have unloaded.
185         umount $MOUNT &
186         UMOUNT_PID=$!
187         sleep 2
188         echo "killing umount"
189         kill -TERM $UMOUNT_PID
190         echo "waiting for umount to finish"
191         wait $UMOUNT_PID
192
193         # cleanup client modules
194         $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
195         
196         # stop_mds is a no-op here, and should not fail
197         stop_mds  || return 4
198         stop_ost || return 5
199
200         lsmod | grep -q portals && return 6
201         return 0
202 }
203 run_test 5 "force cleanup mds, then cleanup"
204
205 test_5b() {
206         start_ost
207         start_mds
208         stop_mds
209
210         [ -d $MOUNT ] || mkdir -p $MOUNT
211         $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
212         llmount $mds_HOST://mds1_svc/client_facet $MOUNT  && exit 1
213
214         # cleanup client modules
215         $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
216         
217         # stop_mds is a no-op here, and should not fail
218         stop_mds || return 2
219         stop_ost || return 3
220
221         lsmod | grep -q portals && return 4 
222         return 0
223
224 }
225 run_test 5b "mds down, cleanup after failed mount (bug 2712)"
226
227 test_5c() {
228         start_ost
229         start_mds
230
231         [ -d $MOUNT ] || mkdir -p $MOUNT
232         $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
233         llmount $mds_HOST://wrong_mds1_svc/client_facet $MOUNT  && return 1
234
235         # cleanup client modules
236         $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
237         
238         stop_mds || return 2
239         stop_ost || return 3
240
241         lsmod | grep -q portals && return 4
242         return 0
243
244 }
245 run_test 5c "cleanup after failed mount (bug 2712)"
246
247 test_5d() {
248        start_ost
249        start_mds
250        stop_ost --force
251
252        [ -d $MOUNT ] || mkdir -p $MOUNT
253        $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
254        llmount $mds_HOST://mds1_svc/client_facet $MOUNT  || return 1
255
256        umount $MOUNT || return 2
257        # cleanup client modules
258        $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
259
260        stop_mds || return 3
261
262        lsmod | grep -q portals && return 4
263        return 0
264
265 }
266 run_test 5d "ost down, don't crash during mount attempt"
267
268 test_6() {
269         setup
270         manual_umount_client
271         mount_client ${MOUNT} || return 87
272         touch $DIR/a || return 86
273         cleanup  || return $?
274 }
275 run_test 6 "manual umount, then mount again"
276
277 test_7() {
278         setup
279         manual_umount_client
280         cleanup || return $?
281 }
282 run_test 7 "manual umount, then cleanup"
283
284 test_8() {
285         start_ost
286         start_mds
287
288         mount_client $MOUNT
289         mount_client $MOUNT2
290
291         check_mount2 || return 45
292         umount $MOUNT
293         umount_client $MOUNT2
294         
295         stop_mds
296         stop_ost
297 }
298 run_test 8 "double mount setup"
299
300 test_9() {
301         # backup the old values of PTLDEBUG and SUBSYSTEM
302         OLDPTLDEBUG=$PTLDEBUG
303         OLDSUBSYSTEM=$SUBSYSTEM
304
305         # generate new configuration file with lmc --ptldebug and --subsystem
306         PTLDEBUG="trace"
307         SUBSYSTEM="mdc"
308         gen_config
309
310         # check the result of lmc --ptldebug/subsystem
311         start_ost
312         start_mds
313         mount_client $MOUNT
314         CHECK_PTLDEBUG="`cat /proc/sys/portals/debug`"
315         if [ $CHECK_PTLDEBUG = "1" ]; then
316            echo "lmc --debug success"
317         else
318            echo "lmc --debug: want 1, have $CHECK_PTLDEBUG"
319            return 1
320         fi
321         CHECK_SUBSYSTEM="`cat /proc/sys/portals/subsystem_debug`"
322         if [ $CHECK_SUBSYSTEM = "2" ]; then
323            echo "lmc --subsystem success"
324         else
325            echo "lmc --subsystem: want 2, have $CHECK_SUBSYSTEM"
326            return 1
327         fi
328         check_mount || return 41
329         cleanup || return $?
330
331         # the new PTLDEBUG/SUBSYSTEM used for lconf --ptldebug/subsystem
332         PTLDEBUG="inode+trace"
333         SUBSYSTEM="mds+ost"
334
335         # check lconf --ptldebug/subsystem overriding lmc --ptldebug/subsystem
336         start_ost
337         start_mds
338         CHECK_PTLDEBUG="`do_facet mds1 cat /proc/sys/portals/debug`"
339         if [ $CHECK_PTLDEBUG = "3" ]; then
340            echo "lconf --debug success"
341         else
342            echo "lconf --debug: want 3, have $CHECK_PTLDEBUG"
343            return 1
344         fi
345         CHECK_SUBSYSTEM="`do_facet mds1 cat /proc/sys/portals/subsystem_debug`"
346         if [ $CHECK_SUBSYSTEM = "20" ]; then
347            echo "lconf --subsystem success"
348         else
349            echo "lconf --subsystem: want 20, have $CHECK_SUBSYSTEM"
350            return 1
351         fi
352         mount_client $MOUNT
353         check_mount || return 41
354         cleanup || return $?
355
356         # resume the old configuration
357         PTLDEBUG=$OLDPTLDEBUG
358         SUBSYSTEM=$OLDSUBSYSTEM
359         gen_config
360 }
361
362 run_test 9 "test --ptldebug and --subsystem for lmc and lconf"
363
364 test_10() {
365         echo "generate configuration with the same name for node and mds"
366         OLDXMLCONFIG=$XMLCONFIG
367         XMLCONFIG="broken.xml"
368         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
369         facet="mds1"
370         rm -f ${facet}active
371         add_facet $facet
372         echo "the name for node and mds is the same"
373         do_lmc --add mds --node ${facet}_facet --mds ${facet}_facet \
374             --dev $MDSDEV --size $MDSSIZE || return $?
375         do_lmc --add lov --mds ${facet}_facet --lov lov1 --stripe_sz \
376             $STRIPE_BYTES --stripe_cnt $STRIPES_PER_OBJ \
377             --stripe_pattern 0 || return $?
378         add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
379         facet="client"
380         add_facet $facet --lustre_upcall $UPCALL
381         do_lmc --add mtpt --node ${facet}_facet --mds mds1_facet \
382             --lov lov1 --path $MOUNT
383
384         echo "mount lustre"
385         start_ost
386         start_mds
387         mount_client $MOUNT
388         check_mount || return 41
389         cleanup || return $?
390
391         echo "Success!"
392         XMLCONFIG=$OLDXMLCONFIG
393 }
394 run_test 10 "mount lustre with the same name for node and mds"
395
396 test_11() {
397         OLDXMLCONFIG=$XMLCONFIG
398         XMLCONFIG="conf11.xml"
399
400         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
401         add_mds mds1 --dev $MDSDEV --size $MDSSIZE
402         add_ost ost --dev $OSTDEV --size $OSTSIZE
403         add_client client mds1 --path $MOUNT --ost ost_svc || return $?
404         echo "Default lov config success!"
405
406         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
407         add_mds mds1 --dev $MDSDEV --size $MDSSIZE
408         add_ost ost --dev $OSTDEV --size $OSTSIZE
409         add_client client mds1 --path $MOUNT && return $?
410         echo "--add mtpt with neither --lov nor --ost will return error"
411
412         echo ""
413         echo "Success!"
414         XMLCONFIG=$OLDXMLCONFIG
415 }
416 run_test 11 "use default lov configuration (should return error)"
417
418 test_12() {
419         OLDXMLCONFIG=$XMLCONFIG
420         XMLCONFIG="batch.xml"
421         BATCHFILE="batchfile"
422
423         # test double quote
424         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
425         [ -f "$BATCHFILE" ] && rm -f $BATCHFILE
426         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
427         echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128\"" >> $BATCHFILE
428         # --mkfsoptions "-I 128"
429         do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
430         if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
431                 echo "matched double quote success"
432         else
433                 echo "matched double quote fail"
434                 return 1
435         fi
436         rm -f $XMLCONFIG
437         rm -f $BATCHFILE
438         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
439         echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128" >> $BATCHFILE
440         # --mkfsoptions "-I 128
441         do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
442         echo "unmatched double quote should return error"
443
444         # test single quote
445         rm -f $BATCHFILE
446         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
447         echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128'" >> $BATCHFILE
448         # --mkfsoptions '-I 128'
449         do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
450         if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
451                 echo "matched single quote success"
452         else
453                 echo "matched single quote fail"
454                 return 1
455         fi
456         rm -f $XMLCONFIG
457         rm -f $BATCHFILE
458         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
459         echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128" >> $BATCHFILE
460         # --mkfsoptions '-I 128
461         do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
462         echo "unmatched single quote should return error"
463
464         # test backslash
465         rm -f $BATCHFILE
466         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
467         echo "--add mds --node localhost --mds mds1 --mkfsoptions \-\I\ \128" >> $BATCHFILE
468         # --mkfsoptions \-\I\ \128
469         do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
470         if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
471                 echo "backslash followed by a whitespace/letter success"
472         else
473                 echo "backslash followed by a whitespace/letter fail"
474                 return 1
475         fi
476         rm -f $XMLCONFIG
477         rm -f $BATCHFILE
478         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
479         echo "--add mds --node localhost --mds mds1 --mkfsoptions -I\ 128\\" >> $BATCHFILE
480         # --mkfsoptions -I\ 128\
481         do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
482         echo "backslash followed by nothing should return error"
483
484         rm -f $BATCHFILE
485         XMLCONFIG=$OLDXMLCONFIG
486 }
487 run_test 12 "lmc --batch, with single/double quote, backslash in batchfile"
488
489 test_13() {
490         OLDXMLCONFIG=$XMLCONFIG
491         XMLCONFIG="conf13-1.xml"
492         SECONDXMLCONFIG="conf13-2.xml"
493
494         # check long uuid will be truncated properly and uniquely
495         echo "To generate XML configuration file(with long ost name): $XMLCONFIG"
496         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
497         do_lmc --add net --node localhost --nid localhost.localdomain --nettype tcp
498         do_lmc --add mds --node localhost --mds mds1_name_longer_than_31characters
499         do_lmc --add mds --node localhost --mds mds2_name_longer_than_31characters
500         if [ ! -f "$XMLCONFIG" ]; then
501                 echo "Error:no file $XMLCONFIG created!"
502                 return 1
503         fi
504         EXPECTEDMDS1UUID="e_longer_than_31characters_UUID"
505         EXPECTEDMDS2UUID="longer_than_31characters_UUID_2"
506         FOUNDMDS1UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '1p' \
507                        | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
508         FOUNDMDS2UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '2p' \
509                        | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
510         if ([ $EXPECTEDMDS1UUID = $FOUNDMDS1UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS2UUID ]) || \
511            ([ $EXPECTEDMDS1UUID = $FOUNDMDS2UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS1UUID ]); then
512                 echo "Success:long uuid truncated successfully and being unique."
513         else
514                 echo "Error:expected uuid for mds1 and mds2: $EXPECTEDMDS1UUID; $EXPECTEDMDS2UUID"
515                 echo "but:     found uuid for mds1 and mds2: $FOUNDMDS1UUID; $FOUNDMDS2UUID"
516                 return 1
517         fi
518
519         # check multiple invocations for lmc generate same XML configuration file
520         rm -f $XMLCONFIG
521         echo "Generate the first XML configuration file"
522         gen_config
523         echo "mv $XMLCONFIG to $SECONDXMLCONFIG"
524         mv $XMLCONFIG $SECONDXMLCONFIG || return $?
525         echo "Generate the second XML configuration file"
526         gen_config
527         if [ `diff $XMLCONFIG $SECONDXMLCONFIG | wc -l` -eq 0 ]; then
528                 echo "Success:multiple invocations for lmc generate same XML file"
529         else
530                 echo "Error: multiple invocations for lmc generate different XML file"
531                 return 1
532         fi
533
534         rm -f $XMLCONFIG
535         rm -f $SECONDXMLCONFIG
536         XMLCONFIG=$OLDXMLCONFIG
537 }
538 run_test 13 "check new_uuid of lmc operating correctly"
539
540 test_14() {
541         rm -f $XMLCONFIG
542
543         # create xml file with --mkfsoptions for ost
544         echo "create xml file with --mkfsoptions for ost"
545         add_mds mds1 --dev $MDSDEV --size $MDSSIZE
546         add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES\
547             --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
548         add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE \
549             --mkfsoptions "-Llabel_conf_14"
550         add_client client mds1 --lov lov1 --path $MOUNT
551
552         FOUNDSTRING=`awk -F"<" '/<mkfsoptions>/{print $2}' $XMLCONFIG`
553         EXPECTEDSTRING="mkfsoptions>-Llabel_conf_14"
554         if [ $EXPECTEDSTRING != $FOUNDSTRING ]; then
555                 echo "Error: expected: $EXPECTEDSTRING; found: $FOUNDSTRING"
556                 return 1
557         fi
558         echo "Success:mkfsoptions for ost written to xml file correctly."
559
560         # mount lustre to test lconf mkfsoptions-parsing
561         echo "mount lustre"
562         start_ost
563         start_mds
564         mount_client $MOUNT || return $?
565         if [ -z "`dumpe2fs -h $OSTDEV | grep label_conf_14`" ]; then
566                 echo "Error: the mkoptions not applied to mke2fs of ost."
567                 return 1
568         fi
569         cleanup
570         echo "lconf mkfsoptions for ost success"
571
572         gen_config
573 }
574 run_test 14 "test mkfsoptions of ost for lmc and lconf"
575
576 cleanup_15() {
577         trap 0
578         [ -f $MOUNTLUSTRE ] && echo "remove $MOUNTLUSTRE" && rm -f $MOUNTLUSTRE
579         if [ -f $MOUNTLUSTRE.sav ]; then
580                 echo "return original $MOUNTLUSTRE.sav to $MOUNTLUSTRE"
581                 mv $MOUNTLUSTRE.sav $MOUNTLUSTRE
582         fi
583 }
584
585 test_15() {
586         start_ost
587         start_mds
588         echo "mount lustre on ${MOUNT} with $MOUNTLUSTRE....."
589         if [ -f "$MOUNTLUSTRE" ]; then
590                 echo "save $MOUNTLUSTRE to $MOUNTLUSTRE.sav"
591                 mv $MOUNTLUSTRE $MOUNTLUSTRE.sav
592         fi
593         [ -f "$MOUNTLUSTRE" ] && echo "can't move $MOUNTLUSTRE" && return 40
594         trap cleanup_15 EXIT INT
595         [ ! `cp $LUSTRE/utils/llmount $MOUNTLUSTRE` ] || return $?
596         do_node `hostname` mkdir -p $MOUNT 2> /dev/null
597         # load llite module on the client if it isn't in /lib/modules
598         do_node `hostname` lconf --nosetup --node client_facet $XMLCONFIG
599         do_node `hostname` mount -t lustre -o nettype=$NETTYPE \
600                 `facet_active_host mds1`:/mds1_svc/client_facet $MOUNT ||return $?
601         echo "mount lustre on $MOUNT with $MOUNTLUSTRE: success"
602         [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
603         check_mount || return 41
604         do_node `hostname` umount $MOUNT
605
606         [ -f "$MOUNTLUSTRE" ] && rm -f $MOUNTLUSTRE
607         echo "mount lustre on ${MOUNT} without $MOUNTLUSTRE....."
608         do_node `hostname` mount -t lustre -o nettype=$NETTYPE \
609                 `facet_active_host mds1`:/mds1_svc/client_facet $MOUNT &&return $?
610         echo "mount lustre on $MOUNT without $MOUNTLUSTRE failed as expected"
611         cleanup || return $?
612         cleanup_15
613 }
614 run_test 15 "zconf-mount without /sbin/mount.lustre (should return error)"
615
616 is_digit() {
617     local value=$1
618     echo $value | grep -q "^[[:digit:]]*$"
619     return $?
620 }
621
622 test_16() {
623         TMPMTPT="/mnt/conf16"
624                                                                                                                              
625         if [ ! -f "$MDSDEV" ]; then
626             echo "no $MDSDEV existing, so mount Lustre to create one"
627             start_ost
628             start_mds
629             mount_client $MOUNT
630             check_mount || return 41
631             cleanup || return $?
632          fi
633                                                                                                                              
634         echo "change the mode of $MDSDEV/OBJECTS,LOGS,PENDING to 555"
635         [ -d $TMPMTPT ] || mkdir -p $TMPMTPT
636         mount -o loop -t ext3 $MDSDEV $TMPMTPT || return $?
637         chmod 555 $TMPMTPT/OBJECTS || return $?
638         chmod 555 $TMPMTPT/LOGS || return $?
639         chmod 555 $TMPMTPT/PENDING || return $?
640         umount $TMPMTPT || return $?
641                                                                                                                              
642         echo "mount Lustre to change the mode of OBJECTS/LOGS/PENDING, then umount Lustre"
643         start_ost
644         start_mds
645         mount_client $MOUNT
646         check_mount || return 41
647         cleanup || return $?
648                                                                                                                              
649         echo "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
650         EXPECTEDOBJECTSMODE=`debugfs -R "stat OBJECTS" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
651         EXPECTEDLOGSMODE=`debugfs -R "stat LOGS" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
652         EXPECTEDPENDINGMODE=`debugfs -R "stat PENDING" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
653
654         # check if values are empty
655         test "$EXPECTEDOBJECTSMODE" = "x" && EXPECTEDOBJECTSMODE="<empty>"
656         test "$EXPECTEDLOGSMODE" = "x" && EXPECTEDLOGSMODE="<empty>"
657         test "$EXPECTEDPENDINGMODE" = "x" && EXPECTEDPENDINGMODE="<empty>"
658
659         # check if values are valid digits
660         is_digit $EXPECTEDOBJECTSMODE || {
661             echo "Invalid OBJECTS mode obtained from debugfs: $EXPECTEDOBJECTSMODE"
662             return 42
663         }
664
665         is_digit $EXPECTEDLOGSMODE || {
666             echo "Invalid LOGS mode obtained from debugfs: $EXPECTEDLOGSMODE"
667             return 42
668         }
669
670         is_digit $EXPECTEDPENDINGMODE || {
671             echo "Invalid PINDING mode obtained from debugfs: $EXPECTEDPENDINGMODE"
672             return 42
673         }
674
675         # check if values are those we expected
676         if [ "x$EXPECTEDOBJECTSMODE" = "x0777" ]; then
677                 echo "Success: Lustre change the mode of OBJECTS correctly"
678         else
679                 echo "Error: Lustre does not change the mode of OBJECTS properly"
680                 echo "Expected value: 0777, actual one: $EXPECTEDOBJECTSMODE"
681                 return 1
682         fi
683                                                                                                                              
684         if [ "x$EXPECTEDLOGSMODE" = "x0777" ]; then
685                 echo "Success: Lustre change the mode of LOGS correctly"
686         else
687                 echo "Error: Lustre does not change the mode of LOGS properly"
688                 echo "Expected value: 0777, actual one: $EXPECTEDLOGSMODE"
689                 return 1
690         fi
691                                                                                                                              
692         if [ "x$EXPECTEDPENDINGMODE" = "x0777" ]; then
693                 echo "Success: Lustre change the mode of PENDING correctly"
694         else
695                 echo "Error: Lustre does not change the mode of PENDING properly"
696                 echo "Expected value: 0777, actual one: $EXPECTEDPENDINGMODE"
697                 return 1
698         fi
699 }
700 run_test 16 "verify that lustre will correct the mode of OBJECTS/LOGS/PENDING"
701
702 test_17() {
703         TMPMTPT="/mnt/conf17"
704
705         if [ ! -f "$MDSDEV" ]; then
706             echo "no $MDSDEV existing, so mount Lustre to create one"
707             start_ost
708             start_mds
709             mount_client $MOUNT
710             check_mount || return 41
711             cleanup || return $?
712         fi
713
714         echo "Remove mds config log"
715         [ -d $TMPMTPT ] || mkdir -p $TMPMTPT
716         mount -o loop -t ext3 $MDSDEV $TMPMTPT || return $?
717         rm -f $TMPMTPT/LOGS/mds1_svc || return $?
718         umount $TMPMTPT || return $?
719
720         start_ost
721         start mds1 $MDSLCONFARGS && return 42
722         cleanup || return $?
723 }
724 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936)"
725
726 test_18() {
727         [ -f $MDSDEV ] && echo "remove $MDSDEV" && rm -f $MDSDEV
728         echo "mount mds with large journal..."
729         OLDMDSSIZE=$MDSSIZE
730         MDSSIZE=2000000
731         gen_config
732                                                                                                                              
733         echo "mount lustre system..."
734         start_ost
735         start_mds
736         mount_client $MOUNT
737         check_mount || return 41
738                                                                                                                              
739         echo "check journal size..."
740         FOUNDJOURNALSIZE=`debugfs -R "stat <8>" $MDSDEV | awk '/Size: / { print $6; exit;}'`
741         if [ $FOUNDJOURNALSIZE = "79691776" ]; then
742                 echo "Success:lconf creates large journals"
743         else
744                 echo "Error:lconf not create large journals correctly"
745                 echo "expected journal size: 79691776(76M), found journal size: $FOUNDJOURNALSIZE"
746                 return 1
747         fi
748                                                                                                                              
749         cleanup || return $?
750                                                                                                                              
751         MDSSIZE=$OLDMDSSIZE
752         gen_config
753 }
754 run_test 18 "check lconf creates large journals"
755
756 equals_msg "Done"