* [PATCH] xfstests: support post-udev device mapper nodes
@ 2011-05-02 16:02 Christoph Hellwig
2011-05-02 19:32 ` Alex Elder
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2011-05-02 16:02 UTC (permalink / raw)
To: xfs
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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: xfstests-dev/common.rc
===================================================================
--- xfstests-dev.orig/common.rc 2011-05-02 12:45:25.000000000 +0000
+++ xfstests-dev/common.rc 2011-05-02 12:45:28.000000000 +0000
@@ -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" ]
Index: xfstests-dev/README.device-mapper
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ xfstests-dev/README.device-mapper 2011-05-02 15:51:24.000000000 +0000
@@ -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
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] xfstests: support post-udev device mapper nodes
2011-05-02 16:02 [PATCH] xfstests: support post-udev device mapper nodes Christoph Hellwig
@ 2011-05-02 19:32 ` Alex Elder
2011-05-02 19:35 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Alex Elder @ 2011-05-02 19:32 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On Mon, 2011-05-02 at 12:02 -0400, Christoph Hellwig wrote:
> 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.
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.
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> Index: xfstests-dev/common.rc
> ===================================================================
> --- xfstests-dev.orig/common.rc 2011-05-02 12:45:25.000000000 +0000
> +++ xfstests-dev/common.rc 2011-05-02 12:45:28.000000000 +0000
> @@ -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...
> + 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}" ]; 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";
This and the next one appear to be junk that should
be removed.
> _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
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ xfstests-dev/README.device-mapper 2011-05-02 15:51:24.000000000 +0000
> @@ -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
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] xfstests: support post-udev device mapper nodes
2011-05-02 19:32 ` Alex Elder
@ 2011-05-02 19:35 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2011-05-02 19:35 UTC (permalink / raw)
To: Alex Elder; +Cc: Christoph Hellwig, xfs
On Mon, May 02, 2011 at 02:32:59PM -0500, Alex Elder wrote:
> 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.
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.
> > + _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...
>
> > + 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}" ]; then
Ok.
> This and the next one appear to be junk that should
> be removed.
Indeed.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-02 19:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 16:02 [PATCH] xfstests: support post-udev device mapper nodes Christoph Hellwig
2011-05-02 19:32 ` Alex Elder
2011-05-02 19:35 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox