All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bryn M. Reeves" <bmr@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Rudy Gevaert <Rudy.Gevaert@UGent.be>
Subject: Re: better alternative to part multpath -l output?
Date: Thu, 05 Jan 2012 13:50:12 +0000	[thread overview]
Message-ID: <4F05AA94.2030202@redhat.com> (raw)
In-Reply-To: <4F05A6B5.1020509@UGent.be>

On 01/05/2012 01:33 PM, Rudy Gevaert wrote:
> Hello,
> 
> Can anybody suggest a better alternative to parsing multpath -l
> <device> to get the underlying devices that are part of the
> multipath?
> 
> Thanks in advance,
> 
> Rudy

You could parse the output of dmsetup, either table or deps:

# dmsetup table mpath2
0 31457280 multipath 1 queue_if_no_path 1 emc 1 1 round-robin 0 2 1
8:32 1000 8:80 1000
^^^^      ^^^^
# dmsetup deps mpath2
2 dependencies	: (8, 80) (8, 32)
                   ^^^^^   ^^^^^
The lsblk command (or dmsetup ls --tree) will also display dependency
trees graphically but you probably wouldn't want to parse this (and it
operates bottom-up rather than top-down):

# lsblk /dev/sdc /dev/sdd
NAME                            MAJ:MIN RM   SIZE RO MOUNTPOINT
sdc                               8:32   0    15G  0
└─mpatha (dm-0)                 253:0    0    15G  0
  ├─mpathap1 (dm-1)             253:1    0   500M  0 /boot
  └─mpathap2 (dm-2)             253:2    0  14.5G  0
    ├─vg_pe19503-lv_root (dm-3) 253:3    0  10.6G  0 /
    └─vg_pe19503-lv_swap (dm-4) 253:4    0     4G  0 [SWAP]
sdd                               8:48   0    15G  0
└─mpatha (dm-0)                 253:0    0    15G  0
  ├─mpathap1 (dm-1)             253:1    0   500M  0 /boot
  └─mpathap2 (dm-2)             253:2    0  14.5G  0
    ├─vg_pe19503-lv_root (dm-3) 253:3    0  10.6G  0 /
    └─vg_pe19503-lv_swap (dm-4) 253:4    0     4G  0 [SWAP]

But probably the easiest and most direct way is to use the sysfs
holders/slaves directories:

# multipath -l mpath2
mpath2 (3600601608e661a01a50ff0fe2776e011) dm-1 DGC,RAID 5
[size=15G][features=1 queue_if_no_path][hwhandler=1 emc][rw]
\_ round-robin 0 [prio=0][active]
 \_ 1:0:0:0 sdc 8:32  [active][undef]
 \_ 2:0:0:0 sdf 8:80  [active][undef]

# ls /sys/block/dm-1/slaves/
sdc  sdf

The only niggle here is that you need to map the mpath device name to
it's device mapper minor number to obtain the sysfs path.

If you want to find out what's using the device rather than what it's
using change slaves to holders:

# ls /sys/block/dm-0/holders/
dm-1  dm-2

# dmsetup info /dev/dm-1
Name:              mpathap1
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        1
Event number:      0
Major, minor:      253, 1
Number of targets: 1
UUID: part1-mpath-3600601608e661a01a60ff0fe2776e011

etc.

Regards,
Bryn.

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

  reply	other threads:[~2012-01-05 13:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-05 13:33 better alternative to part multpath -l output? Rudy Gevaert
2012-01-05 13:50 ` Bryn M. Reeves [this message]
2012-01-05 19:24 ` Christophe Varoqui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F05AA94.2030202@redhat.com \
    --to=bmr@redhat.com \
    --cc=Rudy.Gevaert@UGent.be \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.