Bug 156679 - kernel dm: Export parent/child relationship via sysfs
kernel dm: Export parent/child relationship via sysfs
Product: Fedora
Classification: Fedora
Component: device-mapper-obsolete (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Dave Wysochanski
: FutureFeature, Reopened
Depends On:
  Show dependency treegraph
Reported: 2005-05-03 07:19 EDT by Lars Marowsky-Bree
Modified: 2007-11-30 17:11 EST (History)
7 users (show)

See Also:
Fixed In Version: fc6
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-03-04 12:07:11 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Lars Marowsky-Bree 2005-05-03 07:19:25 EDT
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

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.


- 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

- 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 11:10:20 EDT
See also bug #156324 - "dependency tree should be added to libdevmapper".
Comment 2 Dave Wysochanski 2007-02-21 17:10:25 EST
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.