FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 06-03-2008, 09:57 PM
Ron Peterson
 
Default kpartx and udev problem

Hi,

I am having trouble getting kpartx to run reliably from udev. My config
files look like:
__________________________________________________ ______________________
/etc/udev/rules.d/z60_multipath.rules:

RUN+="socket:/org/kernel/dm/multipath_event"

__________________________________________________ ______________________
/etc/udev/rules.d/z60_kpartx.rules:

KERNEL!="dm-*", GOTO="kpartx_end"
ACTION=="remove", GOTO="kpartx_end"
ACTION=="modify", GOTO="kpartx_end"

ACTION=="add",
SUBSYSTEM=="block",
KERNEL=="dm-*",
PROGRAM="/sbin/devmap_name %M %m",
RUN+="/sbin/kpartx -a /dev/mapper/%c"

LABEL="kpartx_end"

##

When I run 'multipath', my /dev/mapper directory looks something like:

brw-rw---- 1 root disk 253, 22 2008-06-03 12:21 db1
brw-rw---- 1 root disk 253, 26 2008-06-03 12:21 db1p1
brw-rw---- 1 root disk 253, 1 2008-06-03 12:21 db2
brw-rw---- 1 root disk 253, 3 2008-06-03 12:21 db3
brw-rw---- 1 root disk 253, 4 2008-06-03 12:21 db4
brw-rw---- 1 root disk 253, 13 2008-06-03 12:21 f3a00
brw-rw---- 1 root disk 253, 14 2008-06-03 12:21 f3a01
etc...

All of these devices have one or more partitions; i.e. there should be a
db2p1, and a db3p1, and so on.

As you can see, /some/ of my partitions are showing up, but others do not.

If I run kpartx manually, it works; e.g.

1110# kpartx -a /dev/mapper/db2

1111# ll /dev/mapper/db2*
brw-rw---- 1 root disk 253, 1 2008-06-03 12:21 /dev/mapper/db2
brw-rw---- 1 root disk 253, 33 2008-06-03 12:29 /dev/mapper/db2p1

I'm running multipath-tools version 0.4.8 on debian etch, running my own
kernel, which at the moment is 2.6.25.4, but I've experienced the same
trouble on other kernel versions.

Interestingly, on kernel 2.6.23.16 as it happens, I was able to make
this work by wrapping kpartx in a little script called my_kpartx.sh like
this:

#!/bin/sh
(
/bin/sleep 1
/sbin/kpartx $1 $2
) &

Then, in my z60_kpartx.rules file, I called /sbin/my_kpartx rather than
/sbin/kpartx. This doesn't work in 2.6.25.4 though.

So that's my sad tale of woe. Any suggestions that might cheer me up?

--
Ron Peterson
Network & Systems Manager
Mount Holyoke College
http://www.mtholyoke.edu/~rpeterso
-
I wish my computer would do what I want it to do - not what I tell it to do.

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 
Old 06-04-2008, 06:45 AM
Hannes Reinecke
 
Default kpartx and udev problem

Hi Ron,

On Tue, Jun 03, 2008 at 05:57:43PM -0400, Ron Peterson wrote:
> Hi,
>
> I am having trouble getting kpartx to run reliably from udev. My config
> files look like:
> __________________________________________________ ______________________
> /etc/udev/rules.d/z60_multipath.rules:
>
> RUN+="socket:/org/kernel/dm/multipath_event"
>
> __________________________________________________ ______________________
> /etc/udev/rules.d/z60_kpartx.rules:
>
> KERNEL!="dm-*", GOTO="kpartx_end"
> ACTION=="remove", GOTO="kpartx_end"
> ACTION=="modify", GOTO="kpartx_end"
>
> ACTION=="add",
> SUBSYSTEM=="block",
> KERNEL=="dm-*",
> PROGRAM="/sbin/devmap_name %M %m",
> RUN+="/sbin/kpartx -a /dev/mapper/%c"
>
> LABEL="kpartx_end"
>
> ##
>
Ah, yes. That one :-)

