All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: Steffen Maier <maier@linux.vnet.ibm.com>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: Re: [PATCH 4/5] kpartx: default to running in sync mode
Date: Tue, 25 Apr 2017 10:52:55 -0500	[thread overview]
Message-ID: <20170425155255.GS19236@octiron.msp.redhat.com> (raw)
In-Reply-To: <d4cdb3c3-c815-998f-9794-150179c74411@linux.vnet.ibm.com>

On Tue, Apr 25, 2017 at 12:12:25PM +0200, Steffen Maier wrote:
> 
> On 04/25/2017 12:39 AM, Benjamin Marzinski wrote:
> >When users run kpartx, they would naturally assume that when it
> >completes, the devices have been created. However, kpartx runs in async
> >mode by default.  This seems like it is likely to trip up users.  So,
> >switch the default to sync mode, add a -n option to enable async mode,
> >and set async mode when kpartx is called by the udev rules.
> >
> >Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> >---
> > kpartx/kpartx.c     | 10 +++++++---
> > kpartx/kpartx.rules |  2 +-
> > 2 files changed, 8 insertions(+), 4 deletions(-)
> >
> >diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
> >index 58e60ff..d1edd5e 100644
> >--- a/kpartx/kpartx.c
> >+++ b/kpartx/kpartx.c
> 
> >-int udev_sync = 0;
> >+int udev_sync = 1;
> 
> >-	printf("\t-s sync mode. Don't return until the partitions are created\n");
> >+	printf("\t-n nosync mode. Return before the partitions are created\n");
> >+	printf("\t-s sync mode. Don't return until the partitions are created. Default.\n");
> 
> >+		case 'n':
> >+			udev_sync = 0;
> >+			break;
> 
> >diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules
> >index 48a4d6c..a958791 100644
> >--- a/kpartx/kpartx.rules
> >+++ b/kpartx/kpartx.rules
> >@@ -40,6 +40,6 @@ ENV{DM_NR_VALID_PATHS}=="0", GOTO="kpartx_end"
> > ENV{ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG1"
> > ENV{DM_SUBSYSTEM_UDEV_FLAG1}=="1", GOTO="kpartx_end"
> > ENV{DM_STATE}!="SUSPENDED", ENV{DM_UUID}=="mpath-*", \
> >-	RUN+="/sbin/kpartx -u -p -part /dev/$name"
> >+	RUN+="/sbin/kpartx -un -p -part /dev/$name"
> 
> I understand this was async before and is now still async after the default
> change in kpartx. However, I'm wondering in general how one would "wait" for
> kpartx mappings, since I suppose a "udevadm settle" would not suffice.
> Dracut probably does not care because it would loop until its required
> root-fs devices have appeared.

I'm pretty sure that it is inherently impossible in the general case.
There is no way to know when the uevent will occur, and until the uevent
occurs, there would be no way that udev settle could possibly help. You
can know that a dm device has been set up when the first change event
for that device occurs. So, if you knew a device was coming, you could
wait for the change event.  Multipathd currently listens for change
events to know when a multipath device has been fully initialized.

For partition devices explicitly, say you just manually ran multipath to
create a multipath device, and want to know that your partition devices
exist before going on. You could manually run kpartx in the now-default
sync mode, and when it returned, you would know that the devices were
there. However, your kpart call would be racing with the udev version,
so it's possible that kpartx would return with an error because it tried
to create the device and failed because the device already existed. The
good news is that it would continue to try with the rest of the devices,
so it really won't return until they all are there. If it is important
to you, we could add a flag to kpartx to not return an error if a create
fails because the device currently exists. 

-Ben

> 
> -- 
> Mit freundlichen Grüßen / Kind regards
> Steffen Maier
> 
> Linux on z Systems Development
> 
> IBM Deutschland Research & Development GmbH
> Vorsitzende des Aufsichtsrats: Martina Koederitz
> Geschaeftsfuehrung: Dirk Wittkopp
> Sitz der Gesellschaft: Boeblingen
> Registergericht: Amtsgericht Stuttgart, HRB 243294

  reply	other threads:[~2017-04-25 15:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24 22:39 [PATCH 0/5] More misc patches Benjamin Marzinski
2017-04-24 22:39 ` [PATCH 1/5] multipath: Merge the DELL MD3xxx device configs Benjamin Marzinski
2017-04-24 22:39 ` [PATCH 2/5] multipath: fix up position independent code Benjamin Marzinski
2017-05-11 13:12   ` Martin Wilck
2017-04-24 22:39 ` [PATCH 3/5] libmultipath: fix partition detection Benjamin Marzinski
2017-05-11 13:07   ` Martin Wilck
2017-04-24 22:39 ` [PATCH 4/5] kpartx: default to running in sync mode Benjamin Marzinski
2017-04-25 10:12   ` Steffen Maier
2017-04-25 15:52     ` Benjamin Marzinski [this message]
2017-04-25 17:48       ` Steffen Maier
2017-05-10 22:42   ` Xose Vazquez Perez
2017-05-11 12:42   ` Martin Wilck
2017-05-11 17:46     ` Benjamin Marzinski
2017-05-11 20:01       ` Martin Wilck
2017-04-24 22:39 ` [PATCH 5/5] libmultipath: force udev reloads Benjamin Marzinski

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=20170425155255.GS19236@octiron.msp.redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=maier@linux.vnet.ibm.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.