Whamcloud - gitweb
LU-8895 target: limit grant allocation
[fs/lustre-release.git] / lustre / tests / sanity.sh
index c32491c..8cdf3fe 100755 (executable)
@@ -1674,7 +1674,8 @@ test_27u() { # bug 4900
        unlinkmany $DIR/$tdir/t- 1000
        trap 0
        [[ $OBJS -gt 0 ]] &&
-               error "$OBJS objects created on OST-0. See $TLOG" || pass
+               error "$OBJS objects created on OST-0. See $TLOG" ||
+               rm -f $TLOG
 }
 run_test 27u "skip object creation on OSC w/o objects"
 
@@ -3839,6 +3840,7 @@ test_43a() {
                cp -p multiop $DIR/$tdir/multiop
        MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
                error "multiop open $TMP/$tfile.junk failed"
+       rm $TMP/$tfile.junk     # delete junk file on close (not part of test)
        MULTIOP_PID=$!
        $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
        kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
@@ -3853,6 +3855,7 @@ test_43b() {
                cp -p multiop $DIR/$tdir/multiop
        MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
                error "multiop open $TMP/$tfile.junk failed"
+       rm $TMP/$tfile.junk     # delete junk file on close (not part of test)
        MULTIOP_PID=$!
        $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
        kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
@@ -5788,6 +5791,92 @@ test_64c() {
 }
 run_test 64c "verify grant shrink"
 
+# this does exactly what osc_request.c:osc_announce_cached() does in
+# order to calculate max amount of grants to ask from server
+want_grant() {
+       local tgt=$1
+
+       local page_size=$(get_page_size client)
+
+       local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
+       local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
+
+       ((rpc_in_flight ++));
+       nrpages=$((nrpages * rpc_in_flight))
+
+       local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
+
+       dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size))
+
+       [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
+       local undirty=$((nrpages * page_size))
+
+       local max_extent_pages
+       max_extent_pages=$($LCTL get_param osc.${tgt}.import |
+           grep grant_max_extent_size | awk '{print $2}')
+       max_extent_pages=$((max_extent_pages / page_size))
+       local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
+       local grant_extent_tax
+       grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
+           grep grant_extent_tax | awk '{print $2}')
+
+       undirty=$((undirty + nrextents * grant_extent_tax))
+
+       echo $undirty
+}
+
+# this is size of unit for grant allocation. It should be equal to
+# what tgt_grant.c:tgt_grant_chunk() calculates
+grant_chunk() {
+       local tgt=$1
+       local max_brw_size
+       local grant_extent_tax
+
+       max_brw_size=$($LCTL get_param osc.${tgt}.import |
+           grep max_brw_size | awk '{print $2}')
+
+       grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
+           grep grant_extent_tax | awk '{print $2}')
+
+       echo $(((max_brw_size + grant_extent_tax) * 2))
+}
+
+test_64d() {
+       [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
+               skip "OST < 2.10.55 doesn't limit grants enough" && return 0
+
+       local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
+
+       [[ $($LCTL get_param osc.${tgt}.import |
+                   grep "connect_flags:.*grant_param") ]] || \
+                       { skip "no grant_param connect flag"; return; }
+
+       local olddebug=$($LCTL get_param -n debug 2> /dev/null)
+
+       $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
+
+       local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
+
+       $SETSTRIPE $DIR/$tfile -i 0 -c 1
+       dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
+       ddpid=$!
+
+       while true
+       do
+               local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
+               if [[ $cur_grant -gt $max_cur_granted ]]
+               then
+                       kill $ddpid
+                       error "cur_grant $cur_grant > $max_cur_granted"
+               fi
+               kill -0 $ddpid
+               [[ $? -ne 0 ]] && break;
+               sleep 2
+       done
+       $LCTL set_param debug="$olddebug" 2> /dev/null || true
+}
+run_test 64d "check grant limit exceed"
+
 # bug 1414 - set/get directories' stripe info
 test_65a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
@@ -7041,14 +7130,19 @@ test_101g() {
        local list=$(comma_list $(osts_nodes))
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
        local brw_size="obdfilter.*.brw_size"
+       local ostver=$(lustre_version_code ost1)
+       local cliver=$(lustre_version_code client)
 
        $LFS setstripe -i 0 -c 1 $DIR/$tfile
 
        local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
-       if [ $(lustre_version_code ost1) -ge $(version_code 2.8.52) -a \
-            $(lustre_version_code client) -ge $(version_code 2.8.52) ]; then
-               [ $(lustre_version_code ost1) -ge $(version_code 2.9.52) ] &&
-                       suffix="M"
+       if [ $ostver -ge $(version_code 2.8.52) -o \
+            \( $ostver -ge $(version_code 2.7.17) -a \
+               $ostver -lt $(version_code 2.7.50) \) ] &&
+          [ $cliver -ge $(version_code 2.8.52) -o \
+            \( $cliver -ge $(version_code 2.7.17) -a \
+               $cliver -lt $(version_code 2.7.50) \) ]; then
+               [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
                if [[ $orig_mb -lt 16 ]]; then
                        save_lustre_params $osts "$brw_size" > $p
                        do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
@@ -8504,6 +8598,34 @@ run_test 118m "fdatasync dir ========="
 
 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
 
+test_118n()
+{
+       local begin
+       local end
+
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       remote_ost_nodsh && skip "remote OSTs with nodsh" && return
+
+       # Sleep to avoid a cached response.
+       #define OBD_STATFS_CACHE_SECONDS 1
+       sleep 2
+
+       # Inject a 10 second delay in the OST_STATFS handler.
+       #define OBD_FAIL_OST_STATFS_DELAY 0x242
+       set_nodes_failloc "$(osts_nodes)" 0x242
+
+       begin=$SECONDS
+       stat --file-system $MOUNT > /dev/null
+       end=$SECONDS
+
+       set_nodes_failloc "$(osts_nodes)" 0
+
+       if ((end - begin > 20)); then
+           error "statfs took $((end - begin)) seconds, expected 10"
+       fi
+}
+run_test 118n "statfs() sends OST_STATFS requests in parallel"
+
 test_119a() # bug 11737
 {
         BSIZE=$((512 * 1024))
@@ -9332,7 +9454,7 @@ test_129() {
                        check_mds_dmesg '"has reached"' ||
                                error_exit "reached message should be output"
 
-                       [ $has_warning -eq 0 ] &&
+                       [ $has_warning = "false" ] &&
                                error_exit "warning message should be output"
 
                        dirsize=$(stat -c%s "$DIR/$tdir")
@@ -9379,7 +9501,7 @@ test_130a() {
                skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
        [ $RC != 0 ] && error "filefrag $fm_file failed"
 
-       filefrag_op=$(filefrag -ve $fm_file |
+       filefrag_op=$(filefrag -ve -k $fm_file |
                        sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
        lun=$($GETSTRIPE -i $fm_file)
 
@@ -9429,7 +9551,7 @@ test_130b() {
                error "dd failed on $fm_file"
 
        filefrag -ves $fm_file || error "filefrag $fm_file failed"
-       filefrag_op=$(filefrag -ve $fm_file |
+       filefrag_op=$(filefrag -ve -k $fm_file |
                        sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
 
        last_lun=$(echo $filefrag_op | cut -d: -f5 |
@@ -9488,7 +9610,7 @@ test_130c() {
                        error "dd failed on $fm_file"
 
        filefrag -ves $fm_file || error "filefrag $fm_file failed"
-       filefrag_op=$(filefrag -ve $fm_file |
+       filefrag_op=$(filefrag -ve -k $fm_file |
                sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
 
        last_lun=$(echo $filefrag_op | cut -d: -f5 |
@@ -9556,7 +9678,7 @@ test_130d() {
                error "dd failed on $fm_file"
 
        filefrag -ves $fm_file || error "filefrag $fm_file failed"
-       filefrag_op=$(filefrag -ve $fm_file |
+       filefrag_op=$(filefrag -ve -k $fm_file |
                        sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
 
        last_lun=$(echo $filefrag_op | cut -d: -f5 |
@@ -9618,7 +9740,7 @@ test_130e() {
        done
 
        filefrag -ves $fm_file || error "filefrag $fm_file failed"
-       filefrag_op=$(filefrag -ve $fm_file |
+       filefrag_op=$(filefrag -ve -k $fm_file |
                        sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
 
        last_lun=$(echo $filefrag_op | cut -d: -f5 |
@@ -10060,6 +10182,7 @@ test_133g() {
        echo "proc_dirs='$proc_dirs'"
        [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
        find $proc_dirs \
+               -ignore_readdir_race \
                -type f \
                -not -name force_lbug \
                -not -name changelog_mask \
@@ -10075,6 +10198,7 @@ test_133g() {
                echo "${facet}_proc_dirs='$facet_proc_dirs'"
                [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
                do_facet $facet find $facet_proc_dirs \
+                       -ignore_readdir_race \
                        -type f \
                        -not -name force_lbug \
                        -not -name changelog_mask \
@@ -11111,9 +11235,8 @@ test_156() {
                log "cache hits:: before: $BEFORE, after: $AFTER"
        fi
 
-       rm -f $file
        restore_lustre_params < $p
-       rm -f $p
+       rm -f $p $file
 }
 run_test 156 "Verification of tunables"
 
@@ -11383,6 +11506,186 @@ test_160e() {
 }
 run_test 160e "changelog negative testing"
 
+cleanup_160f() {
+       trap 0
+       do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
+       echo "Deregistering changelog client $CL_USER"
+       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
+       echo "Deregistering changelog client $CL_USER2"
+       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER2
+       restore_lustre_params < $save_params
+       rm -f $save_params
+}
+
+test_160f() {
+       # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
+       # should be set by default
+
+       local CL_USERS="mdd.$MDT0.changelog_users"
+       local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
+       local save_params="$TMP/sanity-$TESTNAME.parameters"
+
+       save_lustre_params $SINGLEMDS \
+               "mdd.$MDT0.changelog_max_idle_time" > $save_params
+       save_lustre_params $SINGLEMDS \
+               "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
+       save_lustre_params $SINGLEMDS \
+               "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
+
+       trap cleanup_160f EXIT
+
+       # Create a user
+       CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+               changelog_register -n)
+       echo "Registered as changelog user $CL_USER"
+       CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+               changelog_register -n)
+       echo "Registered as changelog user $CL_USER2"
+       $GET_CL_USERS | grep -q $CL_USER ||
+               error "User $CL_USER not found in changelog_users"
+       $GET_CL_USERS | grep -q $CL_USER2 ||
+               error "User $CL_USER2 not found in changelog_users"
+
+       # generate some changelogs to accumulate
+       mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
+       touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
+       touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
+       rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
+
+       # check changelogs have been generated
+       nbcl=$($LFS changelog $MDT0 | wc -l)
+       [[ $nbcl -eq 0 ]] && error "no changelogs found"
+
+       do_facet $SINGLEMDS $LCTL set_param \
+               mdd.$MDT0.changelog_max_idle_time=10
+       do_facet $SINGLEMDS $LCTL set_param \
+               mdd.$MDT0.changelog_min_gc_interval=2
+       do_facet $SINGLEMDS $LCTL set_param \
+               mdd.$MDT0.changelog_min_free_cat_entries=3
+
+       # simulate changelog catalog almost full
+#define OBD_FAIL_CAT_FREE_RECORDS                  0x1313
+       do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
+       do_facet $SINGLEMDS $LCTL set_param fail_val=3
+
+       sleep 6
+       USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
+       $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 2))
+       USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
+       echo "verifying user clear: $(( $USER_REC1 + 2 )) == $USER_REC2"
+       [ $USER_REC2 == $(($USER_REC1 + 2)) ] ||
+               error "user index expected $(($USER_REC1 + 2)) is $USER_REC2"
+       sleep 5
+
+       # generate one more changelog to trigger fail_loc
+       rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
+
+       # ensure gc thread is done
+       wait_update_facet $SINGLEMDS \
+                         "ps -e -o comm= | grep chlg_gc_thread" "" 20
+
+       # check user still registered
+       $GET_CL_USERS | grep -q $CL_USER ||
+               error "User $CL_USER not found in changelog_users"
+       # check user2 unregistered
+       $GET_CL_USERS | grep -q $CL_USER2 &&
+               error "User $CL_USER2 still found in changelog_users"
+
+       # check changelogs are present and starting at $USER_REC2 + 1
+       FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
+       echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
+       [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
+               error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
+
+       cleanup_160f
+}
+run_test 160f "changelog garbage collect (timestamped users)"
+
+test_160g() {
+       # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
+       # should be set by default
+
+       local CL_USERS="mdd.$MDT0.changelog_users"
+       local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
+       local save_params="$TMP/sanity-$TESTNAME.parameters"
+
+       save_lustre_params $SINGLEMDS \
+               "mdd.$MDT0.changelog_max_idle_indexes" > $save_params
+       save_lustre_params $SINGLEMDS \
+               "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
+       save_lustre_params $SINGLEMDS \
+               "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
+
+       trap cleanup_160f EXIT
+
+#define OBD_FAIL_TIME_IN_CHLOG_USER                 0x1314
+       do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1314
+
+       # Create a user
+       CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+               changelog_register -n)
+       echo "Registered as changelog user $CL_USER"
+       CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+               changelog_register -n)
+       echo "Registered as changelog user $CL_USER2"
+       $GET_CL_USERS | grep -q $CL_USER ||
+               error "User $CL_USER not found in changelog_users"
+       $GET_CL_USERS | grep -q $CL_USER2 ||
+               error "User $CL_USER2 not found in changelog_users"
+
+       # generate some changelogs to accumulate
+       mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
+       touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
+       touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
+       rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
+
+       # check changelogs have been generated
+       nbcl=$($LFS changelog $MDT0 | wc -l)
+       [[ $nbcl -eq 0 ]] && error "no changelogs found"
+
+       do_facet $SINGLEMDS $LCTL set_param \
+               mdd.$MDT0.changelog_max_idle_indexes=$((nbcl - 1))
+       do_facet $SINGLEMDS $LCTL set_param \
+               mdd.$MDT0.changelog_min_gc_interval=2
+       do_facet $SINGLEMDS $LCTL set_param \
+               mdd.$MDT0.changelog_min_free_cat_entries=3
+
+       # simulate changelog catalog almost full
+#define OBD_FAIL_CAT_FREE_RECORDS                  0x1313
+       do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
+       do_facet $SINGLEMDS $LCTL set_param fail_val=3
+
+       USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
+       $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 3))
+       USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
+       echo "verifying user clear: $(( $USER_REC1 + 3 )) == $USER_REC2"
+       [ $USER_REC2 == $(($USER_REC1 + 3)) ] ||
+               error "user index expected $(($USER_REC1 + 3)) is $USER_REC2"
+
+       # generate one more changelog to trigger fail_loc
+       rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
+
+       # ensure gc thread is done
+       wait_update_facet $SINGLEMDS \
+                         "ps -e -o comm= | grep chlg_gc_thread" "" 20
+
+       # check user still registered
+       $GET_CL_USERS | grep -q $CL_USER ||
+               error "User $CL_USER not found in changelog_users"
+       # check user2 unregistered
+       $GET_CL_USERS | grep -q $CL_USER2 &&
+               error "User $CL_USER2 still found in changelog_users"
+
+       # check changelogs are present and starting at $USER_REC2 + 1
+       FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
+       echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
+       [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
+               error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
+
+       cleanup_160f
+}
+run_test 160g "changelog garbage collect (old users)"
+
 test_161a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        test_mkdir -c1 $DIR/$tdir
@@ -12056,6 +12359,8 @@ test_184a() {
 
        cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
        cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
+
+       lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
 }
 run_test 184a "Basic layout swap"
 
@@ -13983,19 +14288,44 @@ test_231b() {
 }
 run_test 231b "must not assert on fully utilized OST request buffer"
 
-test_232() {
+test_232a() {
        mkdir -p $DIR/$tdir
+       $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
+
        #define OBD_FAIL_LDLM_OST_LVB            0x31c
-       $LCTL set_param fail_loc=0x31c
+       do_facet ost1 $LCTL set_param fail_loc=0x31c
 
        # ignore dd failure
        dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
 
-       $LCTL set_param fail_loc=0
+       do_facet ost1 $LCTL set_param fail_loc=0
        umount_client $MOUNT || error "umount failed"
        mount_client $MOUNT || error "mount failed"
+       stop ost1 || error "cannot stop ost1"
+       start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
 }
-run_test 232 "failed lock should not block umount"
+run_test 232a "failed lock should not block umount"
+
+test_232b() {
+       mkdir -p $DIR/$tdir
+       $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
+       dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
+       sync
+       cancel_lru_locks osc
+
+       #define OBD_FAIL_LDLM_OST_LVB            0x31c
+       do_facet ost1 $LCTL set_param fail_loc=0x31c
+
+       # ignore failure
+       $LFS data_version $DIR/$tdir/$tfile || true
+
+       do_facet ost1 $LCTL set_param fail_loc=0
+       umount_client $MOUNT || error "umount failed"
+       mount_client $MOUNT || error "mount failed"
+       stop ost1 || error "cannot stop ost1"
+       start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
+}
+run_test 232b "failed data version lock should not block umount"
 
 test_233a() {
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
@@ -14299,6 +14629,14 @@ test_246() { # LU-7371
 }
 run_test 246 "Read file of size 4095 should return right length"
 
+cleanup_247() {
+       local submount=$1
+
+       trap 0
+       umount_client $submount
+       rmdir $submount
+}
+
 test_247a() {
        lctl get_param -n mdc.$FSNAME-MDT0000*.import |
                grep -q subtree ||
@@ -14310,11 +14648,11 @@ test_247a() {
        mkdir -p $submount || error "mkdir $submount failed"
        FILESET="$FILESET/$tdir" mount_client $submount ||
                error "mount $submount failed"
+       trap "cleanup_247 $submount" EXIT
        echo foo > $submount/$tfile || error "write $submount/$tfile failed"
        [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
                error "read $MOUNT/$tdir/$tfile failed"
-       umount_client $submount || error "umount $submount failed"
-       rmdir $submount
+       cleanup_247 $submount
 }
 run_test 247a "mount subdir as fileset"
 
@@ -14341,12 +14679,12 @@ test_247c() {
 
        mkdir -p $MOUNT/$tdir/dir1
        mkdir -p $submount || error "mkdir $submount failed"
+       trap "cleanup_247 $submount" EXIT
        FILESET="$FILESET/$tdir" mount_client $submount ||
                error "mount $submount failed"
        local fid=$($LFS path2fid $MOUNT/)
        $LFS fid2path $submount $fid && error "fid2path should fail"
-       umount_client $submount || error "umount $submount failed"
-       rmdir $submount
+       cleanup_247 $submount
 }
 run_test 247c "running fid2path outside root"
 
@@ -14360,10 +14698,10 @@ test_247d() {
        mkdir -p $submount || error "mkdir $submount failed"
        FILESET="$FILESET/$tdir" mount_client $submount ||
                error "mount $submount failed"
+       trap "cleanup_247 $submount" EXIT
        local fid=$($LFS path2fid $submount/dir1)
        $LFS fid2path $submount $fid || error "fid2path should succeed"
-       umount_client $submount || error "umount $submount failed"
-       rmdir $submount
+       cleanup_247 $submount
 }
 run_test 247d "running fid2path inside root"
 
@@ -14399,12 +14737,13 @@ test_248() {
        # small read with fast read enabled
        $LCTL set_param -n llite.*.fast_read=1
        local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
-               awk '/copied/ { print $6 }')
-
+               egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
+               sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
        # small read with fast read disabled
        $LCTL set_param -n llite.*.fast_read=0
        local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
-               awk '/copied/ { print $6 }')
+               egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
+               sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
 
        # verify that fast read is 4 times faster for cache read
        [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
@@ -14417,12 +14756,14 @@ test_248() {
        # 1k non-cache read
        cancel_lru_locks osc
        local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
-               awk '/copied/ { print $6 }')
+               egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
+               sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
 
        # 1M non-cache read
        cancel_lru_locks osc
        local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
-               awk '/copied/ { print $6 }')
+               egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
+               sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
 
        # verify that big IO is not 4 times faster than small IO
        [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
@@ -14795,7 +15136,7 @@ ladvise_willread_performance()
 
        local lowest_speedup=20
        if [ ${average_cache%.*} -lt $lowest_speedup ]; then
-               echo "Speedup with OSS cached read less than $lowest_speedup%, "
+               echo "Speedup with OSS cached read less than $lowest_speedup%," \
                        "got $average_cache%. Skipping ladvise willread check."
                return 0
        fi
@@ -15182,6 +15523,10 @@ run_test 260 "Check mdc_close fail"
 
 ### Data-on-MDT sanity tests ###
 test_270a() {
+
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        # create DoM file
        local dom=$DIR/$tdir/dom_file
        local tmp=$DIR/$tdir/tmp_file
@@ -15277,6 +15622,9 @@ test_270a() {
 run_test 270a "DoM: basic functionality tests"
 
 test_270b() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        local dom=$DIR/$tdir/dom_file
        local max_size=1048576
 
@@ -15299,6 +15647,9 @@ test_270b() {
 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
 
 test_270c() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        mkdir -p $DIR/$tdir
        $LFS setstripe -E 1024K -L mdt $DIR/$tdir
 
@@ -15325,6 +15676,9 @@ test_270c() {
 run_test 270c "DoM: DoM EA inheritance tests"
 
 test_270d() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        mkdir -p $DIR/$tdir
        $LFS setstripe -E 1024K -L mdt $DIR/$tdir
 
@@ -15344,6 +15698,9 @@ test_270d() {
 run_test 270d "DoM: change striping from DoM to RAID0"
 
 test_270e() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        mkdir -p $DIR/$tdir/dom
        mkdir -p $DIR/$tdir/norm
        DOMFILES=20
@@ -15382,6 +15739,9 @@ test_270e() {
 run_test 270e "DoM: lfs find with DoM files test"
 
 test_270f() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        local mdtname=${FSNAME}-MDT0000-mdtlov
        local dom=$DIR/$tdir/dom_file
        local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
@@ -15440,6 +15800,9 @@ test_270f() {
 run_test 270f "DoM: maximum DoM stripe size checks"
 
 test_271a() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        local dom=$DIR/$tdir/dom
 
        mkdir -p $DIR/$tdir
@@ -15458,6 +15821,9 @@ test_271a() {
 run_test 271a "DoM: data is cached for read after write"
 
 test_271b() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        local dom=$DIR/$tdir/dom
 
        mkdir -p $DIR/$tdir
@@ -15478,6 +15844,9 @@ test_271b() {
 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
 
 test_271ba() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        local dom=$DIR/$tdir/dom
 
        mkdir -p $DIR/$tdir
@@ -15505,6 +15874,9 @@ test_271c() {
        # test to be enabled with lock_convert
        skip "skipped until lock convert will be implemented" && return
 
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
        local dom=$DIR/$tdir/dom
 
        mkdir -p $DIR/$tdir
@@ -16468,6 +16840,33 @@ test_313() {
 }
 run_test 313 "io should fail after last_rcvd update fail"
 
+test_314() {
+       $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
+       do_facet ost1 "$LCTL set_param fail_loc=0x720"
+       rm -f $DIR/$tfile
+       wait_delete_completed
+       do_facet ost1 "$LCTL set_param fail_loc=0"
+}
+run_test 314 "OSP shouldn't fail after last_rcvd update failure"
+
+test_315() { # LU-618
+       local file=$DIR/$tfile
+       rm -f $file
+
+       $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
+       $MULTIOP $file oO_RDONLY:r4096000_c &
+       PID=$!
+
+       sleep 2
+
+       local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
+       kill -USR1 $PID
+
+       [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
+       rm -f $file
+}
+run_test 315 "read should be accounted"
+
 test_fake_rw() {
        local read_write=$1
        if [ "$read_write" = "write" ]; then
@@ -16737,7 +17136,7 @@ test_403() {
 
        wait
 
-       [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
+       [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
 
        rm -f $tfile $file1 $file2
 }
@@ -17271,6 +17670,137 @@ test_802() {
 }
 run_test 802 "simulate readonly device"
 
+test_803() {
+       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
+               skip "MDS needs to be newer than 2.10.54" && return
+
+       mkdir -p $DIR/$tdir
+       # Create some objects on all MDTs to trigger related logs objects
+       for idx in $(seq $MDSCOUNT); do
+               $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
+                       $DIR/$tdir/dir${idx} ||
+                       error "Fail to create $DIR/$tdir/dir${idx}"
+       done
+
+       sync; sleep 5
+       echo "before create:"
+       $LFS df -i $MOUNT
+       local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
+
+       for ((i=0; i<10; i++)); do
+               $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
+                       error "Fail to create $DIR/$tdir/foo$i"
+       done
+
+       sync; sleep 5
+       echo "after create:"
+       $LFS df -i $MOUNT
+       local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
+
+       [ $after_used -ge $((before_used + 10)) ] ||
+               error "before ($before_used) + 10 > after ($after_used)"
+
+       for ((i=0; i<10; i++)); do
+               rm -rf $DIR/$tdir/foo$i ||
+                       error "Fail to remove $DIR/$tdir/foo$i"
+       done
+
+       wait_delete_completed
+       echo "after unlink:"
+       $LFS df -i $MOUNT
+       before_used=$after_used
+       after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
+
+       [ $after_used -le $((before_used - 8)) ] ||
+               error "before ($before_used) - 8 < after ($after_used)"
+}
+run_test 803 "verify agent object for remote object"
+
+test_804() {
+       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
+               skip "MDS needs to be newer than 2.10.54" && return
+
+       [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
+               skip "ldiskfs only test" && return 0
+
+       mkdir -p $DIR/$tdir
+       $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
+               error "Fail to create $DIR/$tdir/dir0"
+
+       local fid=$($LFS path2fid $DIR/$tdir/dir0)
+       local dev=$(mdsdevname 2)
+
+       do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
+               grep ${fid} || error "NOT found agent entry for dir0"
+
+       $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
+               error "Fail to create $DIR/$tdir/dir1"
+
+       touch $DIR/$tdir/dir1/foo0 ||
+               error "Fail to create $DIR/$tdir/dir1/foo0"
+       fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
+       local rc=0
+
+       for idx in $(seq $MDSCOUNT); do
+               dev=$(mdsdevname $idx)
+               do_facet mds${idx} \
+                       "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
+                       grep ${fid} && rc=$idx
+       done
+
+       mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
+               error "Fail to rename foo0 to foo1"
+       if [ $rc -eq 0 ]; then
+               for idx in $(seq $MDSCOUNT); do
+                       dev=$(mdsdevname $idx)
+                       do_facet mds${idx} \
+                       "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
+                       grep ${fid} && rc=$idx
+               done
+       fi
+
+       mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
+               error "Fail to rename foo1 to foo2"
+       if [ $rc -eq 0 ]; then
+               for idx in $(seq $MDSCOUNT); do
+                       dev=$(mdsdevname $idx)
+                       do_facet mds${idx} \
+                       "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
+                       grep ${fid} && rc=$idx
+               done
+       fi
+
+       [ $rc -ne 0 ] || error "NOT found agent entry for foo"
+
+       ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
+               error "Fail to link to $DIR/$tdir/dir1/foo2"
+       mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
+               error "Fail to rename foo2 to foo0"
+       unlink $DIR/$tdir/dir1/foo0 ||
+               error "Fail to unlink $DIR/$tdir/dir1/foo0"
+       rm -rf $DIR/$tdir/dir0 ||
+               error "Fail to rm $DIR/$tdir/dir0"
+
+       for idx in $(seq $MDSCOUNT); do
+               dev=$(mdsdevname $idx)
+               rc=0
+
+               stop mds${idx}
+               run_e2fsck $(facet_active_host mds$idx) $dev -n ||
+                       rc=$?
+               start mds${idx} $dev $MDS_MOUNT_OPTS ||
+                       error "mount mds$idx failed"
+               df $MOUNT > /dev/null 2>&1
+
+               # e2fsck should not return error
+               [ $rc -eq 0 ] ||
+                       error "e2fsck detected error on MDT${idx}: rc=$rc"
+       done
+}
+run_test 804 "verify agent entry for remote entry"
+
 #
 # tests that do cleanup/setup should be run at the end
 #