+test_111() {
+ [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
+ [[ $(facet_active_host mds1) = $(facet_active_host mds2) ]] ||
+ skip "MDT0 and MDT1 should be on the same node"
+
+ mkdir $DIR1/$tdir
+ $LFS mkdir -i 0 $DIR1/$tdir/mdt0dir
+ $LFS mkdir -i 1 $DIR1/$tdir/mdt1dir
+
+ mkdir $DIR1/$tdir/mdt0dir/foodir
+ touch $DIR1/$tdir/mdt0dir/foodir/{file1,file2}
+
+ $MULTIOP $DIR2/$tdir/mdt0dir/foodir/file2 Ow4096_c &
+ MULTIOP_PID=$!
+ ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2
+
+ #define OBD_FAIL_MDS_LINK_RENAME_RACE 0x18a
+ do_facet mds1 $LCTL set_param fail_loc=0x8000018a
+
+ ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2x &
+ sleep 1
+
+ rm $DIR2/$tdir/mdt1dir/file2
+ sleep 1
+
+ mv $DIR2/$tdir/mdt0dir/foodir/file1 $DIR2/$tdir/mdt0dir/foodir/file2
+ sleep 1
+
+ kill $MULTIOP_PID
+ wait
+ rm -r $DIR1/$tdir || error "Removing test dir failed"
+}
+run_test 111 "A racy rename/link an open file should not cause fs corruption"
+
+test_112() {
+ (( MDSCOUNT >= 2 )) ||
+ skip "We need at least 2 MDTs for this test"
+
+ (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
+ skip "Need server version at least 2.14.54"
+
+ local rr
+ local count
+
+ rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
+ rr=${rr%%%}
+ stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
+
+ mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
+ $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
+ $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
+ error "setdirstripe s3 failed"
+ $LCTL set_param lmv.*.qos_threshold_rr=90
+ mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
+ count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
+ (( count == 64 )) || error "only $count subdirs created on MDT0"
+
+ $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
+ error "setdirstripe s3 failed"
+ mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
+ count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
+ (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
+}
+run_test 112 "update max-inherit in default LMV"
+
+test_113 () {
+ (( MDS1_VERSION >= $(version_code 2.15.50) )) ||
+ skip "Need server version at least 2.15.50"
+
+ local instance
+ local nid
+
+ instance=$($LFS getname -i $DIR1) ||
+ error "cannot get instance of $DIR1"
+
+ $LFS check osts $DIR1 | grep $instance ||
+ error "cannot find OSTs of instance $instance"
+
+ $LFS check osts $DIR1 | grep -v $instance
+ if (( $? == 0 )); then
+ error "find OSTs other than instance $instance"
+ fi
+
+ $LFS check osts | grep $instance ||
+ error "cannot find other OSTs"
+
+ nid=$(df $DIR2 | tail -1 | sed 's%:/.*%%') ||
+ error "cannot parse nid for $DIR2"
+
+ $LFS check mgts $DIR2 | grep MGC$nid ||
+ error "cannot find mgc of $nid"
+
+ $LFS check mgts $DIR2 | grep -v MGC$nid
+ if (( $? == 0 )); then
+ error "find MGTs other than nid $nid"
+ fi
+}
+run_test 113 "check servers of specified fs"
+
+check_default_lmv() {
+ local dir=$1
+
+ local enabled
+ local dmv
+ local index
+ local count
+ local inherit
+ local inherit_rr
+ local raw
+
+ enabled=$(do_facet mds1 \
+ $LCTL get_param -n mdt.*-MDT0000*.enable_dmv_implicit_inherit)
+
+ dmv=$($LFS getdirstripe -D $dir)
+ echo $dir $dmv
+ index=$(echo $dmv | awk '{ print $4 }')
+ (( index == $2 )) || error "$dir default stripe index $index != $2"
+
+ count=$(echo $dmv | awk '{ print $2 }')
+ (( count == $3 )) || error "$dir default stripe count $count != $3"
+
+ inherit=$(echo $dmv | awk '{ print $8 }')
+ (( inherit == $4 )) || error "$dir default max-inherit $inherit != $4"
+
+ if [ $index -eq -1 ]; then
+ inherit_rr=$(echo $dmv | awk '{ print $10 }')
+ (( inherit_rr == $5 )) ||
+ error "$dir default max-inherit-rr $inherit_rr != $5"
+ fi
+
+ # with --raw, print default LMV stored in inode, otherwise print nothing
+ raw=$($LFS getdirstripe -D --raw $dir)
+ if (( enabled == 1 )); then
+ [ -z $raw ] ||
+ error "implicit inherited DMV is printed with --raw"
+ else
+ # if disabled, dmv is stored in inode, which will always
+ # print max-inherit-rr
+ echo $dir $raw
+ [[ $raw =~ $dmv.* ]] || error "$dir raw $raw != dmv $dmv"
+ fi
+}
+
+test_dmv_imp_inherit() {
+ local dmv
+ local raw
+ local index
+ local count
+ local inherit
+ local inherit_rr
+
+ rm -rf $DIR/$tdir || error "rm $tdir failed"
+ mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
+
+ # set dir default LMV
+ $LFS setdirstripe -D -c1 -X4 --max-inherit-rr 2 $DIR/$tdir ||
+ error "setdirstripe -D $tdir failed"
+ dmv=$($LFS getdirstripe -D $DIR/$tdir)
+ raw=$($LFS getdirstripe -D --raw $DIR/$tdir)
+ [ "$dmv" == "$raw" ] || error "$dmv != $raw"
+
+ mkdir -p $DIR/$tdir/l1/l2/l3 || error "mkdir $DIR/$tdir/l1/l2/l3 failed"
+ check_default_lmv $DIR/$tdir/l1/l2/l3 -1 1 1 0
+ check_default_lmv $DIR2/$tdir/l1/l2/l3 -1 1 1 0
+
+ # below tests are valid only when this feature is enabled
+ local enabled=$(do_facet mds1 \
+ $LCTL get_param -n mdt.*-MDT0000*.enable_dmv_implicit_inherit)
+
+ (( enabled == 1 )) || return 0
+
+ # set l2 default LMV, dmv of l3 should change immediately
+ $LFS setdirstripe -D -i1 -c2 -X4 $DIR/$tdir/l1/l2 ||
+ error "setdirstripe -D $tdir/l1/l2 failed"
+
+ check_default_lmv $DIR/$tdir/l1/l2/l3 1 2 3
+ check_default_lmv $DIR2/$tdir/l1/l2/l3 1 2 3
+
+ # change tdir default LMV, dmv of l3 should be unchanged because dmv
+ # of l2 is explicitly set
+ $LFS setdirstripe -D -i2 -c2 -X3 $DIR/$tdir ||
+ error "setdirstripe -D $tdir failed"
+
+ check_default_lmv $DIR/$tdir/l1 2 2 2
+ check_default_lmv $DIR2/$tdir/l1 2 2 2
+ check_default_lmv $DIR/$tdir/l1/l2/l3 1 2 3
+ check_default_lmv $DIR2/$tdir/l1/l2/l3 1 2 3
+}
+
+test_114() {
+ (( MDSCOUNT >= 2 )) ||
+ skip "We need at least 2 MDTs for this test"
+
+ (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
+ skip "Need server version at least 2.15.54.45"
+
+ test_dmv_imp_inherit
+
+ # disable dmv_imp_inherit to simulate old client
+ local mdts=$(comma_list $(mdts_nodes))
+
+ do_nodes $mdts $LCTL set_param -n \
+ mdt.*MDT*.enable_dmv_implicit_inherit=0
+ test_dmv_imp_inherit
+ do_nodes $mdts $LCTL set_param -n \
+ mdt.*MDT*.enable_dmv_implicit_inherit=1
+}
+run_test 114 "implicit default LMV inherit"
+
+test_115() {
+ local td=$DIR/$tdir
+
+ [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
+
+ mkdir_on_mdt0 $td || error "can't mkdir"
+ # turn it htree (don't really needed)
+ createmany -m $td/f 3000 || error "can't createmany"
+
+ # here is an example of debugfs output for htree command:
+ # Entry #0: Hash 0x00000000, block 27
+ # Reading directory block 27, phys 16760
+ # 938 0x0016fb58-7f3d21f5 (32) f775 834 0x001db8c8-d31a4e0e (32) f671
+ # 1085 0x0040cb70-4498abd4 (32) f922 1850 0x0066a1e6-f6f0dc69 (32) f1687
+ # 2005 0x006c1a46-ef466058 (32) f1842 2025 0x007e64d4-8b28b734 (32) f1862
+ # 642 0x008b53a0-77adc601 (32) f479 447 0x009ec152-af54eea3 (32) f284
+ # 1740 0x00c38f56-ed310e61 (32) f1577 2165 0x00cdfd66-f429a93f (32) f2002
+ # 930 0x00d7ada4-b80421c9 (32) f767 1946 0x00da6a7a-e8080600 (32) f1783
+ # 273 0x00f8ea00-760bf97c (32) f110 1589 0x0103c4ee-94fad5dd (32) f1426
+ # 1383 0x01193516-83120b48 (32) f1220 2379 0x01431e3c-e85b5bd9 (32) f2216
+ #
+ # find couple names in a same htree block of the same size
+ mdt_dev=$(facet_device $SINGLEMDS)
+ de=( $(do_facet $SINGLEMDS "debugfs -c -R 'htree /ROOT/$tdir' $mdt_dev" |
+ awk '/Reading directory block/ { getline; print $4,$8; exit; }' ))
+ local de1=${de[0]}
+ local de2=${de[1]}
+ [[ $de1 == "" || $de2 == "" ]] && error "de1=$de1 de2=$de2"
+ echo "USE: $de1 $de2"
+ # release one mkdir will lookup
+ rm $DIR/$tdir/$de2
+#define OBD_FAIL_MDS_PAUSE_CREATE_AFTER_LOOKUP 0x2401
+ do_facet $SINGLEMDS $LCTL set_param fail_loc=0x80002401 fail_val=5
+ mkdir $DIR/$tdir/$de2 &
+ sleep 0.3
+ local PID1=$!
+ # recreate $de2
+ mkdir $DIR2/$tdir/$de2
+ # release space $de1 (should be enough to save $de2)
+ rm $DIR2/$tdir/$de1
+ # ready to create a dup of $de2
+ wait $PID1
+ local found=$(ls $DIR/$tdir/|grep "^$de2\$"|wc -l)
+ (( $found == 1 )) || error "found $found"
+}
+run_test 115 "ldiskfs doesn't check direntry for uniqueness"
+
+test_116() {
+ (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
+ (( $MDS1_VERSION >= $(version_code 2.15.61) )) ||
+ skip "Need MDS version at least 2.15.61 for intent mkdir"
+
+ local mdt_idx
+ local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
+ save_lustre_params client "llite.*.intent_mkdir" > $save
+ stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
+ $LCTL set_param llite.*.intent_mkdir=1
+
+ $LFS mkdir -c$MDSCOUNT -i0 $DIR/$tdir ||
+ error "$LFS mkdir $DIR/$tdir failed"
+ echo "MD layout $DIR/$tdir:"
+ $LFS getdirstripe $DIR/$tdir
+ echo "mkdir $DIR/$tdir/tdir0"
+ mkdir $DIR/$tdir/tdir0 || error "mkdir tdir0 failed"
+ echo "setdirstripe -D -i1 $DIR2/$tdir/tdir0"
+ $LFS setdirstripe -D -i1 $DIR2/$tdir/tdir0 ||
+ error "$LFS setdirstripe $DIR2/$tdir/tdir0 failed"
+ echo "mkdir $DIR/$tdir/tdir0/tdir11"
+ mkdir $DIR/$tdir/tdir0/tdir11 || error "mkdir tdir0/tdir11 failed"
+ $LFS getdirstripe $DIR/$tdir/tdir0
+ $LFS getdirstripe $DIR/$tdir/tdir0/tdir11
+
+ mdt_idx=$($LFS getstripe -m $DIR/$tdir/tdir0/tdir11)
+ [ $mdt_idx == 1 ] ||
+ error "$DIR/$tdir/tdir0/tdir11 on wrong MDT $mdt_idx"
+}
+run_test 116 "DNE: Set default LMV layout from a remote client"
+