Whamcloud - gitweb
LU-5319 tests: testcases for multiple modify RPCs feature
[fs/lustre-release.git] / lustre / tests / conf-sanity.sh
index 1100c02..4c2aa80 100644 (file)
@@ -4,8 +4,8 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 
-# bug number for skipped test:
-ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
+# bug number for skipped test:     LU-7005
+ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 50i"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 is_sles11()                                            # LU-2181
@@ -78,8 +78,8 @@ if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
 fi
 
 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
-# bug number for skipped test:        LU-2778 LU-4444
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT 57b     69"
+# bug number for skipped test:        LU-4444
+       ALWAYS_EXCEPT="$ALWAYS_EXCEPT 69"
 
 init_logging
 
@@ -3385,6 +3385,52 @@ test_50h() {
 }
 run_test 50h "LU-642: activate deactivated OST"
 
+test_50i() {
+       # prepare MDT/OST, make OSC inactive for OST1
+       [ "$MDSCOUNT" -lt "2" ] && skip_env "$MDSCOUNT < 2, skipping" && return
+
+       [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
+       load_modules
+       do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
+               error "tunefs MDT2 failed"
+       start_mds  || error "Unable to start MDT"
+       start_ost  || error "Unable to start OST1"
+       start_ost2 || error "Unable to start OST2"
+       mount_client $MOUNT || error "client start failed"
+
+       mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+
+       $LCTL conf_param ${FSNAME}-MDT0000.mdc.active=0 &&
+               error "deactive MDC0 succeeds"
+       # activate MDC for MDT2
+       local TEST="$LCTL get_param -n mdc.${FSNAME}-MDT0001-mdc-[!M]*.active"
+       set_conf_param_and_check client                                 \
+               "$TEST" "${FSNAME}-MDT0001.mdc.active" 1 ||
+               error "Unable to activate MDT2"
+
+       $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
+       # create some file
+       createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
+
+       rm -rf $DIR/$tdir/2 || error "unlink dir failed"
+
+       # deactivate MDC for MDT2
+       local TEST="$LCTL get_param -n mdc.${FSNAME}-MDT0001-mdc-[!M]*.active"
+       set_conf_param_and_check client                                 \
+               "$TEST" "${FSNAME}-MDT0001.mdc.active" 0 ||
+               error "Unable to deactivate MDT2"
+
+       $LFS mkdir -i1 $DIR/$tdir/2 &&
+               error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
+
+       # cleanup
+       umount_client $MOUNT || error "Unable to umount client"
+       stop_mds
+       stop_ost
+       stop_ost 2
+}
+run_test 50i "activate deactivated MDT"
+
 test_51() {
        local LOCAL_TIMEOUT=20
 
@@ -3914,20 +3960,19 @@ test_60() { # LU-471
 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
 
 test_61() { # LU-80
-       local reformat=false
+       local lxattr=false
 
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
                { skip "Need MDS version at least 2.1.53"; return 0; }
 
        if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
-          ! large_xattr_enabled; then
-               reformat=true
-               LDISKFS_MKFS_OPTS+=" -O large_xattr"
+            ! large_xattr_enabled; then
+               lxattr=true
 
                for num in $(seq $MDSCOUNT); do
-                       add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
-                       --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
-                       error "add mds $num failed"
+                       do_facet mds${num} $TUNE2FS -O large_xattr \
+                               $(mdsdevname $num) ||
+                               error "tune2fs on mds $num failed"
                done
        fi
 
@@ -3976,9 +4021,12 @@ test_61() { # LU-80
 
     rm -f $file
     stopall
-       if $reformat; then
-               LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
-               reformat
+       if $lxattr; then
+               for num in $(seq $MDSCOUNT); do
+                       do_facet mds${num} $TUNE2FS -O ^large_xattr \
+                               $(mdsdevname $num) ||
+                               error "tune2fs on mds $num failed"
+               done
        fi
 }
 run_test 61 "large xattr"
@@ -3997,10 +4045,10 @@ test_62() {
                { skip "Need MDS version at least 2.2.51"; return 0; }
 
        echo "disable journal for mds"
-       do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
+       do_facet mds $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
        start_mds && error "MDT start should fail"
        echo "disable journal for ost"
-       do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
+       do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
        start_ost && error "OST start should fail"
        cleanup || error "cleanup failed with rc $?"
        reformat_and_config
@@ -4956,7 +5004,7 @@ test_80() {
 }
 run_test 80 "mgc import reconnect race"
 
-# Save the original values of $OSTCOUNT and $OSTINDEX$i.
+#Save the original values of $OSTCOUNT and $OSTINDEX$i.
 save_ostindex() {
        local new_ostcount=$1
        saved_ostcount=$OSTCOUNT
@@ -5407,6 +5455,412 @@ test_85() {
 }
 run_test 85 "osd_ost init: fail ea_fid_set"
 
+test_86() {
+       [ "$(facet_fstype ost1)" = "zfs" ] &&
+               skip "LU-6442: no such mkfs params for ZFS OSTs" && return
+
+       local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \
+               --reformat $(ostdevname 1) $(ostvdevname 1)"
+
+       local NEWSIZE=1024
+       local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
+               awk '/Flex block group size: / { print $NF; exit; }')
+
+       local opts=OST_OPTS
+       if [[ ${!opts} != *mkfsoptions* ]]; then
+               eval opts=\"${!opts} \
+                       --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\"
+       else
+               val=${!opts//--mkfsoptions=\\\"/ \
+                       --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE }
+               eval opts='${val}'
+       fi
+
+       echo "params: $opts"
+
+       add ost1 $opts || error "add ost1 failed with new params"
+
+       local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
+               awk '/Flex block group size: / { print $NF; exit; }')
+
+       [[ $FOUNDSIZE == $NEWSIZE ]] ||
+               error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
+       return 0
+}
+run_test 86 "Replacing mkfs.lustre -G option"
+
+test_87() { #LU-6544
+       [[ $(lustre_version_code $SINGLEMDS1) -ge $(version_code 2.7.56) ]] ||
+               { skip "Need MDS version at least 2.7.56" && return; }
+       [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
+               { skip "Only applicable to ldiskfs-based MDTs" && return; }
+       [[ $OSTCOUNT -gt 69 ]] &&
+               { skip "Ignore wide striping situation" && return; }
+
+       local mdsdev=$(mdsdevname 1)
+       local mdsvdev=$(mdsvdevname 1)
+       local file=$DIR/$tfile
+       local mntpt=$(facet_mntpt $SINGLEMDS)
+       local used_xattr_blk=0
+       local inode_size=${1:-512}
+       local left_size=0
+       local xtest="trusted.test"
+       local value
+       local orig
+       local i
+
+       #Please see LU-6544 for MDT inode size calculation
+       if [ $OSTCOUNT -gt 26 ]; then
+               inode_size=2048
+       elif [ $OSTCOUNT -gt 5 ]; then
+               inode_size=1024
+       fi
+       left_size=$(expr $inode_size - \
+                       156 - \
+                       32 - \
+                       32 - $OSTCOUNT \* 24 - 16 - 3 -  \
+                       24 - 16 - 3 - \
+                       24 - 18 - $(expr length $tfile) - 16 - 4)
+       if [ $left_size -le 0 ]; then
+               echo "No space($left_size) is expected in inode."
+               echo "Try 1-byte xattr instead to verify this."
+               left_size=1
+       else
+               echo "Estimate: at most $left_size-byte space left in inode."
+       fi
+
+       unload_modules
+       reformat
+
+       add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$OSTCOUNT \
+               --reformat $mdsdev $mdsvdev || error "add mds1 failed"
+       start_mdt 1 > /dev/null || error "start mdt1 failed"
+       for i in $(seq $OSTCOUNT); do
+               start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
+                       error "start ost$i failed"
+       done
+       mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
+       check_mount || error "check client $MOUNT failed"
+
+       #set xattr
+       $SETSTRIPE -c -1 $file || error "$SETSTRIPE -c -1 $file failed"
+       $GETSTRIPE $file || error "$GETSTRIPE $file failed"
+       i=$($GETSTRIPE -c $file)
+       if [ $i -ne $OSTCOUNT ]; then
+               left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
+               echo -n "Since only $i out $OSTCOUNT OSTs are used, "
+               echo -n "the expected left space is changed to "
+               echo "$left_size bytes at most."
+       fi
+       value=$(generate_string $left_size)
+       setfattr -n $xtest -v $value $file
+       orig=$(get_xattr_value $xtest $file)
+       [[ "$orig" != "$value" ]] && error "$xtest changed"
+
+       #Verify if inode has some expected space left
+       umount $MOUNT > /dev/null || error "umount $MOUNT failed"
+       stop_mdt 1 > /dev/null || error "stop mdt1 failed"
+       mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
+
+       do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
+       used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
+                       awk '{ print $1 }')
+       [[ $used_xattr_blk -eq 0 ]] &&
+               error "Please check MDS inode size calculation: \
+                      more than $left_size-byte space left in inode."
+       echo "Verified: at most $left_size-byte space left in inode."
+
+       stopall
+}
+run_test 87 "check if MDT inode can hold EAs with N stripes properly"
+
+# $1 test directory
+# $2 (optional) value of max_mod_rpcs_in_flight to set
+check_max_mod_rpcs_in_flight() {
+       local dir="$1"
+       local mmr="$2"
+       local idx
+       local facet
+       local tmp
+       local i
+
+       idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
+       facet="mds$((0x$idx + 1))"
+
+       if [ -z "$mmr" ]; then
+               # get value of max_mod_rcps_in_flight
+               mmr=$($LCTL get_param -n \
+                       mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
+                       error "Unable to get max_mod_rpcs_in_flight"
+               echo "max_mod_rcps_in_flight is $mmr"
+       else
+               # set value of max_mod_rpcs_in_flight
+               $LCTL set_param \
+                   mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
+                       error "Unable to set max_mod_rpcs_in_flight to $mmr"
+               echo "max_mod_rpcs_in_flight set to $mmr"
+       fi
+
+       # create mmr+1 files
+       echo "creating $((mmr + 1)) files ..."
+       umask 0022
+       for i in $(seq $((mmr + 1))); do
+               touch $dir/file-$i
+       done
+
+       ### part 1 ###
+
+       # consumes mmr-1 modify RPC slots
+       #define OBD_FAIL_MDS_REINT_MULTI_NET     0x159
+       # drop requests on MDT so that RPC slots are consumed
+       # during all the request resend interval
+       do_facet $facet "$LCTL set_param fail_loc=0x159"
+       echo "launch $((mmr - 1)) chmod in parallel ..."
+       for i in $(seq $((mmr - 1))); do
+               chmod 0600 $dir/file-$i &
+       done
+
+       # send one additional modify RPC
+       do_facet $facet "$LCTL set_param fail_loc=0"
+       echo "launch 1 additional chmod in parallel ..."
+       chmod 0600 $dir/file-$mmr &
+       sleep 1
+
+       # check this additional modify RPC get a modify RPC slot
+       # and succeed its operation
+       checkstat -vp 0600 $dir/file-$mmr ||
+               error "Unable to send $mmr modify RPCs in parallel"
+       wait
+
+       ### part 2 ###
+
+       # consumes mmr modify RPC slots
+       #define OBD_FAIL_MDS_REINT_MULTI_NET     0x159
+       # drop requests on MDT so that RPC slots are consumed
+       # during all the request resend interval
+       do_facet $facet "$LCTL set_param fail_loc=0x159"
+       echo "launch $mmr chmod in parallel ..."
+       for i in $(seq $mmr); do
+               chmod 0666 $dir/file-$i &
+       done
+
+       # send one additional modify RPC
+       do_facet $facet "$LCTL set_param fail_loc=0"
+       echo "launch 1 additional chmod in parallel ..."
+       chmod 0666 $dir/file-$((mmr + 1)) &
+       sleep 1
+
+       # check this additional modify RPC blocked getting a modify RPC slot
+       checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
+               error "Unexpectedly send $mmr modify RPCs in parallel"
+       wait
+}
+
+test_90a() {
+       reformat
+       if ! combined_mgs_mds ; then
+               start_mgs
+       fi
+       setup
+
+       [[ $($LCTL get_param mdc.*.import |
+            grep "connect_flags:.*multi_mod_rpc") ]] ||
+               { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
+
+       # check default value
+       $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+       check_max_mod_rpcs_in_flight $DIR/$tdir
+
+       cleanup
+}
+run_test 90a "check max_mod_rpcs_in_flight is enforced"
+
+test_90b() {
+       local idx
+       local facet
+       local tmp
+       local mmrpc
+
+       setup
+
+       [[ $($LCTL get_param mdc.*.import |
+            grep "connect_flags:.*multi_mod_rpc") ]] ||
+               { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
+
+       ### test 1.
+       # update max_mod_rpcs_in_flight
+       $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
+       check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
+
+       ### test 2.
+       # check client is able to send multiple modify RPCs in paralell
+       tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
+               grep -c "multi_mod_rpcs")
+       if [ "$tmp" -ne $MDSCOUNT ]; then
+               echo "Client not able to send multiple modify RPCs in parallel"
+               cleanup
+               return
+       fi
+
+       # update max_mod_rpcs_in_flight
+       $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
+       check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
+
+       ### test 3.
+       $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
+       idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
+       facet="mds$((0x$idx + 1))"
+
+       # save MDT max_mod_rpcs_per_client
+       mmrpc=$(do_facet $facet \
+                   cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
+
+       # update max_mod_rpcs_in_flight
+       umount_client $MOUNT
+       do_facet $facet \
+               "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
+       mount_client $MOUNT
+       $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
+       check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
+
+       # restore MDT max_mod_rpcs_per_client initial value
+       do_facet $facet \
+               "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
+
+       rm -rf $DIR/${tdir}?
+       cleanup
+}
+run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
+
+test_90c() {
+       local tmp
+       local mrif
+       local mmrpc
+
+       setup
+
+       [[ $($LCTL get_param mdc.*.import |
+            grep "connect_flags:.*multi_mod_rpc") ]] ||
+               { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
+
+       # check client is able to send multiple modify RPCs in paralell
+       tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
+               grep -c "multi_mod_rpcs")
+       if [ "$tmp" -ne $MDSCOUNT ]; then
+               skip "Client not able to send multiple modify RPCs in parallel"
+               cleanup
+               return
+       fi
+
+       # get max_rpcs_in_flight value
+       mrif=$($LCTL get_param -n mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
+       echo "max_rpcs_in_flight is $mrif"
+
+       # get MDT max_mod_rpcs_per_client
+       mmrpc=$(do_facet mds1 \
+                   cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
+       echo "max_mod_rpcs_per_client is $mmrpc"
+
+       # testcase 1
+       # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
+       # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
+       umount_client $MOUNT
+       do_facet mds1 \
+               "echo $mrif > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
+       mount_client $MOUNT
+
+       $LCTL set_param \
+           mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif &&
+           error "set max_mod_rpcs_in_flight to $mrif should fail"
+
+       umount_client $MOUNT
+       do_facet mds1 \
+               "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
+       mount_client $MOUNT
+
+       # testcase 2
+       # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
+       # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
+       $LCTL set_param \
+           mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc + 2))
+
+       $LCTL set_param \
+           mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc + 1)) &&
+           error "set max_mod_rpcs_in_flight to $((mmrpc + 1)) should fail"
+
+       cleanup
+}
+run_test 90c "check max_mod_rpcs_in_flight update limits"
+
+test_90d() {
+       local idx
+       local facet
+       local mmr
+       local i
+       local pid
+
+       setup
+
+       [[ $($LCTL get_param mdc.*.import |
+            grep "connect_flags:.*multi_mod_rpc") ]] ||
+               { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
+
+       $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+       idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
+       facet="mds$((0x$idx + 1))"
+
+       # check client version supports multislots
+       tmp=$($LCTL get_param -N \
+               mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
+       if [ -z "$tmp" ]; then
+               skip "Client does not support multiple modify RPCs in flight"
+               cleanup
+               return
+       fi
+
+       # get current value of max_mod_rcps_in_flight
+       mmr=$($LCTL get_param -n \
+               mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
+       echo "max_mod_rcps_in_flight is $mmr"
+
+       # create mmr files
+       echo "creating $mmr files ..."
+       umask 0022
+       for i in $(seq $mmr); do
+               touch $DIR/$tdir/file-$i
+       done
+
+       # prepare for close RPC
+       multiop_bg_pause $DIR/$tdir/file-close O_c
+       pid=$!
+
+       # consumes mmr modify RPC slots
+       #define OBD_FAIL_MDS_REINT_MULTI_NET     0x159
+       # drop requests on MDT so that RPC slots are consumed
+       # during all the request resend interval
+       do_facet $facet "$LCTL set_param fail_loc=0x159"
+       echo "launch $mmr chmod in parallel ..."
+       for i in $(seq $mmr); do
+               chmod 0600 $DIR/$tdir/file-$i &
+       done
+
+       # send one additional close RPC
+       do_facet $facet "$LCTL set_param fail_loc=0"
+       echo "launch 1 additional close in parallel ..."
+       kill -USR1 $pid
+       cancel_lru_locks mdc
+       sleep 1
+
+       # check this additional close RPC get a modify RPC slot
+       # and multiop process completed
+       [ -d /proc/$pid ] &&
+               error "Unable to send the additional close RPC in parallel"
+       wait
+       rm -rf $DIR/$tdir
+       cleanup
+}
+run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
+
 if ! combined_mgs_mds ; then
        stop mgs
 fi