+test_85() {
+ [[ $(lustre_version_code ost1) -ge $(version_code 2.7.55) ]] ||
+ { skip "Need OST version at least 2.7.55" && return 0; }
+##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
+ do_facet ost1 "lctl set_param fail_loc=0x197"
+ start_ost
+ stop_ost
+}
+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
+ sleep 1
+
+ # 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
+ sleep 1
+
+ # 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 + 1)) 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"
+
+check_uuid_on_ost() {
+ local nid=$1
+ do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
+}
+
+check_uuid_on_mdt() {
+ local nid=$1
+ do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
+}
+
+test_91() {
+ local uuid
+ local nid
+ local found
+
+ load_modules
+
+ [[ $(lustre_version_code ost1) -ge $(version_code 2.7.63) ]] ||
+ { skip "Need OST version at least 2.7.63" && return 0; }
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.63) ]] ||
+ { skip "Need MDT version at least 2.7.63" && return 0; }
+
+ start_mds || error "MDS start failed"
+ start_ost || error "unable to start OST"
+ mount_client $MOUNT || error "client start failed"
+ check_mount || error "check_mount failed"
+
+ if remote_mds; then
+ nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
+ else
+ nid="0@lo"
+ fi
+ uuid=$(get_client_uuid $MOUNT)
+
+ echo "list nids on mdt:"
+ do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
+ echo "uuid from $nid:"
+ do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
+
+ found=$(check_uuid_on_mdt $nid | grep $uuid)
+ [ -z "$found" ] && error "can't find $uuid $nid on MDT"
+ found=$(check_uuid_on_ost $nid | grep $uuid)
+ [ -z "$found" ] && error "can't find $uuid $nid on OST"
+
+ # umount the client so it won't reconnect
+ manual_umount_client --force || error "failed to umount $?"
+ # shouldn't disappear on MDS after forced umount
+ found=$(check_uuid_on_mdt $nid | grep $uuid)
+ [ -z "$found" ] && error "can't find $uuid $nid"
+
+ echo "evict $nid"
+ do_facet $SINGLEMDS \
+ "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
+
+ found=$(check_uuid_on_mdt $nid | grep $uuid)
+ [ -n "$found" ] && error "found $uuid $nid on MDT"
+ found=$(check_uuid_on_ost $nid | grep $uuid)
+ [ -n "$found" ] && error "found $uuid $nid on OST"
+
+ # check it didn't reconnect (being umounted)
+ sleep $((TIMEOUT+1))
+ found=$(check_uuid_on_mdt $nid | grep $uuid)
+ [ -n "$found" ] && error "found $uuid $nid on MDT"
+ found=$(check_uuid_on_ost $nid | grep $uuid)
+ [ -n "$found" ] && error "found $uuid $nid on OST"
+
+ cleanup
+}
+run_test 91 "evict-by-nid support"
+