Skip to content

Commit 7c59b48

Browse files
committed
ndctl/test: Exercise sub-section sized namespace creation/deletion
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 <[email protected]>
1 parent 1d5c639 commit 7c59b48

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

test/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ TESTS =\
2525
inject-smart.sh \
2626
monitor.sh \
2727
max_available_extent_ns.sh \
28-
pfn-meta-errors.sh
28+
pfn-meta-errors.sh \
29+
sub-section.sh
2930

3031
if ENABLE_KEYUTILS
3132
TESTS += security.sh

test/sub-section.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash -x
2+
3+
# SPDX-License-Identifier: GPL-2.0
4+
# Copyright(c) 2015-2019 Intel Corporation. All rights reserved.
5+
6+
set -e
7+
8+
SKIP=77
9+
FAIL=1
10+
SUCCESS=0
11+
12+
. ./common
13+
14+
check_min_kver "5.2" || do_skip "may lack align sub-section hotplug support"
15+
16+
MNT=test_dax_mnt
17+
mkdir -p $MNT
18+
19+
TEST_SIZE=$((16<<20))
20+
MIN_AVAIL=$((TEST_SIZE*4))
21+
MAX_NS=10
22+
NAME="subsection-test"
23+
24+
ndctl list -N | jq -r ".[] | select(.name==\"subsection-test\") | .dev"
25+
26+
rc=$FAIL
27+
cleanup() {
28+
if [ $rc -ne $SUCCESS ]; then
29+
echo "test/sub-section.sh: failed at line $1"
30+
fi
31+
if mountpoint -q $MNT; then
32+
umount $MNT
33+
fi
34+
rmdir $MNT
35+
# opportunistic cleanup, not fatal if these fail
36+
namespaces=$($NDCTL list -N | jq -r ".[] | select(.name==\"$NAME\") | .dev")
37+
for i in $namespaces
38+
do
39+
if ! $NDCTL destroy-namespace -f $i; then
40+
echo "test/sub-section.sh: cleanup() failed to destroy $i"
41+
fi
42+
done
43+
exit $rc
44+
}
45+
46+
trap 'err $LINENO cleanup' ERR
47+
48+
json=$($NDCTL list -R -b ACPI.NFIT)
49+
region=$(echo $json | jq -r "[.[] | select(.available_size >= $MIN_AVAIL)][0].dev")
50+
avail=$(echo $json | jq -r "[.[] | select(.available_size >= $MIN_AVAIL)][0].available_size")
51+
if [ -z $region ]; then
52+
exit $SKIP
53+
fi
54+
55+
iter=$((avail/TEST_SIZE))
56+
if [ $iter -gt $MAX_NS ]; then
57+
iter=$MAX_NS;
58+
fi
59+
60+
for i in $(seq 1 $iter)
61+
do
62+
json=$($NDCTL create-namespace -s $TEST_SIZE --no-autorecover -r $region -n "$NAME")
63+
dev=$(echo $json | jq -r ".blockdev")
64+
mkfs.ext4 -b 4096 /dev/$dev
65+
mount -o dax /dev/$dev $MNT
66+
umount $MNT
67+
done
68+
69+
namespaces=$($NDCTL list -N | jq -r ".[] | select(.name==\"$NAME\") | .dev")
70+
for i in $namespaces
71+
do
72+
$NDCTL disable-namespace $i
73+
$NDCTL enable-namespace $i
74+
$NDCTL destroy-namespace $i -f
75+
done
76+
77+
rc=$SUCCESS
78+
cleanup $LINENO

0 commit comments

Comments
 (0)