* [PATCH 33/33] Try exclusive open on a spare device before it is added to another container.
[not found] <A9DE54D0CD747C4CB06DCE5B6FA2246FDA893C6B@irsmsx504.ger.corp.intel.com>
@ 2010-07-05 10:51 ` Hawrylewicz Czarnowski, Przemyslaw
2010-07-06 7:57 ` Neil Brown
1 sibling, 0 replies; 2+ messages in thread
From: Hawrylewicz Czarnowski, Przemyslaw @ 2010-07-05 10:51 UTC (permalink / raw)
To: linux-raid@vger.kernel.org
From: Czarnowska, Anna
Sent: Monday, July 05, 2010 11:45 AM
To: Neil Brown
Cc: linux-raid@vger.kernel.org; Czarnowska, Anna; Hawrylewicz Czarnowski, Przemyslaw; Labun, Marcin; Neubauer, Wojciech; Williams, Dan J; Ciechanowski, Ed; dledford@redhat.com
Subject: [PATCH 33/33] Try exclusive open on a spare device before it is added to another container.
From: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: Marcin Labun <marcin.labun@intel.com>
---
Monitor.c | 48 +++++++++++++++++++++++++++++++++++-------------
1 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index 932a2bc..a1ae67f 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -534,8 +534,9 @@ int Monitor(mddev_dev_t devlist,
return 0;
}
-static int move_spare(struct state *st2, struct state *st1, int i, char *mailaddr,
- char *mailfrom, char *alert_cmd, int dosyslog)
+static int move_spare(struct state *st2, struct state *st1, int i,
+ char *mailaddr, char *mailfrom, char *alert_cmd,
+ int dosyslog)
{
struct mddev_dev_s devlist;
@@ -570,20 +571,41 @@ static int move_spare(struct state *st2, struct state *st1, int i, char *mailadd
devlist.disposition = 'r';
if (Manage_subdevs(st2->devname, from_fd, &devlist, -1) == 0) {
- devlist.disposition = 'a';
- if (Manage_subdevs(st1->devname, to_fd, &devlist, -1) == 0) {
- st2->devid[i] = 0;
- ping_manager(st2->devname);
- ping_manager(st1->devname);
- alert("MoveSpare", st1->devname, st2->devname, mailaddr,
- mailfrom, alert_cmd, dosyslog);
- close(from_fd);
- close(to_fd);
- return 1;
+ int dfd;
+ dfd = open(dv, O_RDWR|O_EXCL);
+ if (dfd < 0) {
+ fprintf(stderr,
+ "Error: Exclusive open on device %s failed\n",
+ dv);
+ devlist.disposition = 'a';
+ if (Manage_subdevs(st2->devname, from_fd, &devlist,
+ -1) != 0)
+ fprintf(stderr,
+ "Error: Adding back spare device %s"
+ "to container %s failed!\n",
+ st2->devname, dv);
} else {
- Manage_subdevs(st2->devname, from_fd, &devlist, -1);
+ close(dfd);
+ devlist.disposition = 'a';
+ if (Manage_subdevs(st1->devname, to_fd, &devlist,
+ -1) == 0) {
+ st2->devid[i] = 0;
+ ping_manager(st2->devname);
+ ping_manager(st1->devname);
+ alert("MoveSpare", st1->devname, st2->devname,
+ mailaddr, mailfrom, alert_cmd, dosyslog);
+ close(from_fd);
+ close(to_fd);
+ return 1;
+ } else if (Manage_subdevs(st2->devname, from_fd,
+ &devlist, -1) != 0)
+ fprintf(stderr,
+ "Error: Adding back spare device"
+ "%s to container %s failed!\n",
+ st2->devname, dv);
}
}
+ /* Failed to add spare to new container */
close(from_fd);
close(to_fd);
return 0;
--
1.6.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 33/33] Try exclusive open on a spare device before it is added to another container.
[not found] <A9DE54D0CD747C4CB06DCE5B6FA2246FDA893C6B@irsmsx504.ger.corp.intel.com>
2010-07-05 10:51 ` [PATCH 33/33] Try exclusive open on a spare device before it is added to another container Hawrylewicz Czarnowski, Przemyslaw
@ 2010-07-06 7:57 ` Neil Brown
1 sibling, 0 replies; 2+ messages in thread
From: Neil Brown @ 2010-07-06 7:57 UTC (permalink / raw)
To: Czarnowska, Anna
Cc: linux-raid@vger.kernel.org, Hawrylewicz Czarnowski, Przemyslaw,
Labun, Marcin, Neubauer, Wojciech, Williams, Dan J,
Ciechanowski, Ed, dledford@redhat.com
There is no explanation of why you try an exclusive open.
I can only imagine that you are trying to close some sort of race.
I don't think that getting an exclusive open on a member device actually
closes the race, though it might make it harder to hit.
I think the protocol that we want is that before we add or remove a device to
a container, or reassign a device within a container we take an exclusive
open on the container.
mdadm can do this to add/remove devices.
managemon can do this to assign a spare to an array.
This is the protocol that Manage_subdevs uses I think.
NeilBrown
On Mon, 5 Jul 2010 10:45:26 +0100
"Czarnowska, Anna" <anna.czarnowska@intel.com> wrote:
> From: Marcin Labun <marcin.labun@intel.com>
>
>
>
> Signed-off-by: Marcin Labun <marcin.labun@intel.com<mailto:marcin.labun@intel.com>>
>
> ---
>
> Monitor.c | 48 +++++++++++++++++++++++++++++++++++-------------
>
> 1 files changed, 35 insertions(+), 13 deletions(-)
>
>
>
> diff --git a/Monitor.c b/Monitor.c
>
> index 932a2bc..a1ae67f 100644
>
> --- a/Monitor.c
>
> +++ b/Monitor.c
>
> @@ -534,8 +534,9 @@ int Monitor(mddev_dev_t devlist,
>
> return 0;
>
> }
>
>
>
> -static int move_spare(struct state *st2, struct state *st1, int i, char *mailaddr,
>
> - char *mailfrom, char *alert_cmd, int dosyslog)
>
> +static int move_spare(struct state *st2, struct state *st1, int i,
>
> + char *mailaddr, char *mailfrom, char *alert_cmd,
>
> + int dosyslog)
>
>
>
> {
>
> struct mddev_dev_s devlist;
>
> @@ -570,20 +571,41 @@ static int move_spare(struct state *st2, struct state *st1, int i, char *mailadd
>
>
>
> devlist.disposition = 'r';
>
> if (Manage_subdevs(st2->devname, from_fd, &devlist, -1) == 0) {
>
> - devlist.disposition = 'a';
>
> - if (Manage_subdevs(st1->devname, to_fd, &devlist, -1) == 0) {
>
> - st2->devid[i] = 0;
>
> - ping_manager(st2->devname);
>
> - ping_manager(st1->devname);
>
> - alert("MoveSpare", st1->devname, st2->devname, mailaddr,
>
> - mailfrom, alert_cmd, dosyslog);
>
> - close(from_fd);
>
> - close(to_fd);
>
> - return 1;
>
> + int dfd;
>
> + dfd = open(dv, O_RDWR|O_EXCL);
>
> + if (dfd < 0) {
>
> + fprintf(stderr,
>
> + "Error: Exclusive open on device %s failed\n",
>
> + dv);
>
> + devlist.disposition = 'a';
>
> + if (Manage_subdevs(st2->devname, from_fd, &devlist,
>
> + -1) != 0)
>
> + fprintf(stderr,
>
> + "Error: Adding back spare device %s"
>
> + "to container %s failed!\n",
>
> + st2->devname, dv);
>
> } else {
>
> - Manage_subdevs(st2->devname, from_fd, &devlist, -1);
>
> + close(dfd);
>
> + devlist.disposition = 'a';
>
> + if (Manage_subdevs(st1->devname, to_fd, &devlist,
>
> + -1) == 0) {
>
> + st2->devid[i] = 0;
>
> + ping_manager(st2->devname);
>
> + ping_manager(st1->devname);
>
> + alert("MoveSpare", st1->devname, st2->devname,
>
> + mailaddr, mailfrom, alert_cmd, dosyslog);
>
> + close(from_fd);
>
> + close(to_fd);
>
> + return 1;
>
> + } else if (Manage_subdevs(st2->devname, from_fd,
>
> + &devlist, -1) != 0)
>
> + fprintf(stderr,
>
> + "Error: Adding back spare device"
>
> + "%s to container %s failed!\n",
>
> + st2->devname, dv);
>
> }
>
> }
>
> + /* Failed to add spare to new container */
>
> close(from_fd);
>
> close(to_fd);
>
> return 0;
>
> --
>
> 1.6.4.2
>
>
>
> ---------------------------------------------------------------------
> Intel Technology Poland sp. z o.o.
> z siedziba w Gdansku
> ul. Slowackiego 173
> 80-298 Gdansk
>
> Sad Rejonowy Gdansk Polnoc w Gdansku,
> VII Wydzial Gospodarczy Krajowego Rejestru Sadowego,
> numer KRS 101882
>
> NIP 957-07-52-316
> Kapital zakladowy 200.000 zl
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-06 7:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <A9DE54D0CD747C4CB06DCE5B6FA2246FDA893C6B@irsmsx504.ger.corp.intel.com>
2010-07-05 10:51 ` [PATCH 33/33] Try exclusive open on a spare device before it is added to another container Hawrylewicz Czarnowski, Przemyslaw
2010-07-06 7:57 ` Neil Brown
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).