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, grzegorz.grabowski@intel.com,
	maciej.patelczyk@intel.com, anna.czarnowska@intel.com,
	Adam Kwolek <adam.kwolek@intel.com>
Subject: [PATCH 06/14] imsm: FIX: Support metadata changes rollback
Date: Fri, 13 Apr 2012 16:52:00 +0200	[thread overview]
Message-ID: <1334328728-12544-7-git-send-email-adam.kwolek@intel.com> (raw)
In-Reply-To: <1334328728-12544-6-git-send-email-adam.kwolek@intel.com>

Add metadata rollback specific code for imsm.
Let reshape_super() ability to differentiate metadata apply and rollback
actions.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---
 super-intel.c |   56 ++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 62aeeb3..2a050fc 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -9472,7 +9472,8 @@ static int imsm_find_array_minor_by_subdev(int subdev, int container, int *minor
 
 static int imsm_reshape_is_allowed_on_container(struct supertype *st,
 						struct geo_params *geo,
-						int *old_raid_disks)
+						int *old_raid_disks,
+						int direction)
 {
 	/* currently we only support increasing the number of devices
 	 * for a container.  This increases the number of device for each
@@ -9496,6 +9497,12 @@ static int imsm_reshape_is_allowed_on_container(struct supertype *st,
 		return ret_val;
 	}
 
+	if (direction == ROLLBACK_METADATA_CHANGES) {
+		dprintf("imsm: Metadata changes rollback is not supported for "
+			"container operation.\n");
+		return ret_val;
+	}
+
 	info = container_content_imsm(st, NULL);
 	for (member = info; member; member = member->next) {
 		int result;
@@ -9816,11 +9823,13 @@ static void imsm_update_metadata_locally(struct supertype *st,
 * Function:	imsm_analyze_change
 * Description:	Function analyze change for single volume
 * 		and validate if transition is supported
-* Parameters:	Geometry parameters, supertype structure
+* Parameters:	Geometry parameters, supertype structure,
+*		metadata change direction (apply/rollback)
 * Returns:	Operation type code on success, -1 if fail
 ****************************************************************************/
 enum imsm_reshape_type imsm_analyze_change(struct supertype *st,
-					   struct geo_params *geo)
+					   struct geo_params *geo,
+					   int direction)
 {
 	struct mdinfo info;
 	int change = -1;
@@ -9939,18 +9948,24 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st,
 			goto analyse_change_exit;
 		}
 		geo->size *= 2;
-		/* round size due to metadata compatibility
-		 */
-		geo->size = (geo->size >> SECT_PER_MB_SHIFT)
-			    << SECT_PER_MB_SHIFT;
-		dprintf("Prepare update for size change to %llu\n", geo->size );
-		if (current_size >= geo->size) {
-			fprintf(stderr,
-				Name " Error. Size expanssion is supported only"
-				" (current size is %llu, requested size "
-				"/rounded/ is %llu).\n",
-				current_size, geo->size);
-			goto analyse_change_exit;
+		if ((direction == ROLLBACK_METADATA_CHANGES)) {
+			/* accept size for rollback only
+			*/
+		} else {
+			/* round size due to metadata compatibility
+			*/
+			geo->size = (geo->size >> SECT_PER_MB_SHIFT)
+				    << SECT_PER_MB_SHIFT;
+			dprintf("Prepare update for size change to %llu\n",
+				geo->size );
+			if (current_size >= geo->size) {
+				fprintf(stderr,
+					Name " Error. Size expanssion is "
+					"supported only (current size is %llu, "
+					"requested size /rounded/ is %llu).\n",
+					current_size, geo->size);
+				goto analyse_change_exit;
+			}
 		}
 		geo->size *= data_disks;
 		geo->raid_disks = dev->vol.map->num_members;
@@ -9980,7 +9995,12 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st,
 	}
 
 analyse_change_exit:
-
+	if ((direction == ROLLBACK_METADATA_CHANGES) &&
+	     ((change == CH_MIGRATION) || (change == CH_TAKEOVER))) {
+		dprintf("imsm: Metadata changes rollback is not supported for "
+			"migration and takeover operations.\n");
+		change = -1;
+	}
 	return change;
 }
 
@@ -10051,7 +10071,7 @@ static int imsm_reshape_super(struct supertype *st, long long size, int level,
 		int old_raid_disks = 0;
 
 		if (imsm_reshape_is_allowed_on_container(
-			    st, &geo, &old_raid_disks)) {
+			    st, &geo, &old_raid_disks, direction)) {
 			struct imsm_update_reshape *u = NULL;
 			int len;
 
@@ -10100,7 +10120,7 @@ static int imsm_reshape_super(struct supertype *st, long long size, int level,
 			goto exit_imsm_reshape_super;
 		}
 		super->current_vol = dev->index;
-		change = imsm_analyze_change(st, &geo);
+		change = imsm_analyze_change(st, &geo, direction);
 		switch (change) {
 		case CH_TAKEOVER:
 			ret_val = imsm_takeover(st, &geo);
-- 
1.6.4.2


  reply	other threads:[~2012-04-13 14:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13 14:51 [PATCH 00/14] imsm: volume expand Adam Kwolek
2012-04-13 14:51 ` [PATCH 01/14] imsm: FIX: Update function imsm_num_data_members() for Raid1/10 Adam Kwolek
2012-04-13 14:51   ` [PATCH 02/14] imsm: FIX: Add volume size expand support to imsm_analyze_change() Adam Kwolek
2012-04-13 14:51     ` [PATCH 03/14] imsm: Add new metadata update for volume size expansion Adam Kwolek
2012-04-13 14:51       ` [PATCH 04/14] imsm: Execute size change for external metatdata Adam Kwolek
2012-04-13 14:51         ` [PATCH 05/14] FIX: Support metadata changes rollback Adam Kwolek
2012-04-13 14:52           ` Adam Kwolek [this message]
2012-04-13 14:52             ` [PATCH 07/14] FIX: Extend size of raid0 array Adam Kwolek
2012-04-13 14:52               ` [PATCH 08/14] FIX: Respect metadata size limitations Adam Kwolek
2012-04-13 14:52                 ` [PATCH 09/14] FIX: Detect error and rollback metadata Adam Kwolek
2012-04-13 14:52                   ` [PATCH 10/14] imsm: Add function imsm_get_free_size() Adam Kwolek
2012-04-13 14:52                     ` [PATCH 11/14] imsm: Support setting max size for size change operation Adam Kwolek
2012-04-13 14:52                       ` [PATCH 12/14] imsm: FIX: Component size alignment check Adam Kwolek
2012-04-13 14:52                         ` [PATCH 13/14] FIX: Size change is possible as standalone change only Adam Kwolek
2012-04-13 14:52                           ` [PATCH 14/14] FIX: Assembled second array is in read only state during reshape Adam Kwolek
2012-04-17  2:52               ` [PATCH 07/14] FIX: Extend size of raid0 array NeilBrown
2012-04-19 15:09                 ` Dorau, Lukasz
2012-04-19 21:23                   ` NeilBrown
2012-04-20  8:48                     ` Dorau, Lukasz
2012-04-17  2:56 ` [PATCH 00/14] imsm: volume expand NeilBrown

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=1334328728-12544-7-git-send-email-adam.kwolek@intel.com \
    --to=adam.kwolek@intel.com \
    --cc=anna.czarnowska@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ed.ciechanowski@intel.com \
    --cc=grzegorz.grabowski@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=maciej.patelczyk@intel.com \
    --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).