Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 156679 - kernel dm: Export parent/child relationship via sysfs
Summary: kernel dm: Export parent/child relationship via sysfs
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: device-mapper-obsolete
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Dave Wysochanski
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-05-03 11:19 UTC by Lars Marowsky-Bree
Modified: 2007-11-30 22:11 UTC (History)
7 users (show)

Fixed In Version: fc6
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-03-04 17:07:11 UTC


Attachments (Terms of Use)

Description Lars Marowsky-Bree 2005-05-03 11:19:25 UTC
From my dm-devel mail:

To recap, the issue is that we want to prevent LVM2/EVMS2 etc from
scanning (and using!) the raw physical devices if those are already
claimed/used by multipath.

LVM2 has a special handling for md_component_detection already; what I
want to propose in the following is a bit more general, and I've
discussed it with Hannes before.

Problem: A general solution for finding out whether another component is
using the device we're looking at.

Proposed solution: Introduce sub-devices into the sysfs tree. (And,
automatically, backlink those to parent devices, but that's just so the
tree can be traversed in any order.)

For example, /sys/block/sda would have a sub/ directory with "dm-0" in
there, pointing at /sys/block/dm-0 (surprise). The
/sys/block/dm-0/parent/sd{a,b} entries would do a very surprising
thing.

This would also allow us to handle partitions in DM better: as all
linear mappings on top of /dev/dm-0 would show up in block/dm-0/sub/ and
vice versa.

md could work the same: block/sys/md0/parent/ would list all the devices
(or partitions) which it consists of.

This very simple(?) change would make a number of things much easier to
figure out.

Caveats:

- This obviously only works if the devices are already active, not if
  the specific user is offline; if LVM2 scans before multipath-tools has
  worked its magic, it won't work. 
  
  (But then, multipath-tools can figure out that there's already someone
  else using the raw physical device and not mess with it! Woho, world
  saved!)

- This ONLY exports very rudimentary hierarchical information; it won't
  tell you what the device is used for or how. However, that information
  alone would be very helpful already.

Greg has voiced no objections to this and it should already work with current
sysfs, we just need to export that information.

Comment 1 Karel Zak 2005-10-26 15:10:20 UTC
See also bug #156324 - "dependency tree should be added to libdevmapper".

Comment 2 Dave Wysochanski 2007-02-21 22:10:25 UTC
I believe this has been implemented upstream (2.6.20 or before - looks like it's
in FC6 as well, 2.6.19-1.2895.fc6xen) via the 'slaves' directory that contains
links back to the /dev/sd* devices. (see below)

Feel free to reopen if I'm mistaken or you need something further.

# ls /sys/block/dm-29/slaves/
sdaj  sdbg
# uname -a
Linux gfs1.hpperf.rdu.redhat.com 2.6.20 #1 SMP Thu Feb 8 12:06:05 EST 2007 i686
i686 i386 GNU/Linux
# ls -l /dev/mapper/mpath427
brw-rw----  1 root disk 253, 29 Feb 19 13:14 /dev/mapper/mpath427
# ls -l /dev/dm-29
brw-r-----  1 root root 253, 29 Feb 19 13:14 /dev/dm-29
# multipath -ll mpath427
mpath427 (3600805f30005e240db04445cdf0700bd)
[size=47 MB][features="1 queue_if_no_path"][hwhandler="1 hp_sw"]
\_ round-robin 0 [prio=1][active]
 \_ 2:0:0:30 sdaj 66:48  [active][ready]
\_ round-robin 0 [prio=1][enabled]
 \_ 3:0:0:30 sdbg 67:160 [active][ghost]



Note You need to log in before you can comment on or make changes to this bug.