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