From: Hannes Reinecke <hare@suse.de>
To: Christian Seiler <christian@iwakd.de>, dm-devel@redhat.com
Subject: Re: [PATCH] libmultipath: don't lock block device but use lock files
Date: Sun, 24 May 2015 09:07:24 +0200 [thread overview]
Message-ID: <556178AC.2010501@suse.de> (raw)
In-Reply-To: <5560EA5C.6040001@iwakd.de>
[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]
On 05/23/2015 11:00 PM, Christian Seiler wrote:
> In recent versions udev uses flock() on the device node itself,
> breaking libmultipath's current locking logic. Since libmultipath
> doesn't actually modify anything on the device itself (and hence does
> not actually need an exclusive lock on the device node, unlike e.g.
> tools that create partitions etc.), and the reason for the lock is to
> guard against multipath interfering with multipathd, use lock files
> (named after the devices) in /run/lock/multipath instead.
>
> See the discussion under:
> https://www.redhat.com/archives/dm-devel/2014-December/msg00083.html
> Especially:
> https://www.redhat.com/archives/dm-devel/2014-December/msg00117.html
>
> Signed-off-by: Christian Seiler <christian@iwakd.de>
>
> ---
Well ... couldn't you just use a shared lock here?
I thought to have send this patch already; hmm.
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
[-- Attachment #2: multipath-shared-lock.patch --]
[-- Type: text/x-patch, Size: 1538 bytes --]
From 841977fc9c3432702c296d6239e4a54291a6007a Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 24 Jun 2014 08:49:15 +0200
Subject: [PATCH] libmultipath: use a shared lock to co-operate with udev
udev since v214 is placing a shared lock on the device node
whenever it's processing the event. This introduces a race
condition with multipathd, as multipathd is processing the
event for the block device at the same time as udev is
processing the events for the partitions.
And a lock on the partitions will also be visible on the
block device itself, hence multipathd won't be able to
lock the device.
When multipath manages to take a lock on the device,
udev will fail, and consequently ignore this entire event.
Which in turn might cause the system to malfunction as it
might have been a crucial event like 'remove' or 'link down'.
So we should better use LOCK_SH here; with that the flock
call in multipathd _and_ udev will succeed and the events
can be processed.
References: bnc#883878
Signed-off-by: Hannes Reinecke <hare@suse.de>
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 0ddd3d5..dc2ebf0 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -529,7 +529,7 @@ lock_multipath (struct multipath * mpp, int lock)
if (!pgp->paths)
continue;
vector_foreach_slot(pgp->paths, pp, j) {
- if (lock && flock(pp->fd, LOCK_EX | LOCK_NB) &&
+ if (lock && flock(pp->fd, LOCK_SH | LOCK_NB) &&
errno == EWOULDBLOCK)
goto fail;
else if (!lock)
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
next prev parent reply other threads:[~2015-05-24 7:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-23 21:00 [PATCH] libmultipath: don't lock block device but use lock files Christian Seiler
2015-05-24 7:07 ` Hannes Reinecke [this message]
2015-05-24 8:05 ` Christian Seiler
2015-06-02 12:09 ` Christian Seiler
2015-06-03 11:22 ` Hannes Reinecke
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=556178AC.2010501@suse.de \
--to=hare@suse.de \
--cc=christian@iwakd.de \
--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.