echo "done"
}
-check_kernel_version() {
- WANT_VER=$1
- GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
- case $GOT_VER in
- patchless|patchless_client) return 0;;
- *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
- esac
- log "test needs at least kernel version $WANT_VER, running $GOT_VER"
- return 1
-}
-
check_swap_layouts_support()
{
$LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
return 1
}
-if [ "$ONLY" == "cleanup" ]; then
- sh llmountcleanup.sh
- exit 0
-fi
-
check_and_setup_lustre
DIR=${DIR:-$MOUNT}
run_test 24n "Statting the old file after renaming (Posix rename 2)"
test_24o() {
- check_kernel_version 37 || return 0
test_mkdir -p $DIR/d24o
rename_many -s random -v -n 10 $DIR/d24o
}
run_test 31d "remove of open directory ========================="
test_31e() { # bug 2904
- check_kernel_version 34 || return 0
openfilleddirunlink $DIR/d31e || error
}
run_test 31e "remove of open non-empty directory ==============="
[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
return
- check_kernel_version 34 || return 0
- test_mkdir -p $DIR/$tdir
+ test_mkdir $DIR/$tdir
cd $DIR/$tdir
- mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
+ mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
test_mkdir $DIR/$tdir || error "recreate directory failed"
touch foo || error "'touch foo' failed after recreating cwd"
- test_mkdir $DIR/$tdir/bar ||
- error "'mkdir foo' failed after recreating cwd"
- if check_kernel_version 44; then
- touch .foo || error "'touch .foo' failed after recreating cwd"
- test_mkdir $DIR/$tdir/.bar ||
- error "'mkdir .foo' failed after recreating cwd"
- fi
+ test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
+ touch .foo || error "'touch .foo' failed after recreating cwd"
+ test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
ls . > /dev/null || error "'ls .' failed after recreating cwd"
ls .. > /dev/null || error "'ls ..' failed after removing cwd"
cd . || error "'cd .' failed after recreating cwd"
run_test 48a "Access renamed working dir (should return errors)="
test_48b() { # bug 2399
- check_kernel_version 34 || return 0
rm -rf $DIR/$tdir
- test_mkdir -p $DIR/$tdir
+ test_mkdir $DIR/$tdir
cd $DIR/$tdir
rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
touch foo && error "'touch foo' worked after removing cwd"
- test_mkdir $DIR/$tdir/foo &&
- error "'mkdir foo' worked after removing cwd"
- if check_kernel_version 44; then
- touch .foo && error "'touch .foo' worked after removing cwd"
- test_mkdir $DIR/$tdir/.foo &&
- error "'mkdir .foo' worked after removing cwd"
- fi
+ test_mkdir foo && error "'mkdir foo' worked after removing cwd"
+ touch .foo && error "'touch .foo' worked after removing cwd"
+ test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
ls . > /dev/null && error "'ls .' worked after removing cwd"
ls .. > /dev/null || error "'ls ..' failed after removing cwd"
is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
- test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
+ test_mkdir . && error "'mkdir .' worked after removing cwd"
rmdir . && error "'rmdir .' worked after removing cwd"
ln -s . foo && error "'ln -s .' worked after removing cwd"
cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
run_test 48b "Access removed working dir (should return errors)="
test_48c() { # bug 2350
- check_kernel_version 36 || return 0
#lctl set_param debug=-1
#set -vx
rm -rf $DIR/$tdir
$TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
$TRACE touch foo && error "touch foo worked after removing cwd"
$TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
- if check_kernel_version 44; then
- touch .foo && error "touch .foo worked after removing cwd"
- test_mkdir .foo && error "mkdir .foo worked after removing cwd"
- fi
+ touch .foo && error "touch .foo worked after removing cwd"
+ test_mkdir .foo && error "mkdir .foo worked after removing cwd"
$TRACE ls . && error "'ls .' worked after removing cwd"
$TRACE ls .. || error "'ls ..' failed after removing cwd"
is_patchless || ( $TRACE cd . &&
run_test 48c "Access removed working subdir (should return errors)"
test_48d() { # bug 2350
- check_kernel_version 36 || return 0
#lctl set_param debug=-1
#set -vx
rm -rf $DIR/$tdir
$TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
$TRACE touch foo && error "'touch foo' worked after removing parent"
$TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
- if check_kernel_version 44; then
- touch .foo && error "'touch .foo' worked after removing parent"
- test_mkdir .foo &&
- error "mkdir .foo worked after removing parent"
- fi
+ touch .foo && error "'touch .foo' worked after removing parent"
+ test_mkdir .foo && error "mkdir .foo worked after removing parent"
$TRACE ls . && error "'ls .' worked after removing parent"
$TRACE ls .. && error "'ls ..' worked after removing parent"
is_patchless || ( $TRACE cd . &&
run_test 48d "Access removed parent subdir (should return errors)"
test_48e() { # bug 4134
- check_kernel_version 41 || return 0
#lctl set_param debug=-1
#set -vx
rm -rf $DIR/$tdir
run_test 54d "fifo device works in lustre ======================"
test_54e() {
- check_kernel_version 46 || return 0
f="$DIR/f54e"
string="aaaaaa"
cp -aL /dev/console $f
fi
}
+# Return a numeric version code based on a version string. The version
+# code is useful for comparison two version strings to see which is newer.
version_code() {
- # split arguments like "1.8.6-wc3" into "1", "8", "6", "wc3"
- eval set -- $(tr "[:punct:]" " " <<< $*)
+ # split arguments like "1.8.6-wc3" into "1", "8", "6", "wc3"
+ eval set -- $(tr "[:punct:]" " " <<< $*)
- echo -n "$((($1 << 16) | ($2 << 8) | $3))"
+ echo -n "$((($1 << 16) | ($2 << 8) | $3))"
}
export LINUX_VERSION=$(uname -r | sed -e "s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/")
export LINUX_VERSION_CODE=$(version_code ${LINUX_VERSION//\./ })
+# Report the Lustre build version string (e.g. 1.8.7.3 or 2.4.1).
+#
+# usage: lustre_build_version
+#
+# All Lustre versions support "lctl get_param" to report the version of the
+# code running in the kernel (what our tests are interested in), but it
+# doesn't work without modules loaded. If that fails, use "lctl version"
+# instead, which is easy to parse and works without the kernel modules,
+# but was only added in 2.6.50. If that also fails, fall back to calling
+# "lctl lustre_build_version" which prints either (or both) the userspace
+# and kernel build versions, but is deprecated and should eventually be
+# removed.
+#
+# output: prints version string to stdout in dotted-decimal format
+lustre_build_version() {
+ local facet=${1:-client}
+
+ # lustre: 2.6.52
+ # kernel: patchless_client
+ # build: v2_6_92_0-gadb3ee4-2.6.32-431.29.2.el6_lustre.x86_64
+ local VER=$(do_facet $facet $LCTL get_param -n version 2> /dev/null |
+ awk '/lustre: / { print $2 }')
+ # lctl 2.6.50
+ [ -z "$VER" ] && VER=$(do_facet $facet $LCTL --version 2>/dev/null |
+ awk '{ print $2 }')
+ # Lustre version: 2.5.3-gfcfd782-CHANGED-2.6.32.26-175.fc12.x86_64
+ # lctl version: 2.5.3-gfcfd782-CHANGED-2.6.32.26-175.fc12.x86_64
+ [ -z "$VER" ] && VER=$(do_facet $facet $LCTL lustre_build_version |
+ awk '/version:/ { print $3; exit; }')
+ sed -e 's/^v//' -e 's/-.*//' -e 's/_/./g' <<<$VER
+}
+
+# Report the Lustre numeric build version code for the supplied facet.
+lustre_version_code() {
+ version_code $(lustre_build_version $1)
+}
+
module_loaded () {
- /sbin/lsmod | grep -q "^\<$1\>"
+ /sbin/lsmod | grep -q "^\<$1\>"
}
# Load a module on the system where this is running.
EXT=".ko"
module=$1
shift
- BASE=`basename $module $EXT`
+ BASE=$(basename $module $EXT)
module_loaded ${BASE} && return
- # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
- # modprobe.conf
+ # If no module arguments were passed, get them from $MODOPTS_<MODULE>,
+ # else from modprobe.conf
if [ $# -eq 0 ]; then
# $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
# Bash until 4.x, so we resort to eval.
}
facet_active_host() {
- local facet=$1
- local active=`facet_active $facet`
- if [ "$facet" == client ]; then
- echo $HOSTNAME
- else
- echo `facet_host $active`
- fi
+ facet_host $(facet_active $1)
}
# Get the passive failover partner host of facet.
}
do_facet() {
- local facet=$1
- shift
- local HOST=`facet_active_host $facet`
- [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
- do_node $HOST "$@"
+ local facet=$1
+ shift
+ local HOST=$(facet_active_host $facet)
+ [ -z $HOST ] && echo "No host defined for facet ${facet}" && exit 1
+ do_node $HOST "$@"
}
# Function: do_facet_random_file $FACET $FILE $SIZE
log() {
echo "$*" >&2
- module_loaded lnet || load_modules
+ load_module ../libcfs/libcfs/libcfs
local MSG="$*"
# Get rid of '
}
get_clientosc_proc_path() {
- echo "${1}-osc-*"
-}
-
-get_lustre_version () {
- local facet=${1:-"$SINGLEMDS"}
- do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
-}
-
-lustre_version_code() {
- local facet=${1:-"$SINGLEMDS"}
- version_code $(get_lustre_version $1)
+ echo "${1}-osc-*"
}
# If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names