* [PATCH] multipath: fix multipath locking
@ 2010-11-05 4:59 Benjamin Marzinski
2010-11-05 5:59 ` Malahal Naineni
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Marzinski @ 2010-11-05 4:59 UTC (permalink / raw)
To: device-mapper development
In lock_multipath(), if multipathd fails halfway though locking the the path
devices, it doesn't unlock the ones that it already has locked. This
patch fixes that.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/configure.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
Index: multipath-tools/libmultipath/configure.c
===================================================================
--- multipath-tools.orig/libmultipath/configure.c
+++ multipath-tools/libmultipath/configure.c
@@ -284,6 +284,7 @@ lock_multipath (struct multipath * mpp,
struct pathgroup * pgp;
struct path * pp;
int i, j;
+ int x, y;
if (!mpp || !mpp->pg)
return 0;
@@ -294,12 +295,25 @@ lock_multipath (struct multipath * mpp,
vector_foreach_slot(pgp->paths, pp, j) {
if (lock && flock(pp->fd, LOCK_EX | LOCK_NB) &&
errno == EWOULDBLOCK)
- return 1;
+ goto fail;
else if (!lock)
flock(pp->fd, LOCK_UN);
}
}
return 0;
+fail:
+ vector_foreach_slot (mpp->pg, pgp, x) {
+ if (x > i)
+ return 1;
+ if (!pgp->paths)
+ continue;
+ vector_foreach_slot(pgp->paths, pp, y) {
+ if (x == i && y > j)
+ return 1;
+ flock(pp->fd, LOCK_UN);
+ }
+ }
+ return 1;
}
/*
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] multipath: fix multipath locking
2010-11-05 4:59 [PATCH] multipath: fix multipath locking Benjamin Marzinski
@ 2010-11-05 5:59 ` Malahal Naineni
2010-11-05 7:11 ` Christophe Varoqui
0 siblings, 1 reply; 3+ messages in thread
From: Malahal Naineni @ 2010-11-05 5:59 UTC (permalink / raw)
To: dm-devel
Benjamin Marzinski [bmarzins@redhat.com] wrote:
> @@ -294,12 +295,25 @@ lock_multipath (struct multipath * mpp,
> vector_foreach_slot(pgp->paths, pp, j) {
> if (lock && flock(pp->fd, LOCK_EX | LOCK_NB) &&
> errno == EWOULDBLOCK)
> - return 1;
> + goto fail;
> else if (!lock)
> flock(pp->fd, LOCK_UN);
> }
> }
> return 0;
> +fail:
> + vector_foreach_slot (mpp->pg, pgp, x) {
> + if (x > i)
> + return 1;
> + if (!pgp->paths)
> + continue;
> + vector_foreach_slot(pgp->paths, pp, y) {
> + if (x == i && y > j)
Path 'j' has failed to get the lock dropping us to the fail label.
We should NOT be unlocking for path "j", so the above if expression
should be "(x ==i && y >= j)" instead.
Otherwise, it looks good.
> + return 1;
> + flock(pp->fd, LOCK_UN);
> + }
> + }
> + return 1;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] multipath: fix multipath locking
2010-11-05 5:59 ` Malahal Naineni
@ 2010-11-05 7:11 ` Christophe Varoqui
0 siblings, 0 replies; 3+ messages in thread
From: Christophe Varoqui @ 2010-11-05 7:11 UTC (permalink / raw)
To: device-mapper development
Applied with fix,
Thanks.
On jeu., 2010-11-04 at 22:59 -0700, Malahal Naineni wrote:
> Benjamin Marzinski [bmarzins@redhat.com] wrote:
> > @@ -294,12 +295,25 @@ lock_multipath (struct multipath * mpp,
> > vector_foreach_slot(pgp->paths, pp, j) {
> > if (lock && flock(pp->fd, LOCK_EX | LOCK_NB) &&
> > errno == EWOULDBLOCK)
> > - return 1;
> > + goto fail;
> > else if (!lock)
> > flock(pp->fd, LOCK_UN);
> > }
> > }
> > return 0;
> > +fail:
> > + vector_foreach_slot (mpp->pg, pgp, x) {
> > + if (x > i)
> > + return 1;
> > + if (!pgp->paths)
> > + continue;
> > + vector_foreach_slot(pgp->paths, pp, y) {
> > + if (x == i && y > j)
>
> Path 'j' has failed to get the lock dropping us to the fail label.
> We should NOT be unlocking for path "j", so the above if expression
> should be "(x ==i && y >= j)" instead.
>
> Otherwise, it looks good.
>
> > + return 1;
> > + flock(pp->fd, LOCK_UN);
> > + }
> > + }
> > + return 1;
>
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-05 7:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-05 4:59 [PATCH] multipath: fix multipath locking Benjamin Marzinski
2010-11-05 5:59 ` Malahal Naineni
2010-11-05 7:11 ` Christophe Varoqui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).