Skip to content

Commit

Permalink
ndctl/test: Exercise sub-section sized namespace creation/deletion
Browse files Browse the repository at this point in the history
For kernels that have removed the section-aligned namespace constraint
validate that multiple namespaces can be created / deleted that collide
within a given section.

While this test acts on the ACPI.NFIT bus it is not marked "destructive"
because it only operates in available capacity and marks each namespace
created with a unique volume name ("subsection-test").

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
djbw committed Apr 16, 2019
1 parent 1d5c639 commit 7c59b48
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ TESTS =\
inject-smart.sh \
monitor.sh \
max_available_extent_ns.sh \
pfn-meta-errors.sh
pfn-meta-errors.sh \
sub-section.sh

if ENABLE_KEYUTILS
TESTS += security.sh
Expand Down
78 changes: 78 additions & 0 deletions test/sub-section.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash -x

# SPDX-License-Identifier: GPL-2.0
# Copyright(c) 2015-2019 Intel Corporation. All rights reserved.

set -e

SKIP=77
FAIL=1
SUCCESS=0

. ./common

check_min_kver "5.2" || do_skip "may lack align sub-section hotplug support"

MNT=test_dax_mnt
mkdir -p $MNT

TEST_SIZE=$((16<<20))
MIN_AVAIL=$((TEST_SIZE*4))
MAX_NS=10
NAME="subsection-test"

ndctl list -N | jq -r ".[] | select(.name==\"subsection-test\") | .dev"

rc=$FAIL
cleanup() {
if [ $rc -ne $SUCCESS ]; then
echo "test/sub-section.sh: failed at line $1"
fi
if mountpoint -q $MNT; then
umount $MNT
fi
rmdir $MNT
# opportunistic cleanup, not fatal if these fail
namespaces=$($NDCTL list -N | jq -r ".[] | select(.name==\"$NAME\") | .dev")
for i in $namespaces
do
if ! $NDCTL destroy-namespace -f $i; then
echo "test/sub-section.sh: cleanup() failed to destroy $i"
fi
done
exit $rc
}

trap 'err $LINENO cleanup' ERR

json=$($NDCTL list -R -b ACPI.NFIT)
region=$(echo $json | jq -r "[.[] | select(.available_size >= $MIN_AVAIL)][0].dev")
avail=$(echo $json | jq -r "[.[] | select(.available_size >= $MIN_AVAIL)][0].available_size")
if [ -z $region ]; then
exit $SKIP
fi

iter=$((avail/TEST_SIZE))
if [ $iter -gt $MAX_NS ]; then
iter=$MAX_NS;
fi

for i in $(seq 1 $iter)
do
json=$($NDCTL create-namespace -s $TEST_SIZE --no-autorecover -r $region -n "$NAME")
dev=$(echo $json | jq -r ".blockdev")
mkfs.ext4 -b 4096 /dev/$dev
mount -o dax /dev/$dev $MNT
umount $MNT
done

namespaces=$($NDCTL list -N | jq -r ".[] | select(.name==\"$NAME\") | .dev")
for i in $namespaces
do
$NDCTL disable-namespace $i
$NDCTL enable-namespace $i
$NDCTL destroy-namespace $i -f
done

rc=$SUCCESS
cleanup $LINENO

0 comments on commit 7c59b48

Please sign in to comment.