. $LUSTRE/tests/functions.sh
. $LUSTRE/tests/yaml.sh
+export LD_LIBRARY_PATH=${LUSTRE}/utils:${LD_LIBRARY_PATH}
+
LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
}
load_modules_local() {
+ [ $(facet_fstype ost1) == "zfs" ] && export USE_OFD=yes
if [ "$USE_OFD" == yes ]; then
if module_loaded obdfilter; then
if ! $LUSTRE_RMMOD ldiskfs; then
load_module osd-ldiskfs/osd_ldiskfs
fi
load_module mdt/mdt
- load_module cmm/cmm
load_module ost/ost
+ load_module lod/lod
+ load_module osp/osp
if [ "$USE_OFD" == yes ]; then
load_module ofd/ofd
else
# save quota version (both administrative and operational quotas)
# add an additional parameter if mountpoint is ever different from $MOUNT
+#
+# XXX This function is kept for interoperability with old server (< 2.3.50),
+# it should be removed whenever we drop the interoperability for such
+# server.
quota_save_version() {
local fsname=${2:-$FSNAME}
local spec=$1
done
}
-# client could mount several lustre
+# client could mount several lustre
+#
+# XXX This function is kept for interoperability with old server (< 2.3.50),
+# it should be removed whenever we drop the interoperability for such
+# server.
quota_type () {
local fsname=${1:-$FSNAME}
local rc=0
return $rc
}
-restore_quota_type () {
- local mntpt=${1:-$MOUNT}
- local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
- if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
- return
- fi
- quota_save_version $old_QUOTA_TYPE
+# XXX This function is kept for interoperability with old server (< 2.3.50),
+# it should be removed whenever we drop the interoperability for such
+# server.
+restore_quota_old() {
+ local mntpt=${1:-$MOUNT}
+ local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
+ if [ ! "$old_QUOTA_TYPE" ] ||
+ [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
+ return
+ fi
+ quota_save_version $old_QUOTA_TYPE
}
-setup_quota(){
- local mntpt=$1
+# XXX This function is kept for interoperability with old server (< 2.3.50),
+# it should be removed whenever we drop the interoperability for such
+# server.
+setup_quota_old(){
+ local mntpt=$1
- if [ "$USE_OFD" = "yes" ]; then
- $LFS quotacheck $mntpt || error "quotacheck failed"
- return
- fi
+ # no quota enforcement for now and accounting works out of the box
+ return
# We need save the original quota_type params, and restore them after testing
done
}
+# get mdt quota type
+mdt_quota_type() {
+ local varsvc=${SINGLEMDS}_svc
+ do_facet $SINGLEMDS $LCTL get_param -n \
+ osd-$FSTYPE.${!varsvc}.quota_slave.enabled
+}
+
+# get ost quota type
+ost_quota_type() {
+ # All OSTs should have same quota type
+ local varsvc=ost1_svc
+ do_facet ost1 $LCTL get_param -n \
+ osd-$FSTYPE.${!varsvc}.quota_slave.enabled
+}
+
+# restore old quota type settings
+restore_quota() {
+ if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
+ restore_quota_old
+ return
+ fi
+
+ if [ "$old_MDT_QUOTA_TYPE" ]; then
+ do_facet mgs $LCTL conf_param \
+ $FSNAME.quota.mdt=$old_MDT_QUOTA_TYPE
+ fi
+ if [ "$old_OST_QUOTA_TYPE" ]; then
+ do_facet mgs $LCTL conf_param \
+ $FSNAME.quota.ost=$old_OST_QUOTA_TYPE
+ fi
+}
+
+setup_quota(){
+ if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
+ setup_quota_old $1
+ return
+ fi
+
+ # XXX remove it once all quota code landed
+ echo "skip quota setup"
+ return
+
+ local mntpt=$1
+
+ # save old quota type & set new quota type
+ local mdt_qtype=$(mdt_quota_type)
+ local ost_qtype=$(ost_quota_type)
+
+ echo "[HOST:$HOSTNAME] [old_mdt_qtype:$mdt_qtype]" \
+ "[old_ost_qtype:$ost_qtype] [new_qtype:$QUOTA_TYPE]"
+
+ export old_MDT_QUOTA_TYPE=$mdt_qtype
+ export old_OST_QUOTA_TYPE=$ost_qtype
+
+ do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$QUOTA_TYPE ||
+ error "set mdt quota type failed"
+ do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$QUOTA_TYPE ||
+ error "set ost quota type failed"
+
+ local quota_usrs=$QUOTA_USERS
+
+ # get_filesystem_size
+ local disksz=$(lfs df $mntpt | grep "filesystem summary:" |
+ awk '{print $3}')
+ local blk_soft=$((disksz + 1024))
+ local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
+
+ local inodes=$(lfs df -i $mntpt | grep "filesystem summary:" |
+ awk '{print $3}')
+ local i_soft=$inodes
+ local i_hard=$((i_soft + i_soft / 20))
+
+ echo "Total disk size: $disksz block-softlimit: $blk_soft" \
+ "block-hardlimit: $blk_hard inode-softlimit: $i_soft" \
+ "inode-hardlimit: $i_hard"
+
+ local cmd
+ for usr in $quota_usrs; do
+ echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
+ for type in u g; do
+ cmd="$LFS setquota -$type $usr -b $blk_soft"
+ cmd="$cmd -B $blk_hard -i $i_soft -I $i_hard $mntpt"
+ echo "+ $cmd"
+ eval $cmd || error "$cmd FAILED!"
+ done
+ # display the quota status
+ echo "Quota settings for $usr : "
+ $LFS quota -v -u $usr $mntpt || true
+ done
+}
+
zconf_mount() {
local client=$1
local mnt=$2
echo $(comma_list $affected)
}
-facet_up () {
- local facet=$1
- local host=${2:-$(facet_host $facet)}
+facet_up() {
+ local facet=$1
+ local host=${2:-$(facet_host $facet)}
- local label=$(convert_facet2label $facet)
- do_node $host lctl dl | awk '{print $4}' | grep -q $label
+ local label=$(convert_facet2label $facet)
+ do_node $host $LCTL dl | awk '{print $4}' | grep -q -x $label
}
facets_up_on_host () {
return 3
}
-wait_update_facet () {
- local facet=$1
- wait_update $(facet_active_host $facet) "$@"
+wait_update_facet() {
+ local facet=$1
+ shift
+ wait_update $(facet_active_host $facet) "$@"
}
sync_all_data() {
grep -v 'Found no match'
}
-wait_delete_completed () {
- local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
- awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
+wait_delete_completed_mds() {
+ local MAX_WAIT=${1:-20}
+ local mds2sync=""
+ local stime=`date +%s`
+ local etime
+ local node
+ local changes
+
+ # find MDS with pending deletions
+ for node in $(mdts_nodes); do
+ changes=$(do_node $node "lctl get_param -n osc.*MDT*.sync_*" \
+ 2>/dev/null | calc_sum)
+ if [ -z "$changes" ] || [ $changes -eq 0 ]; then
+ continue
+ fi
+ mds2sync="$mds2sync $node"
+ done
+ if [ "$mds2sync" == "" ]; then
+ return
+ fi
+ mds2sync=$(comma_list $mds2sync)
+
+ # sync MDS transactions
+ do_nodes $mds2sync "lctl set_param -n osd*.*MD*.force_sync 1"
+
+ # wait till all changes are sent and commmitted by OSTs
+ # for ldiskfs space is released upon execution, but DMU
+ # do this upon commit
+
+ local WAIT=0
+ while [ "$WAIT" -ne "$MAX_WAIT" ]; do
+ changes=$(do_nodes $mds2sync "lctl get_param -n osc.*MDT*.sync_*" \
+ | calc_sum)
+ #echo "$node: $changes changes on all"
+ if [ "$changes" -eq "0" ]; then
+ etime=`date +%s`
+ #echo "delete took $((etime - stime)) seconds"
+ return
+ fi
+ sleep 1
+ WAIT=$(( WAIT + 1))
+ done
- local WAIT=0
- local MAX_WAIT=20
- while [ "$WAIT" -ne "$MAX_WAIT" ]; do
- sleep 1
- TOTAL=`lctl get_param -n osc.*.kbytesavail | \
- awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
- [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
- echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
- TOTALPREV=$TOTAL
- WAIT=$(( WAIT + 1))
- done
- echo "Delete is not completed in $MAX_WAIT sec"
- return 1
+ etime=`date +%s`
+ echo "Delete is not completed in $((etime - stime)) seconds"
+ do_nodes $mds2sync "lctl get_param osc.*MDT*.sync_*"
}
wait_for_host() {
}
wait_destroy_complete () {
- echo "Waiting for destroy to be done..."
- # MAX value shouldn't be big as this mean server responsiveness
- # never increase this just to make test pass but investigate
- # why it takes so long time
- local MAX=5
- local WAIT=0
- while [ $WAIT -lt $MAX ]; do
- local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
- local con=1
- for ((i=0; i<${#RPCs[@]}; i++)); do
- [ ${RPCs[$i]} -eq 0 ] && continue
- # there are still some destroy RPCs in flight
- con=0
- break;
- done
- sleep 1
- [ ${con} -eq 1 ] && return 0 # done waiting
- echo "Waiting $WAIT secs for destroys to be done."
- WAIT=$((WAIT + 1))
- done
- echo "Destroys weren't done in $MAX sec."
- return 1
+ echo "Waiting for local destroys to complete"
+ # MAX value shouldn't be big as this mean server responsiveness
+ # never increase this just to make test pass but investigate
+ # why it takes so long time
+ local MAX=5
+ local WAIT=0
+ while [ $WAIT -lt $MAX ]; do
+ local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
+ local con=1
+ local i
+
+ for ((i=0; i<${#RPCs[@]}; i++)); do
+ [ ${RPCs[$i]} -eq 0 ] && continue
+ # there are still some destroy RPCs in flight
+ con=0
+ break;
+ done
+ sleep 1
+ [ ${con} -eq 1 ] && return 0 # done waiting
+ echo "Waiting ${WAIT}s for local destroys to complete"
+ WAIT=$((WAIT + 1))
+ done
+ echo "Local destroys weren't done in $MAX sec."
+ return 1
+}
+
+wait_delete_completed() {
+ wait_delete_completed_mds $1 || return $?
+ wait_destroy_complete
}
wait_exit_ST () {
setup_quota $MOUNT || return 2
else
echo "disable quota as required"
- $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
+ # $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
fi
fi
return 0
local ostidx
local dev
+ [[ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]] ||
+ { skip "Lustre 2.2.0 lacks the patch for LU-1255"; exit 0; }
+
check_shared_dir $SHARED_DIRECTORY ||
error "$SHARED_DIRECTORY isn't a shared directory"
run_lfsck
fi
- if is_mounted $MOUNT; then
- [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
- error "remove sub-test dirs failed"
- [ "$ENABLE_QUOTA" ] && restore_quota_type || true
- fi
+ if is_mounted $MOUNT; then
+ [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
+ error "remove sub-test dirs failed"
+ [ "$ENABLE_QUOTA" ] && restore_quota || true
+ fi
if [ "$I_UMOUNTED2" = "yes" ]; then
restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
error_noexit "$@"
}
+error_and_remount() {
+ error_noexit "$@"
+ remount_client $MOUNT
+ exit 1
+}
+
skip_env () {
$FAIL_ON_SKIP_ENV && error false $@ || skip $@
}