All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org, wojciech.neubauer@intel.com,
	adam.kwolek@intel.com, dan.j.williams@intel.com,
	ed.ciechanowski@intel.com
Subject: [PATCH 09/22] imsm: Check if array degradation has been changed
Date: Thu, 02 Jun 2011 16:49:26 +0200	[thread overview]
Message-ID: <20110602144926.27355.45518.stgit@gklab-128-111.igk.intel.com> (raw)
In-Reply-To: <20110602144212.27355.3706.stgit@gklab-128-111.igk.intel.com>

From: Adam Kwolek <adam.kwolek@intel.com>

Before reshaping every "migration unit", check if array is still usable.
In failed disks number is greater than allowed degradation level, reshape
has to be aborted.

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
---
 super-intel.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index b4038d3..d2393c2 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -8310,6 +8310,53 @@ int wait_for_reshape_imsm(struct mdinfo *sra, unsigned long long to_complete,
 }
 
 /*******************************************************************************
+ * Function:	check_degradation_change
+ * Description:	Check that array hasn't become failed.
+ * Parameters:
+ *	info	: for sysfs access
+ *	sources	: source disks descriptors
+ *	degraded: previous degradation level
+ * Returns:
+ *	degradation level
+ ******************************************************************************/
+int check_degradation_change(struct mdinfo *info,
+			     int *sources,
+			     int degraded)
+{
+	unsigned long long new_degraded;
+	sysfs_get_ll(info, NULL, "degraded", &new_degraded);
+	if (new_degraded != (unsigned long long)degraded) {
+		/* check each device to ensure it is still working */
+		struct mdinfo *sd;
+		new_degraded = 0;
+		for (sd = info->devs ; sd ; sd = sd->next) {
+			if (sd->disk.state & (1<<MD_DISK_FAULTY))
+				continue;
+			if (sd->disk.state & (1<<MD_DISK_SYNC)) {
+				char sbuf[20];
+				if (sysfs_get_str(info,
+					sd, "state", sbuf, 20) < 0 ||
+					strstr(sbuf, "faulty") ||
+					strstr(sbuf, "in_sync") == NULL) {
+					/* this device is dead */
+					sd->disk.state = (1<<MD_DISK_FAULTY);
+					if (sd->disk.raid_disk >= 0 &&
+					    sources[sd->disk.raid_disk] >= 0) {
+						close(sources[
+							sd->disk.raid_disk]);
+						sources[sd->disk.raid_disk] =
+							-1;
+					}
+					new_degraded++;
+				}
+			}
+		}
+	}
+
+	return new_degraded;
+}
+
+/*******************************************************************************
  * Function:	imsm_manage_reshape
  * Description:	Function finds array under reshape and it manages reshape
  *		process. It creates stripes backups (if required) and sets
@@ -8353,6 +8400,7 @@ static int imsm_manage_reshape(
 	unsigned long long start_src; /* [bytes] */
 	unsigned long long start; /* [bytes] */
 	unsigned long long start_buf_shift; /* [bytes] */
+	int degraded = 0;
 
 	if (!fds || !offsets || !destfd || !destoffsets || !sra)
 		goto abort;
@@ -8419,6 +8467,15 @@ static int imsm_manage_reshape(
 			* __le32_to_cpu(migr_rec->curr_migr_unit);
 		unsigned long long border;
 
+		/* Check that array hasn't become failed.
+		 */
+		degraded = check_degradation_change(sra, fds, degraded);
+		if (degraded > 1) {
+			dprintf("imsm: Abort reshape due to degradation"
+				" level (%i)\n", degraded);
+			goto abort;
+		}
+
 		next_step = __le32_to_cpu(migr_rec->blocks_per_unit);
 
 		if ((current_position + next_step) > max_position)


  parent reply	other threads:[~2011-06-02 14:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-02 14:48 [PATCH 00/22] IMSM checkpointing implementation Krzysztof Wojcik
2011-06-02 14:48 ` [PATCH 01/22] imsm: Add migration record to intel_super Krzysztof Wojcik
2011-06-02 14:48 ` [PATCH 02/22] Support restore_stripes() from the given buffer Krzysztof Wojcik
2011-06-02 14:48 ` [PATCH 03/22] Define dummy functions to mdmon.c Krzysztof Wojcik
2011-06-02 14:48 ` [PATCH 04/22] imsm: Add support for copy area and backup operations Krzysztof Wojcik
2011-06-02 14:48 ` [PATCH 05/22] imsm: check migration compatibility Krzysztof Wojcik
2011-06-02 14:49 ` [PATCH 06/22] FIX: Initialize reshape structure Krzysztof Wojcik
2011-06-08  6:54   ` NeilBrown
2011-06-02 14:49 ` [PATCH 07/22] imsm: Add wait_for_reshape_imsm() implementation Krzysztof Wojcik
2011-06-08  7:07   ` NeilBrown
2011-06-02 14:49 ` [PATCH 08/22] imsm: Implement imsm_manage_reshape(), reshape workhorse Krzysztof Wojcik
2011-06-02 14:49 ` Krzysztof Wojcik [this message]
2011-06-02 14:49 ` [PATCH 10/22] imsm: Clear migration record when no migration in progress Krzysztof Wojcik
2011-06-02 14:49 ` [PATCH 11/22] imsm: Add information about migration record to mdadm '-E' option Krzysztof Wojcik
2011-06-02 14:49 ` [PATCH 12/22] imsm: update blocks_per_migr_unit() to support migration record Krzysztof Wojcik
2011-06-02 14:49 ` [PATCH 13/22] Add reshape restart support for external metadata Krzysztof Wojcik
2011-06-02 14:50 ` [PATCH 14/22] imsm: Implement recover_backup_imsm() for imsm metadata Krzysztof Wojcik
2011-06-02 14:50 ` [PATCH 15/22] imsm: Disable checkpoint updating by mdmon for general migration Krzysztof Wojcik
2011-06-02 14:50 ` [PATCH 16/22] imsm: Add metadata update type for general migration check-pointing Krzysztof Wojcik
2011-06-02 14:50 ` [PATCH 17/22] imsm: Prepare checkpoint update for general migration Krzysztof Wojcik
2011-06-02 14:50 ` [PATCH 18/22] imsm: Apply checkpoint metadata " Krzysztof Wojcik
2011-06-02 14:50 ` [PATCH 19/22] FIX: Enable metadata updates for raid0 Krzysztof Wojcik
2011-06-02 14:50 ` [PATCH 20/22] Do not use backup file for external metadata Krzysztof Wojcik
2011-06-02 14:51 ` [PATCH 21/22] imsm: Remove user warning before reshape start Krzysztof Wojcik
2011-06-02 14:51 ` [PATCH 22/22] imsm: Unit Tests - remove backup-file during grow command Krzysztof Wojcik
2011-06-08  7:23 ` [PATCH 00/22] IMSM checkpointing implementation NeilBrown
2011-06-08  7:34   ` Wojcik, Krzysztof

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=20110602144926.27355.45518.stgit@gklab-128-111.igk.intel.com \
    --to=krzysztof.wojcik@intel.com \
    --cc=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 \
    --cc=wojciech.neubauer@intel.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.