# Get the OST target device (given the OST facet name and OST index).
get_ost_dev() {
- local node=$1
- local obdidx=$2
- local ost_name
- local ost_dev
-
- ost_name=$(ostname_from_index $obdidx)
- ost_dev=$(do_node $node "lctl get_param -n obdfilter.${ost_name}.mntdev")
- [ ${PIPESTATUS[0]} -ne 0 ] && \
- echo "failed to find the OST device with index $obdidx on $facet" && \
- return 1
-
- if [[ $ost_dev = *loop* ]]; then
- ost_dev=$(do_node $node "losetup $ost_dev" | \
- sed -e "s/.*(//" -e "s/).*//")
- fi
-
- echo $ost_dev
+ local node=$1
+ local obdidx=$2
+ local ost_name
+ local ost_dev
+
+ ost_name=$(ostname_from_index $obdidx)
+ ost_dev=$(get_obdfilter_param $node $ost_name mntdev)
+ if [ $? -ne 0 ]; then
+ printf "unable to find OST%04x on $facet\n" $obdidx
+ return 1
+ fi
+
+ if [[ $ost_dev = *loop* ]]; then
+ ost_dev=$(do_node $node "losetup $ost_dev" | \
+ sed -e "s/.*(//" -e "s/).*//")
+ fi
+
+ echo $ost_dev
}
# Get the file names to be duplicated or removed on the MDS.
run_test 150 "truncate/append tests"
function roc_hit() {
- local list=$(comma_list $(osts_nodes))
+ local list=$(comma_list $(osts_nodes))
- ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
- awk '/'cache_hit'/ {sum+=$2} END {print sum}')
- echo $ACCNUM
+ echo $(get_obdfilter_param $list '' stats |
+ awk '/'cache_hit'/ {sum+=$2} END {print sum}')
}
function set_cache() {
- local on=1
+ local on=1
- if [ "$2" == "off" ]; then
- on=0;
- fi
- local list=$(comma_list $(osts_nodes))
- do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
+ if [ "$2" == "off" ]; then
+ on=0;
+ fi
+ local list=$(comma_list $(osts_nodes))
+ set_obdfilter_param $list '' $1_cache_enable $on
- cancel_lru_locks osc
+ cancel_lru_locks osc
}
test_151() {
- remote_ost_nodsh && skip "remote OST with nodsh" && return
+ remote_ost_nodsh && skip "remote OST with nodsh" && return
- local CPAGES=3
- local list=$(comma_list $(osts_nodes))
+ local CPAGES=3
+ local list=$(comma_list $(osts_nodes))
- # check whether obdfilter is cache capable at all
- if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
- echo "not cache-capable obdfilter"
- return 0
- fi
+ # check whether obdfilter is cache capable at all
+ if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
+ echo "not cache-capable obdfilter"
+ return 0
+ fi
- # check cache is enabled on all obdfilters
- if do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable | grep 0 >&/dev/null; then
- echo "oss cache is disabled"
- return 0
- fi
+ # check cache is enabled on all obdfilters
+ if get_obdfilter_param $list '' read_cache_enable | grep 0; then
+ echo "oss cache is disabled"
+ return 0
+ fi
- do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable 1
+ set_obdfilter_param $list '' writethrough_cache_enable 1
# pages should be in the case right after write
dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
# the following read invalidates the cache
cancel_lru_locks osc
- do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
+ set_obdfilter_param $list '' read_cache_enable 0
cat $DIR/$tfile >/dev/null
# now data shouldn't be found in the cache
error "IN CACHE: before: $BEFORE, after: $AFTER"
fi
- do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 1
+ set_obdfilter_param $list '' read_cache_enable 1
rm -f $DIR/$tfile
}
run_test 151 "test cache on oss and controls ==============================="
echo -n $label
}
+#
+# This and set_obdfilter_param() shall be used to access OSD parameters
+# once existed under "obdfilter":
+#
+# mntdev
+# stats
+# read_cache_enable
+# writethrough_cache_enable
+#
+get_obdfilter_param() {
+ local nodes=$1
+ local device=${2:-$FSNAME-OST*}
+ local name=$3
+
+ do_nodes $nodes "$LCTL get_param -n obdfilter.$device.$name \
+ osd-*.$device.$name" 2>&1 | grep -v 'Found no match'
+}
+
+set_obdfilter_param() {
+ local nodes=$1
+ local device=${2:-$FSNAME-OST*}
+ local name=$3
+ local value=$4
+
+ do_nodes $nodes "$LCTL set_param -n obdfilter.$device.$name=$value \
+ osd-*.$device.$name=$value" 2>&1 | grep -v 'Found no match'
+}
+
set_debug_size () {
local dz=${1:-$DEBUG_SIZE}
# Get all of the server target devices from a given server node and type.
get_mnt_devs() {
- local node=$1
- local type=$2
- local obd_type
- local devs
- local dev
-
- case $type in
- mdt) obd_type="osd" ;;
- ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
- *) echo "invalid server type" && return 1 ;;
- esac
+ local node=$1
+ local type=$2
+ local devs
+ local dev
- devs=$(do_node $node "lctl get_param -n $obd_type*.*.mntdev")
- for dev in $devs; do
- case $dev in
- *loop*) do_node $node "losetup $dev" | \
- sed -e "s/.*(//" -e "s/).*//" ;;
- *) echo $dev ;;
- esac
- done
+ if [ "$type" == ost ]; then
+ devs=$(get_obdfilter_param $node "" mntdev)
+ else
+ devs=$(do_node $node \
+ "lctl get_param -n osd-*.$FSNAME-M*.mntdev")
+ fi
+ for dev in $devs; do
+ case $dev in
+ *loop*) do_node $node "losetup $dev" | \
+ sed -e "s/.*(//" -e "s/).*//" ;;
+ *) echo $dev ;;
+ esac
+ done
}
# Get all of the server target devices.