All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Mahoney <jeffm@suse.com>
To: Andrei Borzenkov <arvidjaar@gmail.com>,
	linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs-progs: udev: add rules for dm devices
Date: Sun, 8 May 2016 21:33:25 -0400	[thread overview]
Message-ID: <572FE8E5.9060106@suse.com> (raw)
In-Reply-To: <572EC7D7.8040608@gmail.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 4056 bytes --]

On 5/8/16 1:00 AM, Andrei Borzenkov wrote:
> 06.05.2016 22:27, Jeff Mahoney пишет:
>> Systemd's btrfs rule runs btrfs dev ready on each device
>> as it's discovered.  The btrfs command is executed as a builtin
>> command via an IMPORT{builtin} rule, which means it gets
>> executed at rule evaluation time, not rule execution time.  That
>> means that the device mapper links haven't been setup yet and the only
>> nodes that can be depended upon are /dev/dm-#.  That we see
>> /dev/mapper/name names in /proc/mounts is only because we replace the
>> device name we have cached with the one passed in via mount.  If
>> we have a multi-device file system and the primary device is removed,
>> the remaining devices will show /dev/dm-#.  In addition, if the
> 
> And I still do not understand why it is bad while /dev/sd#n is good.

The dm-# names are for in-kernel use because the major:minor mappings
don't change but the tables host upon them can be changed to a
completely different mapping without tearing down the device. This is
different behavior than sd#n, which will maintain the same mapping for
lifetime of the device.

Both device mapper and util-linux treat these names as preferred names.
 They're used by mount.  The links are created by device mapper.
Always.  These aren't "arbitrary" names as you insist on calling them.
The are the de facto official names for device mapper devices.

If you use any file system to mount using e.g. LVM's /dev/vg/lv, it will
appear in 'mount' or /proc/mounts as /dev/mapper/vg-lv.  If you use any
file system mount using multipath names, they will similarly appear in
'mount' or /proc/mounts as /dev/mapper/wwid-part#.  It's the same for
dm-crypt, dm-raid, and literally every other device mapper mapping.
There may be other convenience links but these are the names that the
device mapper userspace, which configures everything surrounding device
mapper, uses and expects to exist.

This is different for btrfs.  Every other file system just uses the name
as passed in via the mount command.  Btrfs does too for the first device
and for any devices added from the command line as opposed to being
discovered as long as there are no change events on the block device.
Once that change event comes in or a device is removed to reveal one of
the discovered devices, it reverts to the dm-# names as provided by the
initial udev rule.

That is a *clear* user-visible inconsistency that is easily
reproducible.  That's why it's an issue that needs to be resolved.

That you think that the dm-# names should be used everywhere is an
opinion shared far too late.  The /dev/mapper names are used everywhere
and we need to resolve this inconsistency.  The solution is *not* to fly
in the face of years of user experience and change everything /else/ to
use dm-#.

>> +# Once the device mapper symlink is created, tell btrfs about it
>> +# so we get the friendly name in /proc/mounts (and tools that read it)
>> +ENV{DM_NAME}=="?*", TEST=="/dev/mapper/$env{DM_NAME}", RUN{builtin}+="btrfs ready /dev/mapper/$env{DM_NAME}"
>> +
> 
> That won't work for the very first event (presumably "add"). /dev/mapper
> link is created only after all rules have been processed, so it will
> always evaluate to false.

Yep, I missed that in my test after adding it.  I'd focused on the
partprobe portion of it after adding that rule.  Removing the TEST==
section is safe and results in the correct behavior.  If the link
doesn't exist at that point, device mapper userspace is broken.

An easy test is attached.  If the before and after are different, that's
the problem.  My results, in both modes, without the rule change look
like this:

Before
/dev/mapper/testvg1-lvtest
/dev/mapper/testvg2-lvtest
After
/dev/dm-1
/dev/mapper/testvg1-lvtest

... and after the rule change:

Before
/dev/mapper/testvg1-lvtest
/dev/mapper/testvg2-lvtest
After
/dev/mapper/testvg1-lvtest
/dev/mapper/testvg2-lvtest

-Jeff

-- 
Jeff Mahoney
SUSE Labs

[-- Attachment #1.1.2: test.sh --]
[-- Type: application/x-sh, Size: 1467 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

      reply	other threads:[~2016-05-09  1:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-06 19:27 [PATCH] btrfs-progs: udev: add rules for dm devices Jeff Mahoney
2016-05-06 19:30 ` Jeff Mahoney
2016-05-08  5:00 ` Andrei Borzenkov
2016-05-09  1:33   ` Jeff Mahoney [this message]

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=572FE8E5.9060106@suse.com \
    --to=jeffm@suse.com \
    --cc=arvidjaar@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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.