xfstests: support post-udev device mapper nodes
PATCH 1/1 xfstests: support post-udev device mapper nodes
Because of udevs complaining device mapper now creates /dev/dm-N as the real device nodes, and just symlinks the /dev/mapper/ names to it. This would be easy if everything used the /dev/mapper clear names, but most system utilities translate them back to the /dev/mapper/ names and thus confuse various test cases. Add support to _is_block_dev to read symlinks, and add documentation on how to run xfstests on device mapper volumes.
common.rc +10 -1
@@ -587,7 +587,14 @@ _is_block_dev() exit 1 fi - [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }' + _dev=$1 + if [ -L ${_dev} ]; then + _dev=`readlink -f ${_dev}` + fi + + if [ -b ${_dev} ]; then + src/lstat64 ${_dev} | $AWK_PROG '/Device type:/ { print $9 }' + fi } # Do a command, log it to $seq.full, optionally test return status
@@ -700,10 +707,12 @@ _require_scratch() *) if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ] then + echo "no a block device"; _notrun "this test requires a valid \$SCRATCH_DEV" fi if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ] then + echo "foo" _notrun "this test requires a valid \$SCRATCH_DEV" fi if [ ! -d "$SCRATCH_MNT" ]
README.device-mapper new file +8 -0
@@ -0,0 +1,8 @@ + +To use xfstests on device mapper always use the /dev/mapper/<name> symlinks, +not the /dev/dm-* devices, or the symlinks created by LVM. + +For example: + +TEST_DEV=/dev/mapper/test +SCRATCH_DEV=/dev/mapper/scratch
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines · Christoph Hellwig
Because of udevs complaining device mapper now creates
/dev/dm-Nas the real device nodes, and just symlinks the/dev/mapper/names to it. This would be easy if everything used the/dev/mapperclear names, but most system utilities translate them back to the/dev/mapper/names and thus confuse various test cases. Add support to_is_block_devto read symlinks, and add documentation on how to run xfstests on device mapper volumes.
I'm not 100% sure I'm parsing the above right. What I read is that, although we want to use the "real" device (not the link), the utilities tend to report the /dev/mapper names. Therefore we want to use /dev/mapper names and internally translate them to their real devices.
Based on that understanding I think what you're trying to do is fine, but there a few problems with what you sent. Note that I'm not even looking at the specifics of /dev/mapper links at the moment.
Quoted 7 lines
Signed-off-by Christoph Hellwig <[email protected]>Index: xfstests-dev/common.rc
===================================================================
common.rc _is_block_dev() · line 592
Quoted 7 lines
common.rc +3
-1@@ -587,7 +587,14 @@ _is_block_dev() exit 1 fi - [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }' + _dev=$1 + if [ -L ${_dev} ]; then + _dev=`readlink -f ${_dev}`
Although it typically shouldn't, if the "readlink -f" fails, it will make _dev have an empty value...
common.rc _is_block_dev() · line 595
Quoted 3 lines
common.rc +3
-0+ fi + + if [ -b ${_dev} ]; then
...which will lead to some sort of shell "syntax error" message here, which is rather unhelpful.
At a minimum, I think putting quotes around it here would avoid that (but you should test), i.e.,
if [ -b "${_dev}" ]; thencommon.rc _require_scratch() · line 710
Quoted 10 lines
common.rc +3
-0+ src/lstat64 ${_dev} | $AWK_PROG '/Device type:/ { print $9 }' + fi } # Do a command, log it to $seq.full, optionally test return status@@ -700,10 +707,12 @@ _require_scratch() *) if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ] then + echo "no a block device";
This and the next one appear to be junk that should be removed.
Quoted 22 lines
common.rc +1
-0_notrun "this test requires a valid \$SCRATCH_DEV" fi if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ] then + echo "foo" _notrun "this test requires a valid \$SCRATCH_DEV" fi if [ ! -d "$SCRATCH_MNT" ]Index: xfstests-dev/README.device-mapper
===================================================================README.device-mapper new file +8
-0@@ -0,0 +1,8 @@ + +To use xfstests on device mapper always use the /dev/mapper/<name> symlinks, +not the /dev/dm-* devices, or the symlinks created by LVM. + +For example: + +TEST_DEV=/dev/mapper/test +SCRATCH_DEV=/dev/mapper/scratch
Quoted 4 lines
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines · Alex Elder
I'm not 100% sure I'm parsing the above right. What I read is that, although we want to use the "real" device (not the link), the utilities tend to report the
/dev/mappernames. Therefore we want to use/dev/mappernames and internally translate them to their real devices.
We as in xfstests want to use whatever everyone else uses to make our life easier for parsing mount table output, df output, etc, and that's normally the /dev/mapper/ name. The only thing that can't cope with the symlink there is the _is_block_dev helper.
Quoted 11 lines
common.rc _is_block_dev() · line 592
Quoted 3 lines
common.rc +3
-0+ _dev=$1 + if [ -L ${_dev} ]; then + _dev=`readlink -f ${_dev}`Although it typically shouldn't, if the "readlink -f" fails, it will make
_devhave an empty value...common.rc _is_block_dev() · line 595
Quoted 3 lines
common.rc +3
-0+ fi + + if [ -b ${_dev} ]; then
Quoted 6 lines
...which will lead to some sort of shell "syntax error" message here, which is rather unhelpful.
At a minimum, I think putting quotes around it here would avoid that (but you should test), i.e.,
if [ -b "${_dev}" ]; then
Ok.
Quoted 2 lines
This and the next one appear to be junk that should be removed.
Indeed.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs