Whamcloud - gitweb
LU-4131 mdd: Changelog not logging file truncate.
[fs/lustre-release.git] / lustre / tests / sanity.sh
index a1c5f65..7a430d0 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# -*- tab-width: 4; indent-tabs-mode: t; -*-
+# -*- tab-width: 8; indent-tabs-mode: t; -*-
 #
 # Run select tests by setting ONLY, or as arguments to the script.
 # Skip specific tests by setting EXCEPT.
@@ -106,8 +106,8 @@ check_and_setup_lustre
 DIR=${DIR:-$MOUNT}
 assert_DIR
 
-MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
-    awk '{gsub(/_UUID/,""); print $1}' | head -1)
+MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
+       awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
@@ -515,9 +515,9 @@ test_17i() { #bug 20018
 run_test 17i "don't panic on short symlink"
 
 test_17k() { #bug 22301
-        rsync --help | grep -q xattr ||
-                skip_env "$(rsync --version| head -1) does not support xattrs"
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       rsync --help | grep -q xattr ||
+               skip_env "$(rsync --version | head -n1) does not support xattrs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
        test_mkdir -p $DIR/$tdir
        test_mkdir -p $DIR/$tdir.new
        touch $DIR/$tdir/$tfile
@@ -1031,7 +1031,7 @@ simple_cleanup_common() {
 }
 
 max_pages_per_rpc() {
-       $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
+       $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
 }
 
 test_24v() {
@@ -5625,7 +5625,8 @@ test_78() { # bug 10901
        [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
        [ $F78SIZE -gt 512 ] && F78SIZE=512
        [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
-       SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
+       SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
+               head -n1)
        echo "Smallest OST: $SMALLESTOST"
        [ $SMALLESTOST -lt 10240 ] && \
                skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
@@ -5636,12 +5637,12 @@ test_78() { # bug 10901
        [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
        echo "File size: $F78SIZE"
        $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
-       for i in `seq 1 $NSEQ`
-       do
-               FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
-               echo directIO rdwr round $i of $NSEQ
-               $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
-       done
+       for i in `seq 1 $NSEQ`
+       do
+               FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
+               echo directIO rdwr round $i of $NSEQ
+               $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
+       done
 
        rm -f $DIR/$tfile
 }
@@ -6618,7 +6619,11 @@ test_103 () {
        fi
 
        echo "LU-2561 newly created file is same size as directory..."
-       run_acl_subtest 2561 || error "LU-2561 test failed"
+       if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
+               run_acl_subtest 2561 || error "LU-2561 test failed"
+       else
+               run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
+       fi
 
        cd $SAVE_PWD
        umask $SAVE_UMASK
@@ -6830,7 +6835,7 @@ test_116a() { # was previously test_116()
 
        echo -n "Free space priority "
        do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
-               head -1
+               head -n1
        declare -a AVAIL
        free_min_max
 
@@ -6844,7 +6849,7 @@ test_116a() { # was previously test_116()
        local DIFF2=$(($DIFF * 100 / $MINV))
 
        local threshold=$(do_facet $SINGLEMDS \
-               lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -1)
+               lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
        threshold=${threshold%%%}
        echo -n "Check for uneven OSTs: "
        echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
@@ -6944,14 +6949,17 @@ test_116b() { # LU-2093
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
 #define OBD_FAIL_MDS_OSC_CREATE_FAIL     0x147
        local old_rr
-       old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
-       do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
+       old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
+               lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
+       do_facet $SINGLEMDS lctl set_param \
+               lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
        mkdir -p $DIR/$tdir
        do_facet $SINGLEMDS lctl set_param fail_loc=0x147
        createmany -o $DIR/$tdir/f- 20 || error "can't create"
        do_facet $SINGLEMDS lctl set_param fail_loc=0
        rm -rf $DIR/$tdir
-       do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
+       do_facet $SINGLEMDS lctl set_param \
+               lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
 }
 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
 
@@ -6972,7 +6980,7 @@ NO_SLOW_RESENDCOUNT=4
 export OLD_RESENDCOUNT=""
 set_resend_count () {
        local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
-       OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
+       OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
        lctl set_param -n $PROC_RESENDCOUNT $1
        echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
 }
@@ -7445,19 +7453,21 @@ test_120a() {
        cancel_lru_locks osc
 
        stat $DIR/$tdir > /dev/null
-       can1=$(lctl get_param -n ldlm.services.ldlm_canceld.stats |
-                                       awk '/ldlm_cancel/ {print $2}')
-       blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
-                                       awk '/ldlm_bl_callback/ {print $2}')
+       can1=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
        test_mkdir -c1 $DIR/$tdir/d1
-        can2=$(lctl get_param -n ldlm.services.ldlm_canceld.stats |
-                                       awk '/ldlm_cancel/ {print $2}')
-       blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
-                                       awk '/ldlm_bl_callback/ {print $2}')
-        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
-        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
-        lru_resize_enable mdc
-        lru_resize_enable osc
+       can2=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+       [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+       lru_resize_enable mdc
+       lru_resize_enable osc
 }
 run_test 120a "Early Lock Cancel: mkdir test"
 
@@ -7470,15 +7480,21 @@ test_120b() {
         lru_resize_disable osc
         cancel_lru_locks mdc
         stat $DIR/$tdir > /dev/null
-        can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
-        blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
-        touch $DIR/$tdir/f1
-        can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
-        blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
-        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
-        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
-        lru_resize_enable mdc
-        lru_resize_enable osc
+       can1=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       touch $DIR/$tdir/f1
+       can2=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+       [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+       lru_resize_enable mdc
+       lru_resize_enable osc
 }
 run_test 120b "Early Lock Cancel: create test"
 
@@ -7491,18 +7507,24 @@ test_120c() {
         lru_resize_disable osc
        test_mkdir -p -c1 $DIR/$tdir/d1
        test_mkdir -p -c1 $DIR/$tdir/d2
-        touch $DIR/$tdir/d1/f1
-        cancel_lru_locks mdc
-        stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
-        can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
-        blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
-        ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
-        can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
-        blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
-        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
-        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
-        lru_resize_enable mdc
-        lru_resize_enable osc
+       touch $DIR/$tdir/d1/f1
+       cancel_lru_locks mdc
+       stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
+       can1=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
+       can2=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+       [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+       lru_resize_enable mdc
+       lru_resize_enable osc
 }
 run_test 120c "Early Lock Cancel: link test"
 
@@ -7511,20 +7533,26 @@ test_120d() {
        test_mkdir -p -c1 $DIR/$tdir
        [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
               skip "no early lock cancel on server" && return 0
-        lru_resize_disable mdc
-        lru_resize_disable osc
-        touch $DIR/$tdir
-        cancel_lru_locks mdc
-        stat $DIR/$tdir > /dev/null
-        can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
-        blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
-        chmod a+x $DIR/$tdir
-        can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
-        blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
-        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
-        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
-        lru_resize_enable mdc
-        lru_resize_enable osc
+       lru_resize_disable mdc
+       lru_resize_disable osc
+       touch $DIR/$tdir
+       cancel_lru_locks mdc
+       stat $DIR/$tdir > /dev/null
+       can1=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       chmod a+x $DIR/$tdir
+       can2=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+       [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+       lru_resize_enable mdc
+       lru_resize_enable osc
 }
 run_test 120d "Early Lock Cancel: setattr test"
 
@@ -7540,19 +7568,21 @@ test_120e() {
         cancel_lru_locks osc
         dd if=$DIR/$tdir/f1 of=/dev/null
         stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
-        can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
-              awk '/ldlm_cancel/ {print $2}'`
-        blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
-              awk '/ldlm_bl_callback/ {print $2}'`
-        unlink $DIR/$tdir/f1
-        can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
-              awk '/ldlm_cancel/ {print $2}'`
-        blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
-              awk '/ldlm_bl_callback/ {print $2}'`
-        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
-        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
-        lru_resize_enable mdc
-        lru_resize_enable osc
+       can1=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       unlink $DIR/$tdir/f1
+       can2=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+       [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+       lru_resize_enable mdc
+       lru_resize_enable osc
 }
 run_test 120e "Early Lock Cancel: unlink test"
 
@@ -7572,19 +7602,21 @@ test_120f() {
         dd if=$DIR/$tdir/d1/f1 of=/dev/null
         dd if=$DIR/$tdir/d2/f2 of=/dev/null
         stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
-        can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
-              awk '/ldlm_cancel/ {print $2}'`
-        blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
-              awk '/ldlm_bl_callback/ {print $2}'`
-        mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
-        can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
-              awk '/ldlm_cancel/ {print $2}'`
-        blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
-              awk '/ldlm_bl_callback/ {print $2}'`
-        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
-        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
-        lru_resize_enable mdc
-        lru_resize_enable osc
+       can1=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
+       can2=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+       [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+       lru_resize_enable mdc
+       lru_resize_enable osc
 }
 run_test 120f "Early Lock Cancel: rename test"
 
@@ -7601,32 +7633,35 @@ test_120g() {
         cancel_lru_locks osc
         t0=`date +%s`
 
-        can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
-              awk '/ldlm_cancel/ {print $2}'`
-        blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
-              awk '/ldlm_bl_callback/ {print $2}'`
-        createmany -o $DIR/$tdir/f $count
-        sync
-        can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
-              awk '/ldlm_cancel/ {print $2}'`
-        blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
-              awk '/ldlm_bl_callback/ {print $2}'`
-        t1=`date +%s`
-        echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
-        echo rm $count files
-        rm -r $DIR/$tdir
-        sync
-        can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
-              awk '/ldlm_cancel/ {print $2}'`
-        blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
-              awk '/ldlm_bl_callback/ {print $2}'`
-        t2=`date +%s`
-        echo total: $count removes in $((t2-t1))
-        echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
-        sleep 2
-        # wait for commitment of removal
-        lru_resize_enable mdc
-        lru_resize_enable osc
+       can0=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       createmany -o $DIR/$tdir/f $count
+       sync
+       can1=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       t1=$(date +%s)
+       echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
+       echo rm $count files
+       rm -r $DIR/$tdir
+       sync
+       can2=$(do_facet $SINGLEMDS \
+              "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
+              awk '/ldlm_cancel/ {print $2}')
+       blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
+              awk '/ldlm_bl_callback/ {print $2}')
+       t2=$(date +%s)
+       echo total: $count removes in $((t2-t1))
+       echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
+       sleep 2
+       # wait for commitment of removal
+       lru_resize_enable mdc
+       lru_resize_enable osc
 }
 run_test 120g "Early Lock Cancel: performance test"
 
@@ -9679,18 +9714,18 @@ test_160a() {
 
        MIN_REC=$($GET_CL_USERS |
                awk 'min == "" || $2 < min {min = $2}; END {print min}')
-       FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
+       FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
        echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
        [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
                err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
 
        # LU-3446 changelog index reset on MDT restart
        local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
-       CUR_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
+       CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
        $LFS changelog_clear $MDT0 $USER 0
        stop $SINGLEMDS || error "Fail to stop MDT."
        start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
-       CUR_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
+       CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
        echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
        [ $CUR_REC1 == $CUR_REC2 ] ||
                err17935 "current index should be $CUR_REC1 is $CUR_REC2"
@@ -9702,9 +9737,9 @@ test_160a() {
 
        USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
        if [ $USERS -eq 0 ]; then
-               LAST_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
+               LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
                touch $DIR/$tdir/chloe
-               LAST_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
+               LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
                echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
                [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
        else
@@ -9744,6 +9779,32 @@ test_160b() { # LU-3587
 }
 run_test 160b "Verify that very long rename doesn't crash in changelog"
 
+test_160c() {
+       local rc=0
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+
+       # Registration step
+       local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+               changelog_register -n)
+
+       rm -rf $DIR/$tdir
+       mkdir -p $DIR/$tdir
+       $MCREATE $DIR/$tdir/foo_160c
+       changelog_chmask "TRUNC"
+       $TRUNCATE $DIR/$tdir/foo_160c 200
+       changelog_chmask "TRUNC"
+       $TRUNCATE $DIR/$tdir/foo_160c 199
+       $LFS changelog $MDT0
+       TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
+       [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
+       $LFS changelog_clear $MDT0 $USER 0
+
+       # Deregistration step
+       echo "deregistering $USER"
+       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
+}
+run_test 160c "verify that changelog log catch the truncate event"
+
 test_161a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        test_mkdir -p -c1 $DIR/$tdir
@@ -10192,7 +10253,8 @@ test_180c() { # LU-2598
        do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
                rmmod_remote=true || error "failed to load module obdecho"
 
-       target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4}'|head -1)
+       target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
+               head -n1)
        if [[ -n $target ]]; then
                obdecho_test "$target" ost1 "$pages" ||
                        rc=${PIPESTATUS[0]}
@@ -10655,7 +10717,7 @@ pool_remove_first_target() {
        local pool=$1
 
        local pname="lov.$FSNAME-*.pools.$pool"
-       local t=$($LCTL get_param -n $pname | head -1)
+       local t=$($LCTL get_param -n $pname | head -n1)
        do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
        wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
                error_noexit "$t not removed from $FSNAME.$pool"
@@ -10676,7 +10738,7 @@ pool_remove_all_targets() {
                error_noexit "Pool $FSNAME.$pool cannot be drained"
                return 1
        }
-       # striping on an empty/nonexistant pool should fall back 
+       # striping on an empty/nonexistant pool should fall back
        # to "pool of everything"
        touch $file || {
                error_noexit "failed to use fallback striping for empty pool"
@@ -12046,7 +12108,7 @@ test_231a()
 {
        # For simplicity this test assumes that max_pages_per_rpc
        # is the same across all OSCs
-       local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
+       local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
        local bulk_size=$((max_pages * 4096))
 
        mkdir -p $DIR/$tdir
@@ -12210,6 +12272,23 @@ test_237() {
 }
 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
 
+# LU-4659 linkea consistency
+test_238() {
+       touch $DIR/$tfile
+       ln $DIR/$tfile $DIR/$tfile.lnk
+       touch $DIR/$tfile.new
+       mv $DIR/$tfile.new $DIR/$tfile
+       local fid1=$(lfs path2fid $DIR/$tfile)
+       local fid2=$(lfs path2fid $DIR/$tfile.lnk)
+       local path1=$(lfs fid2path $FSNAME $fid1)
+       [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
+       local path2=$(lfs fid2path $FSNAME $fid2)
+       [ $tfile.lnk == $path2 ] ||
+               error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
+       rm -f $DIR/$tfile*
+}
+run_test 238 "Verify linkea consistency"
+
 test_striped_dir() {
        local mdt_index=$1
        local stripe_count