mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-28 21:48:07 +03:00
tests: use new help in aux
Simplify tests and use aux mdadm helpers.
This commit is contained in:
parent
1e3c135d71
commit
a7d28639eb
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
|
# Copyright (C) 2014-2015 Red Hat, Inc. All rights reserved.
|
||||||
#
|
#
|
||||||
# This copyrighted material is made available to anyone wishing to use,
|
# This copyrighted material is made available to anyone wishing to use,
|
||||||
# modify, copy, or redistribute it subject to the terms and conditions
|
# modify, copy, or redistribute it subject to the terms and conditions
|
||||||
@ -12,72 +12,25 @@
|
|||||||
. lib/inittest
|
. lib/inittest
|
||||||
|
|
||||||
test -e LOCAL_LVMETAD || skip
|
test -e LOCAL_LVMETAD || skip
|
||||||
which mdadm || skip
|
|
||||||
|
|
||||||
test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
|
test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
|
||||||
modprobe raid0 || skip
|
modprobe raid0 || skip
|
||||||
|
|
||||||
|
aux prepare_devs 2
|
||||||
|
|
||||||
|
# create 2 disk MD raid0 array (stripe_width=128K)
|
||||||
|
aux prepare_md_dev 0 64 2 "$dev1" "$dev2"
|
||||||
|
|
||||||
aux lvmconf 'devices/md_component_detection = 1'
|
aux lvmconf 'devices/md_component_detection = 1'
|
||||||
aux extend_filter_LVMTEST
|
aux extend_filter_LVMTEST
|
||||||
aux extend_filter "a|/dev/md.*|"
|
aux extend_filter "a|/dev/md.*|"
|
||||||
|
|
||||||
aux prepare_devs 2
|
pvdev=$(< MD_DEV_PV)
|
||||||
|
|
||||||
# TODO factor out the following MD-creation code into lib/
|
|
||||||
|
|
||||||
# Have MD use a non-standard name to avoid colliding with an existing MD device
|
|
||||||
# - mdadm >= 3.0 requires that non-standard device names be in /dev/md/
|
|
||||||
# - newer mdadm _completely_ defers to udev to create the associated device node
|
|
||||||
mdadm_maj=$(mdadm --version 2>&1 | perl -pi -e 's|.* v(\d+).*|\1|')
|
|
||||||
[ $mdadm_maj -ge 3 ] && \
|
|
||||||
mddev=/dev/md/md_lvm_test0 || \
|
|
||||||
mddev=/dev/md_lvm_test0
|
|
||||||
|
|
||||||
cleanup_md() {
|
|
||||||
# sleeps offer hack to defeat: 'md: md127 still in use'
|
|
||||||
# see: https://bugzilla.redhat.com/show_bug.cgi?id=509908#c25
|
|
||||||
aux udev_wait
|
|
||||||
mdadm --stop "$mddev" || true
|
|
||||||
# also remove singnatures
|
|
||||||
mdadm --zero-superblock "$dev1" "$dev2" || true
|
|
||||||
aux udev_wait
|
|
||||||
if [ -b "$mddev" ]; then
|
|
||||||
# mdadm doesn't always cleanup the device node
|
|
||||||
sleep 2
|
|
||||||
rm -f "$mddev"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup_md_and_teardown() {
|
|
||||||
cleanup_md
|
|
||||||
aux teardown
|
|
||||||
}
|
|
||||||
|
|
||||||
# create 2 disk MD raid0 array (stripe_width=128K)
|
|
||||||
test -b "$mddev" && skip
|
|
||||||
trap 'cleanup_md_and_teardown' EXIT # cleanup this MD device at the end of the test
|
|
||||||
mdadm --create --metadata=1.0 "$mddev" --auto=md --level 0 --raid-devices=2 --chunk 64 "$dev1" "$dev2"
|
|
||||||
test -b "$mddev" || skip
|
|
||||||
if test "$DM_DEV_DIR" != "/dev" ; then
|
|
||||||
cp -LR "$mddev" "$DM_DEV_DIR" # so that LVM/DM can see the device
|
|
||||||
pvdev="$DM_DEV_DIR/md_lvm_test0"
|
|
||||||
else
|
|
||||||
pvdev=$(readlink -f "$mddev")
|
|
||||||
fi
|
|
||||||
# TODO end MD-creation code
|
|
||||||
|
|
||||||
# maj=$(($(stat -L --printf=0x%t "$dev2")))
|
|
||||||
# min=$(($(stat -L --printf=0x%T "$dev2")))
|
|
||||||
|
|
||||||
pvcreate "$pvdev"
|
pvcreate "$pvdev"
|
||||||
|
|
||||||
pvscan --cache "$pvdev"
|
|
||||||
|
|
||||||
# ensure that lvmetad can only see the toplevel MD device
|
# ensure that lvmetad can only see the toplevel MD device
|
||||||
pvscan --cache "$dev1" 2>&1 | grep "not found"
|
|
||||||
pvscan --cache "$dev2" 2>&1 | grep "not found"
|
|
||||||
|
|
||||||
pvs | tee out
|
pvs | tee out
|
||||||
grep "$pvdev" out
|
grep "$pvdev" out
|
||||||
pvs | not grep "$dev1"
|
not grep "$dev1" out
|
||||||
pvs | not grep "$dev2"
|
not grep "$dev2" out
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
|
# Copyright (C) 2009-2015 Red Hat, Inc. All rights reserved.
|
||||||
#
|
#
|
||||||
# This copyrighted material is made available to anyone wishing to use,
|
# This copyrighted material is made available to anyone wishing to use,
|
||||||
# modify, copy, or redistribute it subject to the terms and conditions
|
# modify, copy, or redistribute it subject to the terms and conditions
|
||||||
@ -12,11 +12,7 @@
|
|||||||
. lib/inittest
|
. lib/inittest
|
||||||
|
|
||||||
# skip this test if mdadm or sfdisk (or others) aren't available
|
# skip this test if mdadm or sfdisk (or others) aren't available
|
||||||
which mdadm || skip
|
|
||||||
which sfdisk || skip
|
which sfdisk || skip
|
||||||
which perl || skip
|
|
||||||
which awk || skip
|
|
||||||
which cut || skip
|
|
||||||
|
|
||||||
test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
|
test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
|
||||||
modprobe raid0 || skip
|
modprobe raid0 || skip
|
||||||
@ -27,66 +23,33 @@ aux extend_filter "a|/dev/md.*|"
|
|||||||
|
|
||||||
aux prepare_devs 2
|
aux prepare_devs 2
|
||||||
|
|
||||||
# Have MD use a non-standard name to avoid colliding with an existing MD device
|
|
||||||
# - mdadm >= 3.0 requires that non-standard device names be in /dev/md/
|
|
||||||
# - newer mdadm _completely_ defers to udev to create the associated device node
|
|
||||||
mdadm_maj=$(mdadm --version 2>&1 | perl -pi -e 's|.* v(\d+).*|\1|')
|
|
||||||
[ $mdadm_maj -ge 3 ] && \
|
|
||||||
mddev=/dev/md/md_lvm_test0 || \
|
|
||||||
mddev=/dev/md_lvm_test0
|
|
||||||
|
|
||||||
cleanup_md() {
|
|
||||||
# sleeps offer hack to defeat: 'md: md127 still in use'
|
|
||||||
# see: https://bugzilla.redhat.com/show_bug.cgi?id=509908#c25
|
|
||||||
aux udev_wait
|
|
||||||
mdadm --stop "$mddev" || true
|
|
||||||
mdadm --zero-superblock "$dev1" "$dev2" || true
|
|
||||||
aux udev_wait
|
|
||||||
if [ -b "$mddev" ]; then
|
|
||||||
# mdadm doesn't always cleanup the device node
|
|
||||||
sleep 2
|
|
||||||
rm -f "$mddev"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup_md_and_teardown() {
|
|
||||||
cleanup_md
|
|
||||||
aux teardown
|
|
||||||
}
|
|
||||||
|
|
||||||
# create 2 disk MD raid0 array (stripe_width=128K)
|
# create 2 disk MD raid0 array (stripe_width=128K)
|
||||||
test -b "$mddev" && skip
|
aux prepare_md_dev 0 64 2 "$dev1" "$dev2"
|
||||||
trap 'cleanup_md_and_teardown' EXIT # cleanup this MD device at the end of the test
|
|
||||||
mdadm --create --metadata=1.0 "$mddev" --auto=md --level 0 --raid-devices=2 --chunk 64 "$dev1" "$dev2"
|
mddev=$(< MD_DEV)
|
||||||
test -b "$mddev" || skip
|
pvdev=$(< MD_DEV_PV)
|
||||||
test "$DM_DEV_DIR" != "/dev" && cp -LR "$mddev" "$DM_DEV_DIR" # so that LVM/DM can see the device
|
|
||||||
lvmdev="$DM_DEV_DIR/md_lvm_test0"
|
|
||||||
|
|
||||||
# Test alignment of PV on MD without any MD-aware or topology-aware detection
|
# Test alignment of PV on MD without any MD-aware or topology-aware detection
|
||||||
# - should treat $mddev just like any other block device
|
# - should treat $mddev just like any other block device
|
||||||
pv_align="1.00m"
|
|
||||||
pvcreate --metadatasize 128k \
|
pvcreate --metadatasize 128k \
|
||||||
--config 'devices {md_chunk_alignment=0 data_alignment_detection=0 data_alignment_offset_detection=0}' \
|
--config 'devices {md_chunk_alignment=0 data_alignment_detection=0 data_alignment_offset_detection=0}' \
|
||||||
"$lvmdev"
|
"$pvdev"
|
||||||
|
|
||||||
check pv_field "$lvmdev" pe_start $pv_align
|
check pv_field "$pvdev" pe_start "1.00m"
|
||||||
|
|
||||||
# Test md_chunk_alignment independent of topology-aware detection
|
# Test md_chunk_alignment independent of topology-aware detection
|
||||||
pv_align="1.00m"
|
|
||||||
pvcreate --metadatasize 128k \
|
pvcreate --metadatasize 128k \
|
||||||
--config 'devices {data_alignment_detection=0 data_alignment_offset_detection=0}' \
|
--config 'devices {data_alignment_detection=0 data_alignment_offset_detection=0}' \
|
||||||
"$lvmdev"
|
"$pvdev"
|
||||||
check pv_field "$lvmdev" pe_start $pv_align
|
check pv_field "$pvdev" pe_start "1.00m"
|
||||||
|
|
||||||
|
|
||||||
# Test newer topology-aware alignment detection
|
# Test newer topology-aware alignment detection
|
||||||
# - first added to 2.6.31 but not "reliable" until 2.6.33
|
# - first added to 2.6.31 but not "reliable" until 2.6.33
|
||||||
if kernel_at_least 2 6 33 ; then
|
if kernel_at_least 2 6 33 ; then
|
||||||
pv_align="1.00m"
|
|
||||||
# optimal_io_size=131072, minimum_io_size=65536
|
# optimal_io_size=131072, minimum_io_size=65536
|
||||||
pvcreate --metadatasize 128k \
|
pvcreate --metadatasize 128k \
|
||||||
--config 'devices { md_chunk_alignment=0 }' "$lvmdev"
|
--config 'devices { md_chunk_alignment=0 }' "$pvdev"
|
||||||
check pv_field "$lvmdev" pe_start $pv_align
|
check pv_field "$pvdev" pe_start "1.00m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# partition MD array directly, depends on blkext in Linux >= 2.6.28
|
# partition MD array directly, depends on blkext in Linux >= 2.6.28
|
||||||
@ -98,67 +61,53 @@ EOF
|
|||||||
pvscan
|
pvscan
|
||||||
# make sure partition on MD is _not_ removed
|
# make sure partition on MD is _not_ removed
|
||||||
# - tests partition -> parent lookup via sysfs paths
|
# - tests partition -> parent lookup via sysfs paths
|
||||||
not pvcreate --metadatasize 128k "$lvmdev"
|
not pvcreate --metadatasize 128k "$pvdev"
|
||||||
|
|
||||||
# verify alignment_offset is accounted for in pe_start
|
# verify alignment_offset is accounted for in pe_start
|
||||||
# - topology infrastructure is available in Linux >= 2.6.31
|
# - topology infrastructure is available in Linux >= 2.6.31
|
||||||
# - also tests partition -> parent lookup via sysfs paths
|
# - also tests partition -> parent lookup via sysfs paths
|
||||||
|
|
||||||
# Oh joy: need to lookup /sys/block/md127 rather than /sys/block/md_lvm_test0
|
|
||||||
mddev_maj_min=$(ls -lL "$mddev" | awk '{ print $5 $6 }' | perl -pi -e 's|,|:|')
|
|
||||||
mddev_p_sysfs_name=$(echo /sys/dev/block/${mddev_maj_min}/*p1)
|
|
||||||
base_mddev_p=`basename $mddev_p_sysfs_name`
|
|
||||||
mddev_p=/dev/${base_mddev_p}
|
|
||||||
|
|
||||||
# in case the system is running without devtmpfs /dev
|
|
||||||
# wait here for created device node on tmpfs
|
|
||||||
aux udev_wait "$mddev_p"
|
|
||||||
test -b "$mddev_p" || skip
|
|
||||||
test "$DM_DEV_DIR" != "/dev" && cp -LR "$mddev_p" "$DM_DEV_DIR"
|
|
||||||
lvmdev_p="$DM_DEV_DIR/$base_mddev_p"
|
|
||||||
|
|
||||||
# Checking for 'alignment_offset' in sysfs implies Linux >= 2.6.31
|
# Checking for 'alignment_offset' in sysfs implies Linux >= 2.6.31
|
||||||
# but reliable alignment_offset support requires kernel.org Linux >= 2.6.33
|
# but reliable alignment_offset support requires kernel.org Linux >= 2.6.33
|
||||||
sysfs_alignment_offset=/sys/dev/block/${mddev_maj_min}/${base_mddev_p}/alignment_offset
|
if kernel_at_least 2 6 33 ; then
|
||||||
[ -f $sysfs_alignment_offset ] && kernel_at_least 2 6 33 && \
|
# in case the system is running without devtmpfs /dev
|
||||||
alignment_offset=`cat $sysfs_alignment_offset` || \
|
# wait here for created device node on tmpfs
|
||||||
alignment_offset=0
|
test "$DM_DEV_DIR" != "/dev" && cp -LR "${mddev}p1" "$DM_DEV_DIR"
|
||||||
|
|
||||||
if [ $alignment_offset -gt 0 ]; then
|
pvcreate --metadatasize 128k "${pvdev}p1"
|
||||||
# default alignment is 1M, add alignment_offset
|
check sysfs "${pvdev}p1" alignment_offset 0
|
||||||
pv_align=$((1048576+$alignment_offset))B
|
|
||||||
pvcreate --metadatasize 128k "$lvmdev_p"
|
maj=$(($(stat -L --printf=0x%t "${mddev}p1")))
|
||||||
check pv_field "$lvmdev_p" pe_start $pv_align --units b
|
min=$(($(stat -L --printf=0x%T "${mddev}p1")))
|
||||||
pvremove "$lvmdev_p"
|
|
||||||
|
sysfs_alignment_offset="/sys/dev/block/$maj:$min/alignment_offset"
|
||||||
|
[ -f "$sysfs_alignment_offset" ] && \
|
||||||
|
alignment_offset=$(< "$sysfs_alignment_offset") || \
|
||||||
|
alignment_offset=0
|
||||||
|
|
||||||
|
# default alignment is 1M, add alignment_offset
|
||||||
|
pv_align=$((1048576+$alignment_offset))
|
||||||
|
check pv_field "${pvdev}p1" pe_start $pv_align --units b --nosuffix
|
||||||
|
|
||||||
|
pvremove "${pvdev}p1"
|
||||||
|
test "$DM_DEV_DIR" != "/dev" && rm -f "$DM_DEV_DIR/${mddev}p1"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Test newer topology-aware alignment detection w/ --dataalignment override
|
# Test newer topology-aware alignment detection w/ --dataalignment override
|
||||||
if kernel_at_least 2 6 33 ; then
|
if kernel_at_least 2 6 33 ; then
|
||||||
# make sure we're clean for another test
|
# make sure we're clean for another test
|
||||||
test -b "$mddev" && cleanup_md
|
dd if=/dev/zero of="$mddev" bs=512 count=1
|
||||||
dd if=/dev/zero of="$dev1" bs=512 count=1
|
aux prepare_md_dev 0 1024 2 "$dev1" "$dev2"
|
||||||
dd if=/dev/zero of="$dev2" bs=512 count=1
|
pvdev=$(< MD_DEV_PV)
|
||||||
|
|
||||||
pvcreate -f "$dev1"
|
|
||||||
pvcreate -f "$dev2"
|
|
||||||
|
|
||||||
# create 2 disk MD raid0 array (stripe_width=2M)
|
|
||||||
test -b "$mddev" && skip
|
|
||||||
mdadm --create --metadata=1.0 "$mddev" --auto=md --level 0 --raid-devices=2 --chunk 1024 "$dev1" "$dev2"
|
|
||||||
test -b "$mddev" || skip
|
|
||||||
|
|
||||||
# optimal_io_size=2097152, minimum_io_size=1048576
|
# optimal_io_size=2097152, minimum_io_size=1048576
|
||||||
pv_align="2.00m"
|
|
||||||
pvcreate --metadatasize 128k \
|
pvcreate --metadatasize 128k \
|
||||||
--config 'devices { md_chunk_alignment=0 }' "$lvmdev"
|
--config 'devices { md_chunk_alignment=0 }' "$pvdev"
|
||||||
pvscan # Something is seriously broken.
|
check pv_field "$pvdev" pe_start "2.00m"
|
||||||
check pv_field "$lvmdev" pe_start $pv_align
|
|
||||||
|
|
||||||
# now verify pe_start alignment override using --dataalignment
|
# now verify pe_start alignment override using --dataalignment
|
||||||
pv_align="192.00k"
|
|
||||||
pvcreate --dataalignment 64k --metadatasize 128k \
|
pvcreate --dataalignment 64k --metadatasize 128k \
|
||||||
--config 'devices { md_chunk_alignment=0 }' "$lvmdev"
|
--config 'devices { md_chunk_alignment=0 }' "$pvdev"
|
||||||
check pv_field "$lvmdev" pe_start $pv_align
|
check pv_field "$pvdev" pe_start "192.00k"
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user