1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
#!/bin/bash -x
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
. $(dirname $0)/common
MNT=test_dax_mnt
FILE=image
blockdev=""
cleanup() {
echo "test-dax: failed at line $1"
if [ -n "$blockdev" ]; then
umount /dev/$blockdev
else
rc=77
fi
rm -rf $MNT
exit $rc
}
run_test() {
rc=0
if ! trace-cmd record -e fs_dax:dax_pmd_fault_done $TEST_PATH/dax-pmd $MNT/$FILE; then
rc=$?
if [ "$rc" -ne 77 ] && [ "$rc" -ne 0 ]; then
cleanup "$1"
fi
fi
# Fragile hack to double check the kernel services this test
# with successful pmd faults. If dax-pmd.c ever changes the
# number of times the dax_pmd_fault_done trace point fires the
# hack needs to be updated from 10 expected firings and the
# result of success (NOPAGE).
count=0
rc=1
while read -r p; do
[[ $p ]] || continue
if [ "$count" -lt 10 ]; then
if [ "$p" != "0x100" ] && [ "$p" != "NOPAGE" ]; then
cleanup "$1"
fi
fi
count=$((count + 1))
done < <(trace-cmd report | awk '{ print $21 }')
if [ $count -lt 10 ]; then
cleanup "$1"
fi
}
run_ext4() {
mkfs.ext4 -b 4096 /dev/$blockdev
mount /dev/$blockdev $MNT -o dax
fallocate -l 1GiB $MNT/$FILE
run_test $LINENO
umount $MNT
# convert pmem to put the memmap on the device
json=$($NDCTL create-namespace -m fsdax -M dev -f -e $dev)
eval $(json2var <<< "$json")
[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
#note the blockdev returned from ndctl create-namespace lacks the /dev prefix
mkfs.ext4 -b 4096 /dev/$blockdev
mount /dev/$blockdev $MNT -o dax
fallocate -l 1GiB $MNT/$FILE
run_test $LINENO
umount $MNT
json=$($NDCTL create-namespace -m raw -f -e $dev)
eval $(json2var <<< "$json")
[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
true
}
run_xfs() {
mkfs.xfs -f -d su=2m,sw=1,agcount=2 -m reflink=0 /dev/$blockdev
mount /dev/$blockdev $MNT -o dax
fallocate -l 1GiB $MNT/$FILE
run_test $LINENO
umount $MNT
# convert pmem to put the memmap on the device
json=$($NDCTL create-namespace -m fsdax -M dev -f -e $dev)
eval $(json2var <<< "$json")
[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
mkfs.xfs -f -d su=2m,sw=1,agcount=2 -m reflink=0 /dev/$blockdev
mount /dev/$blockdev $MNT -o dax
fallocate -l 1GiB $MNT/$FILE
run_test $LINENO
umount $MNT
# revert namespace to raw mode
json=$($NDCTL create-namespace -m raw -f -e $dev)
eval $(json2var <<< "$json")
[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
true
}
set -e
mkdir -p $MNT
trap 'err $LINENO cleanup' ERR
dev=$($TEST_PATH/dax-dev)
json=$($NDCTL list -N -n $dev)
eval $(json2var <<< "$json")
rc=1
if [ $(basename $0) = "dax-ext4.sh" ]; then
run_ext4
elif [ $(basename $0) = "dax-xfs.sh" ]; then
run_xfs
else
run_ext4
run_xfs
fi
check_dmesg "$LINENO"
exit 0
|