> When I run 'multipath', my /dev/mapper directory looks something like:
>
> brw-rw---- 1 root disk 253, 22 2008-06-03 12:21 db1
> brw-rw---- 1 root disk 253, 26 2008-06-03 12:21 db1p1
> brw-rw---- 1 root disk 253, 1 2008-06-03 12:21 db2
> brw-rw---- 1 root disk 253, 3 2008-06-03 12:21 db3
> brw-rw---- 1 root disk 253, 4 2008-06-03 12:21 db4
> brw-rw---- 1 root disk 253, 13 2008-06-03 12:21 f3a00
> brw-rw---- 1 root disk 253, 14 2008-06-03 12:21 f3a01
> etc...
>
> All of these devices have one or more partitions; i.e. there should be a
> db2p1, and a db3p1, and so on.
>
> As you can see, /some/ of my partitions are showing up, but others do not.
>
> If I run kpartx manually, it works; e.g.
>
> 1110# kpartx -a /dev/mapper/db2
>
> 1111# ll /dev/mapper/db2*
> brw-rw---- 1 root disk 253, 1 2008-06-03 12:21 /dev/mapper/db2
> brw-rw---- 1 root disk 253, 33 2008-06-03 12:29 /dev/mapper/db2p1
>
> I'm running multipath-tools version 0.4.8 on debian etch, running my own
> kernel, which at the moment is 2.6.25.4, but I've experienced the same
> trouble on other kernel versions.
>
> Interestingly, on kernel 2.6.23.16 as it happens, I was able to make
> this work by wrapping kpartx in a little script called my_kpartx.sh like
> this:
>
> #!/bin/sh
> (
> /bin/sleep 1
> /sbin/kpartx $1 $2
> ) &
>
> Then, in my z60_kpartx.rules file, I called /sbin/my_kpartx rather than
> /sbin/kpartx. This doesn't work in 2.6.25.4 though.
>
> So that's my sad tale of woe. Any suggestions that might cheer me up?
>
Quite so.

Problem being the 'interesting' device-mapper design.
Whenever a 'table create' operation is triggered from user-space, it's
actually being broken down by the device-mapper library into 4 distinct
operations:
1. create device dm-X
2. suspend device
3. load table definition
4. resume device

and you'll be getting an 'add' event for the first operation, and a
'change' event for the second and the forth operation.
But clearly the 'add' event is pretty much pointless, as there is
not table loaded at that time, so you wouldn't know what to do with
it. And the device is locked between the second and the fourth
operation, so kpartx would refuse to touch it.

So, in essence: 'add' is evil for device-mapper devices.
Use the 'change' event and check if the dm-device is not suspended
when you get the event.

Or look at the current 'kpartx_id' script. That handles it properly.
(Of course it does. I wrote it :-)

Cheers,

Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N�g
GF: Markus Rex, HRB 16746 (AG N�g)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 
Old 06-04-2008, 04:49 PM
Ron Peterson
 
Default kpartx and udev problem

2008-06-04_02:45:29-0400 Hannes Reinecke <hare@suse.de>:

> Problem being the 'interesting' device-mapper design.
> Whenever a 'table create' operation is triggered from user-space, it's
> actually being broken down by the device-mapper library into 4 distinct
> operations:
> 1. create device dm-X
> 2. suspend device
> 3. load table definition
> 4. resume device
>
> and you'll be getting an 'add' event for the first operation, and a
> 'change' event for the second and the forth operation.
> But clearly the 'add' event is pretty much pointless, as there is
> not table loaded at that time, so you wouldn't know what to do with
> it. And the device is locked between the second and the fourth
> operation, so kpartx would refuse to touch it.
>
> So, in essence: 'add' is evil for device-mapper devices.
> Use the 'change' event and check if the dm-device is not suspended
> when you get the event.

Aha. It took a little finagaling, but I finally got it.

I had to install an updated version of dmsetup, because the version on
etch doesn't support the options in the dmsetup_env script I pilfered.
I put my dmsetup in its own location, and compiled w/ LD_RUN_PATH set
to the location of its own local libdevmapper.so library, because I
didn't want to replace my system's libdevmapper.so, because I'm not
entirely sure of the consequences.

Everything appears to be working great. Thanks!

--
Ron Peterson
Network & Systems Manager
Mount Holyoke College
http://www.mtholyoke.edu/~rpeterso
-
I wish my computer would do what I want it to do - not what I tell it to do.

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 

Thread Tools




All times are GMT. The time now is 10:12 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org