set_default_debug
load_module ../lnet/lnet/lnet
- case $NETTYPE in
- o2ib)
- LNETLND="o2iblnd/ko2iblnd"
- ;;
- *)
- ;;
- esac
- LNETLND=${LNETLND:-"socklnd/ksocklnd"}
+
+ LNDPATH=${LNDPATH:-"../lnet/klnds"}
+ if [ -z "$LNETLND" ]; then
+ case $NETTYPE in
+ o2ib*) LNETLND="o2iblnd/ko2iblnd" ;;
+ tcp*) LNETLND="socklnd/ksocklnd" ;;
+ *) local lnd="${NETTYPE%%[0-9]}lnd"
+ [ -f "$LNDPATH/$lnd/k$lnd.ko" ] &&
+ LNETLND="$lnd/k$lnd" ||
+ LNETLND="socklnd/ksocklnd"
+ esac
+ fi
load_module ../lnet/klnds/$LNETLND
load_module obdclass/obdclass
load_module ptlrpc/ptlrpc
[ "$LQUOTA" != "no" ] &&
load_module quota/lquota $LQUOTAOPTS
if [[ $(node_fstypes $HOSTNAME) == *zfs* ]]; then
- modprobe zfs
+ lsmod | grep zfs >&/dev/null || modprobe zfs
load_module osd-zfs/osd_zfs
fi
if [[ $(node_fstypes $HOSTNAME) == *ldiskfs* ]]; then
shift 3
local opts=${@:-"-o cachefile=none"}
- do_facet $facet "modprobe zfs;
+ do_facet $facet "lsmod | grep zfs >&/dev/null || modprobe zfs;
$ZPOOL list -H $poolname >/dev/null 2>&1 ||
$ZPOOL create -f $opts $poolname $vdev"
}
if [[ -n "$poolname" ]]; then
opts+=" -d $(dirname $(facet_vdevice $facet))"
- do_facet $facet "modprobe zfs;
+ do_facet $facet "lsmod | grep zfs >&/dev/null || modprobe zfs;
$ZPOOL list -H $poolname >/dev/null 2>&1 ||
$ZPOOL import -f $opts $poolname"
fi
fi
do_nodes $clients "
-running=\\\$(mount | grep -c $mnt' ');
-rc=0;
-if [ \\\$running -eq 0 ] ; then
- mkdir -p $mnt;
- $MOUNT_CMD $flags $opts $device $mnt;
- rc=\\\$?;
-fi;
-exit \\\$rc" || return ${PIPESTATUS[0]}
+ running=\\\$(mount | grep -c $mnt' ');
+ rc=0;
+ if [ \\\$running -eq 0 ] ; then
+ mkdir -p $mnt;
+ $MOUNT_CMD $flags $opts $device $mnt;
+ rc=\\\$?;
+ else
+ lustre_mnt_count=\\\$(mount | grep $mnt' ' | \
+ grep 'type lustre' | wc -l);
+ if [ \\\$running -ne \\\$lustre_mnt_count ] ; then
+ echo zconf_mount_clients FAILED: \
+ mount count \\\$running, not matching \
+ with mount count of 'type lustre' \
+ \\\$lustre_mnt_count;
+ rc=1;
+ fi;
+ fi;
+ exit \\\$rc" || return ${PIPESTATUS[0]}
echo "Started clients $clients: "
do_nodes $clients "mount | grep $mnt' '"
wait_update $HOSTNAME "eval $cmd" $OSTCOUNT ||
error "wait_update OSTs up on client failed"
- cmd="$LCTL get_param -n lod.$FSNAME-MDT*-*.target_obd | sort -u |
- awk 'BEGIN {c = 0} /ACTIVE/{c += 1} END {printf \\\"%d\\\", c}'"
+ cmd="$LCTL get_param osp.$FSNAME-OST*-MDT0000.prealloc_last_id |
+ awk '/=[1-9][0-9]/ { c += 1 } END { printf \\\"%d\\\", c }'"
wait_update_facet $SINGLEMDS "eval $cmd" $OSTCOUNT ||
- error "wait_update OSTs up on MDT failed"
+ error "wait_update OSTs up on MDT0000 failed"
}
wait_destroy_complete () {
clients_up || error "post-failover stat: $?"
}
-do_lmc() {
- echo There is no lmc. This is mountconf, baby.
- exit 1
-}
-
host_nids_address() {
- local nodes=$1
- local kind=$2
+ local nodes=$1
+ local net=${2:-"."}
- if [ -n "$kind" ]; then
- nids=$(do_nodes $nodes "$LCTL list_nids | grep $kind | cut -f 1 -d '@'")
- else
- nids=$(do_nodes $nodes "$LCTL list_nids all | cut -f 1 -d '@'")
- fi
- echo $nids
+ do_nodes $nodes "$LCTL list_nids | grep $net | cut -f 1 -d @"
}
h2name_or_ip() {
fi
}
-h2ptl() {
- if [ "$1" = "'*'" ]; then echo \'*\'; else
- ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | \
- awk '{print $1}'`
- if [ -z "$ID" ]; then
- echo "Could not get a ptl id for $1..."
- exit 1
- fi
- echo $ID"@ptl"
+h2nettype() {
+ if [[ -n "$NETTYPE" ]]; then
+ h2name_or_ip "$1" "$NETTYPE"
+ else
+ h2name_or_ip "$1" "$2"
fi
}
-declare -fx h2ptl
+declare -fx h2nettype
+# Wrapper function to print the deprecation warning
h2tcp() {
- h2name_or_ip "$1" "tcp"
-}
-declare -fx h2tcp
-
-h2elan() {
- if [ "$1" = "'*'" ]; then echo \'*\'; else
- if type __h2elan >/dev/null 2>&1; then
- ID=$(__h2elan $1)
- else
- ID=`echo $1 | sed 's/[^0-9]*//g'`
- fi
- echo $ID"@elan"
+ echo "h2tcp: deprecated, use h2nettype instead" 1>&2
+ if [[ -n "$NETTYPE" ]]; then
+ h2nettype "$@"
+ else
+ h2nettype "$1" "tcp"
fi
}
-declare -fx h2elan
+# Wrapper function to print the deprecation warning
h2o2ib() {
- h2name_or_ip "$1" "o2ib"
+ echo "h2o2ib: deprecated, use h2nettype instead" 1>&2
+ if [[ -n "$NETTYPE" ]]; then
+ h2nettype "$@"
+ else
+ h2nettype "$1" "o2ib"
+ fi
}
-declare -fx h2o2ib
# This enables variables in cfg/"setup".sh files to support the pdsh HOSTLIST
# expressions format. As a bonus we can then just pass in those variables
var=${facet}failover_HOST
if [ -n "${!var}" ] && [ ${!var} != $(facet_host $facet) ]; then
- opts+=" --failnode=$(h2$NETTYPE ${!var})"
+ opts+=" --failnode=$(h2nettype ${!var})"
fi
opts+=${TIMEOUT:+" --param=sys.timeout=$TIMEOUT"}
done
}
+__touch_device()
+{
+ local facet_type=$1 # mgs || mds || ost
+ local facet_num=$2
+ local facet=${1}${2}
+ local device
+
+ case "$(facet_fstype $facet)" in
+ ldiskfs)
+ device=$(${facet_type}devname $facet_num)
+ ;;
+ zfs)
+ device=$(${facet_type}vdevname $facet_num)
+ ;;
+ *)
+ error "Unhandled filesystem type"
+ ;;
+ esac
+
+ do_facet $facet "[ -e \"$device\" ]" && return
+
+ # Note: the following check only works with absolute paths
+ [[ ! "$device" =~ ^/dev/ ]] || [[ "$device" =~ ^/dev/shm/ ]] ||
+ error "$facet: device '$device' does not exist"
+
+ do_facet $facet "touch \"${device}\""
+}
+
format_mgs() {
local quiet
fi
echo "Format mgs: $(mgsdevname)"
reformat_external_journal mgs
+
+ # touch "device" in case it is a loopback file for testing and needs to
+ # be created. mkfs.lustre doesn't do this to avoid accidentally writing
+ # to non-existent files in /dev if the admin made a typo during setup
+ __touch_device mgs
+
add mgs $(mkfs_opts mgs $(mgsdevname)) $(mountfs_opts mgs) --reformat \
$(mgsdevname) $(mgsvdevname) ${quiet:+>/dev/null} || exit 10
}
fi
echo "Format mds$num: $(mdsdevname $num)"
reformat_external_journal mds$num
+
+ __touch_device mds $num
+
add mds$num $(mkfs_opts mds$num $(mdsdevname ${num})) \
$(mountfs_opts mds$num) --reformat $(mdsdevname $num) \
$(mdsvdevname $num) ${quiet:+>/dev/null} || exit 10
fi
echo "Format ost$num: $(ostdevname $num)"
reformat_external_journal ost$num
+
+ __touch_device ost $num
+
add ost$num $(mkfs_opts ost$num $(ostdevname ${num})) \
$(mountfs_opts ost$num) --reformat $(ostdevname $num) \
$(ostvdevname ${num}) ${quiet:+>/dev/null} || exit 10
return 0
fi
- local myMGS_host=$mgs_HOST
- if [ "$NETTYPE" = "ptl" ]; then
- myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
- fi
-
echo Checking config lustre mounted on $mntpt
local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
mgshost=$(echo $mgshost | awk -F: '{print $1}')
-# if [ "$mgshost" != "$myMGS_host" ]; then
-# log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
-# Please use correct config or set mds_HOST correctly!"
-# fi
-
}
check_config_clients () {
setstripe_nfsserver () {
local dir=$1
+ local nfsexportdir=$2
+ shift
+ shift
- local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
- { print $1 }' /proc/mounts | cut -f 1 -d : | head -n1)
+ local -a nfsexport=($(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
+ { print $1 }' /proc/mounts | cut -f 1 -d :))
- [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
+ # check that only one nfs mounted
+ [[ -z $nfsexport ]] && echo "$dir is not nfs mounted" && return 1
+ (( ${#nfsexport[@]} == 1 )) ||
+ error "several nfs mounts found for $dir: ${nfsexport[@]} !"
- do_nodev $nfsserver lfs setstripe "$@"
+ do_nodev ${nfsexport[0]} lfs setstripe $nfsexportdir "$@"
}
# Check and add a test group.
}
min_ost_size () {
- $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
+ $LFS df | grep OST | awk '{print $4}' | sort -un | head -1
}
#