linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Xiao Ni <xni@redhat.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: [PATCH] need read reshape_groress from sys
Date: Wed, 20 May 2015 15:20:42 +1000	[thread overview]
Message-ID: <20150520152042.407313f9@notabene.brown> (raw)
In-Reply-To: <592729481.1396196.1432089335521.JavaMail.zimbra@redhat.com>

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

On Tue, 19 May 2015 22:35:35 -0400 (EDT) Xiao Ni <xni@redhat.com> wrote:

> Hi all
> 
>    Send the patch again. Because I don't see them at http://www.spinics.net/lists/raid/
> 
> 
> ----- Forwarded Message -----
> From: "Xiao Ni" <xni@redhat.com>
> To: linux-raid@vger.kernel.org
> Cc: "Xiao Ni" <xni@redhat.com>
> Sent: Friday, May 15, 2015 3:07:17 PM
> Subject: [PATCH] need read reshape_groress from sys
> 
> 


Please actually explain the purpose of the patch.
Then  re-read it to ensure it makes sense and remove obvious typos.

and don't just remove unrelated blank lines.
Only include in the patch things that need to be in the patch.


NeilBrown


> Signed-off-by: Xiao Ni <xni@redhat.com>
> ---
>  Grow.c  |   18 ++++++++++++------
>  mdadm.h |    1 +
>  sysfs.c |   15 +++++++++++++++
>  3 files changed, 28 insertions(+), 6 deletions(-)
> 
> diff --git a/Grow.c b/Grow.c
> index 568e399..44ee8a7 100644
> --- a/Grow.c
> +++ b/Grow.c
> @@ -710,11 +710,17 @@ int start_reshape(struct mdinfo *sra, int already_running,
>  	err = sysfs_set_num(sra, NULL, "suspend_hi", sra->reshape_progress);
>  	err = err ?: sysfs_set_num(sra, NULL, "suspend_lo",
>  				   sra->reshape_progress);
> -	if (before_data_disks <= data_disks)
> -		sync_max_to_set = sra->reshape_progress / data_disks;
> -	else
> -		sync_max_to_set = (sra->component_size * data_disks
> -				   - sra->reshape_progress) / data_disks;
> +
> +	if (sra->reshape_progress == UINT64_MAX) {
> +		err = err ?: sysfs_set_str(sra, NULL, "sync_max", "max");
> +	} else {
> +		if (before_data_disks <= data_disks)
> +			sync_max_to_set = sra->reshape_progress / data_disks;
> +		else
> +			sync_max_to_set = (sra->component_size * 2 * data_disks
> +										- sra->reshape_progress) / data_disks;
> +	}
> +
>  	if (!already_running)
>  		sysfs_set_num(sra, NULL, "sync_min", sync_max_to_set);
>  	err = err ?: sysfs_set_num(sra, NULL, "sync_max", sync_max_to_set);
> @@ -3075,7 +3081,7 @@ static int reshape_array(char *container, int fd, char *devname,
>  	}
>  	sra = sysfs_read(fd, NULL,
>  			 GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|GET_CHUNK|
> -			 GET_CACHE);
> +			 GET_CACHE|GET_RESHAPE_PROGRESS);
>  	if (!sra) {
>  		pr_err("%s: Cannot get array details from sysfs\n",
>  			devname);
> diff --git a/mdadm.h b/mdadm.h
> index 141f963..6fb17e1 100644
> --- a/mdadm.h
> +++ b/mdadm.h
> @@ -526,6 +526,7 @@ enum sysfs_read_flags {
>  	GET_DEGRADED	= (1 << 8),
>  	GET_SAFEMODE	= (1 << 9),
>  	GET_BITMAP_LOCATION = (1 << 10),
> +	GET_RESHAPE_PROGRESS = (1 << 11),
>  
>  	GET_DEVS	= (1 << 20), /* gets role, major, minor */
>  	GET_OFFSET	= (1 << 21),
> diff --git a/sysfs.c b/sysfs.c
> index 18f3df9..09b0c93 100644
> --- a/sysfs.c
> +++ b/sysfs.c
> @@ -26,6 +26,7 @@
>  #include	"mdadm.h"
>  #include	<dirent.h>
>  #include	<ctype.h>
> +#include	<stdint.h>
>  
>  int load_sys(char *path, char *buf)
>  {
> @@ -210,6 +211,19 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
>  		msec = (msec * 1000) / scale;
>  		sra->safe_mode_delay = msec;
>  	}
> +
> +	if (options & GET_RESHAPE_PROGRESS) {
> +			  
> +		strcpy(base, "reshape_progress");
> +		if (load_sys(fname, buf))
> +			goto abort;
> +
> +		if (strncmp(buf, "max", 3) == 0)
> +			sra->reshape_progress = UINT64_MAX;
> +		else
> +			sra->reshape_progress = strtol(buf, NULL, 10);
> +	}
> +
>  	if (options & GET_BITMAP_LOCATION) {
>  		strcpy(base, "bitmap/location");
>  		if (load_sys(fname, buf))
> @@ -224,6 +238,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
>  			goto abort;
>  	}
>  
> +
>  	if (! (options & GET_DEVS))
>  		return sra;
>  


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

  reply	other threads:[~2015-05-20  5:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1431673637-10817-1-git-send-email-xni@redhat.com>
2015-05-20  2:35 ` Fwd: [PATCH] need read reshape_groress from sys Xiao Ni
2015-05-20  5:20   ` NeilBrown [this message]
2015-05-21  3:35     ` Xiao Ni

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=20150520152042.407313f9@notabene.brown \
    --to=neilb@suse.de \
    --cc=linux-raid@vger.kernel.org \
    --cc=xni@redhat.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).