linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adam Kwolek <adam.kwolek@intel.com>
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org, dan.j.williams@intel.com,
	ed.ciechanowski@intel.com
Subject: [PATCH 09/10] FIX: Honor !reshape state on wait_reshape() entry
Date: Thu, 02 Dec 2010 09:19:51 +0100	[thread overview]
Message-ID: <20101202081950.4639.14389.stgit@gklab-170-024.igk.intel.com> (raw)
In-Reply-To: <20101202080818.4639.38119.stgit@gklab-170-024.igk.intel.com>

When wait_reshape() function starts it can occurs that reshape is finished already,
before wait_reshape() start. This can lead to wait for change state inside this function for a long time.
To avoid this before wait we should test if finish conditions are not reached already.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 Grow.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Grow.c b/Grow.c
index 96c9526..24c5c39 100644
--- a/Grow.c
+++ b/Grow.c
@@ -548,17 +548,22 @@ static void wait_reshape(struct mdinfo *sra)
 	int fd = sysfs_get_fd(sra, NULL, "sync_action");
 	char action[20];
 
-	do {
+	if (fd < 0)
+		return;
+
+	if (sysfs_fd_get_str(fd, action, 20) < 0) {
+		close(fd);
+		return;
+	}
+	while  (strncmp(action, "reshape", 7) == 0) {
 		fd_set rfds;
 		FD_ZERO(&rfds);
 		FD_SET(fd, &rfds);
 		select(fd+1, NULL, NULL, &rfds, NULL);
-		
-		if (sysfs_fd_get_str(fd, action, 20) < 0) {
-			close(fd);
-			return;
-		}
-	} while  (strncmp(action, "reshape", 7) == 0);
+		if (sysfs_fd_get_str(fd, action, 20) < 0)
+			break;
+	}
+	close(fd);
 }
 
 static int reshape_super(struct supertype *st, long long size, int level,


  parent reply	other threads:[~2010-12-02  8:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-02  8:18 [PATCH 00/10] Pre-migration patch series Adam Kwolek
2010-12-02  8:18 ` [PATCH 01/10] FIX: Cannot exit monitor after takeover Adam Kwolek
2010-12-02  8:18 ` [PATCH 02/10] FIX: Problem with removing array " Adam Kwolek
2010-12-03  3:46   ` Neil Brown
2010-12-02  8:19 ` [PATCH 03/10] FIX: Add error code for raid_disks set Adam Kwolek
2010-12-02 18:56   ` Dan Williams
2010-12-02  8:19 ` [PATCH 04/10] Add support to skip slot configuration Adam Kwolek
2010-12-02  8:19 ` [PATCH 05/10] Add spares to raid0 array using takeover Adam Kwolek
2010-12-03  3:52   ` Neil Brown
2010-12-02  8:19 ` [PATCH 06/10] FIX: open backup file for reshape as function Adam Kwolek
2010-12-03  4:01   ` Neil Brown
2010-12-02  8:19 ` [PATCH 07/10] FIX: Do not use layout for raid4 and raid0 while geo map computing Adam Kwolek
2010-12-02  8:19 ` [PATCH 08/10] FIX: sync_completed_fd handler has to be closed Adam Kwolek
2010-12-02  8:19 ` Adam Kwolek [this message]
2010-12-03  4:11   ` [PATCH 09/10] FIX: Honor !reshape state on wait_reshape() entry Neil Brown
2010-12-02  8:19 ` [PATCH 10/10] FIX: wait_backup() sometimes hungs Adam Kwolek
2010-12-03  4:16   ` Neil Brown
2010-12-03  7:45     ` Kwolek, Adam
2010-12-03 10:35       ` Neil Brown
2010-12-03  4:19 ` [PATCH 00/10] Pre-migration patch series Neil Brown

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=20101202081950.4639.14389.stgit@gklab-170-024.igk.intel.com \
    --to=adam.kwolek@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ed.ciechanowski@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    /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 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).