linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Adam Kwolek <adam.kwolek@intel.com>
Cc: linux-raid@vger.kernel.org, ed.ciechanowski@intel.com,
	marcin.labun@intel.com, dan.j.williams@intel.com
Subject: Re: [PATCH 3/8] Do not restart reshape if it is started already
Date: Mon, 3 Oct 2011 09:41:58 +1100	[thread overview]
Message-ID: <20111003094158.36e18c5f@notabene.brown> (raw)
In-Reply-To: <20110927120457.4890.53328.stgit@gklab-128-013.igk.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2823 bytes --]

On Tue, 27 Sep 2011 14:04:57 +0200 Adam Kwolek <adam.kwolek@intel.com> wrote:

> When reshape was invoked during initrd start-up stage array is pushed
> in to reshape state already, so read only state cannot be set again during
> reshape continuation. Set previously reshape state has to be reused
> during reshape continuation.
> 
> Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
> ---
> 
>  Grow.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/Grow.c b/Grow.c
> index 768fc86..d9c2817 100644
> --- a/Grow.c
> +++ b/Grow.c
> @@ -3773,11 +3773,17 @@ int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info,
>  {
>  	char buf[40];
>  	char *container = NULL;
> -	int err;
> +	int err = 0;
>  
> -	err = sysfs_set_str(info, NULL, "array_state", "readonly");
> +	/* set read only array state when there is no reshape
> +	 * in progress already
> +	 */
> +	if ((sysfs_get_str(info, NULL, "sync_action", buf, 40) != 8) &&
> +	    (strncmp(buf, "reshape", 7) != 0))
> +		err = sysfs_set_str(info, NULL, "array_state", "readonly");
>  	if (err)
>  		return err;
> +
>  	if (st->ss->external) {
>  		fmt_devname(buf, st->container_dev);
>  		container = buf;


This is wrong.
For a start the '&&' should be '||' or it doesn't make sense.

The reason were are setting readonly here is that the array hasn't been
activated at all, so it isn't possible to freeze anything.
So we set the array to readonly so that no reshape/resync/etc can start, then
activate the array in reshape_array, then freeze, and allow it to be
read-write.

So Grow_continue really assumes that the array hasn't been started yet.
You are using it in different situation, where it has been started.
For that to be reasonably, you really need to tell Grow_continue that the
array hasn't started, not let it try to figure out for itself.

However I think it would be easier to just copy the code from Grow_continue
into the place where you called it in Grow_continue_command and then remove
the bits that you don't need.
You don't need the readonly setting and you don't need the start_mdmon and I
don't think you need the freeze(), so it becomes:

if (st->ss->external && info->reshape_active == 2) {
  		int cfd = open_dev(st->container_dev);
		if (cfd < 0)
			return 1;
		st->ss->load_container(st, cfd, container);
		close(cfd);
		ret_val = reshape_container(container, NULL,
					 st, info, 0, backup_file,
					 0, 1, freeze_reshape);
	}
} else
	ret_val = reshape_array(container, mdfd, "array", st, info, 1,
			     NULL, backup_file, 0, 0, 1, freeze_reshape);

which is a better result I think.

So I won't apply this patch.  Please consider the above and submit a revised
version if you agree.

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

  reply	other threads:[~2011-10-02 22:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 12:04 [PATCH 0/8] Reshape restart after filesystem pivot Adam Kwolek
2011-09-27 12:04 ` [PATCH 1/8] Do not continue reshape during initrd phase Adam Kwolek
2011-10-02 22:19   ` NeilBrown
2011-09-27 12:04 ` [PATCH 2/8] Add continue option to grow command Adam Kwolek
2011-10-02 22:27   ` NeilBrown
2011-09-27 12:04 ` [PATCH 3/8] Do not restart reshape if it is started already Adam Kwolek
2011-10-02 22:41   ` NeilBrown [this message]
2011-09-27 12:05 ` [PATCH 4/8] Set correct reshape restart position Adam Kwolek
2011-10-02 22:56   ` NeilBrown
2011-09-27 12:05 ` [PATCH 5/8] Move code to get_data_disks() function Adam Kwolek
2011-10-02 22:58   ` NeilBrown
2011-09-27 12:05 ` [PATCH 6/8] Verify reshape restart position Adam Kwolek
2011-10-02 23:06   ` NeilBrown
2011-09-27 12:05 ` [PATCH 7/8] Manual update for --continue option Adam Kwolek
2011-09-27 12:05 ` [PATCH 8/8] " Adam Kwolek
2011-10-02 23:09   ` 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=20111003094158.36e18c5f@notabene.brown \
    --to=neilb@suse.de \
    --cc=adam.kwolek@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ed.ciechanowski@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=marcin.labun@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 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).