linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] imsm: add extra handling of sync_action and sync_completed
@ 2016-06-16  9:31 Alexey Obitotskiy
  2016-06-16  9:31 ` [PATCH 1/2] imsm: add handling of sync_action is equal to 'idle' Alexey Obitotskiy
  2016-06-16  9:31 ` [PATCH 2/2] imsm: properly handle values of sync_completed Alexey Obitotskiy
  0 siblings, 2 replies; 5+ messages in thread
From: Alexey Obitotskiy @ 2016-06-16  9:31 UTC (permalink / raw)
  To: jes.sorensen; +Cc: linux-raid

This patchset fixes issues with IMSM reshape completion
or interruption. 
After sync completion sync_action set to 'idle' and must be treated 
as normal wait_for_reshape_imsm termination. During sync or after 
sync finished sync_completed can be set to 'disabled' or 'none' and 
must be handled respectively.

Alexey Obitotskiy (2):
  imsm: add handling of sync_action is equal to 'idle'
  imsm: properly handle values of sync_completed

 super-intel.c | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] imsm: add handling of sync_action is equal to 'idle'
  2016-06-16  9:31 [PATCH 0/2] imsm: add extra handling of sync_action and sync_completed Alexey Obitotskiy
@ 2016-06-16  9:31 ` Alexey Obitotskiy
  2016-06-16 17:59   ` Jes Sorensen
  2016-06-16  9:31 ` [PATCH 2/2] imsm: properly handle values of sync_completed Alexey Obitotskiy
  1 sibling, 1 reply; 5+ messages in thread
From: Alexey Obitotskiy @ 2016-06-16  9:31 UTC (permalink / raw)
  To: jes.sorensen; +Cc: linux-raid

After resync is stopped sync_action value become 'idle'.
We treat this case as normal termination of waiting, not as error.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Reviewed-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
---
 super-intel.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/super-intel.c b/super-intel.c
index 7e2860c..7950bef 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -10423,6 +10423,8 @@ int wait_for_reshape_imsm(struct mdinfo *sra, int ndata)
 		if (sysfs_get_str(sra, NULL, "sync_action",
 				  action, 20) > 0 &&
 				strncmp(action, "reshape", 7) != 0) {
+			if (strncmp(action, "idle", 4) == 0)
+				break;
 			close(fd);
 			return -1;
 		}
@@ -10432,9 +10434,9 @@ int wait_for_reshape_imsm(struct mdinfo *sra, int ndata)
 			return 1;
 		}
 	} while (completed < position_to_set);
+
 	close(fd);
 	return 0;
-
 }
 
 /*******************************************************************************
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] imsm: properly handle values of sync_completed
  2016-06-16  9:31 [PATCH 0/2] imsm: add extra handling of sync_action and sync_completed Alexey Obitotskiy
  2016-06-16  9:31 ` [PATCH 1/2] imsm: add handling of sync_action is equal to 'idle' Alexey Obitotskiy
@ 2016-06-16  9:31 ` Alexey Obitotskiy
  2016-06-16 17:59   ` Jes Sorensen
  1 sibling, 1 reply; 5+ messages in thread
From: Alexey Obitotskiy @ 2016-06-16  9:31 UTC (permalink / raw)
  To: jes.sorensen; +Cc: linux-raid

The sync_completed can be set to such values:
- two numbers of processed sectors and total during synchronization,
separated with '/';
- 'none' if synchronization process is stopped;
- 'delayed' if synchronization process is delayed.
Handle value of sync_completed not only as numbers but
also check for 'none' and 'delayed'.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Reviewed-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
---
 super-intel.c | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 7950bef..b401f3c 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -10363,6 +10363,33 @@ exit_imsm_reshape_super:
 	return ret_val;
 }
 
+#define COMPLETED_OK		0
+#define COMPLETED_NONE		1
+#define COMPLETED_DELAYED	2
+
+static int read_completed(int fd, unsigned long long *val)
+{
+	int ret;
+	char buf[50];
+
+	ret = sysfs_fd_get_str(fd, buf, 50);
+	if (ret < 0)
+		return ret;
+
+	ret = COMPLETED_OK;
+	if (strncmp(buf, "none", 4) == 0) {
+		ret = COMPLETED_NONE;
+	} else if (strncmp(buf, "delayed", 7) == 0) {
+		ret = COMPLETED_DELAYED;
+	} else {
+		char *ep;
+		*val = strtoull(buf, &ep, 0);
+		if (ep == buf || (*ep != 0 && *ep != '\n' && *ep != ' '))
+			ret = -1;
+	}
+	return ret;
+}
+
 /*******************************************************************************
  * Function:	wait_for_reshape_imsm
  * Description:	Function writes new sync_max value and waits until
@@ -10417,7 +10444,9 @@ int wait_for_reshape_imsm(struct mdinfo *sra, int ndata)
 	}
 
 	do {
+		int rc;
 		char action[20];
+
 		int timeout = 3000;
 		sysfs_wait(fd, &timeout);
 		if (sysfs_get_str(sra, NULL, "sync_action",
@@ -10428,11 +10457,14 @@ int wait_for_reshape_imsm(struct mdinfo *sra, int ndata)
 			close(fd);
 			return -1;
 		}
-		if (sysfs_fd_get_ll(fd, &completed) < 0) {
+
+		rc = read_completed(fd, &completed);
+		if (rc < 0) {
 			dprintf("cannot read reshape_position (in loop)\n");
 			close(fd);
 			return 1;
-		}
+		} else if (rc == COMPLETED_NONE)
+			break;
 	} while (completed < position_to_set);
 
 	close(fd);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] imsm: add handling of sync_action is equal to 'idle'
  2016-06-16  9:31 ` [PATCH 1/2] imsm: add handling of sync_action is equal to 'idle' Alexey Obitotskiy
@ 2016-06-16 17:59   ` Jes Sorensen
  0 siblings, 0 replies; 5+ messages in thread
From: Jes Sorensen @ 2016-06-16 17:59 UTC (permalink / raw)
  To: Alexey Obitotskiy; +Cc: linux-raid

Alexey Obitotskiy <aleksey.obitotskiy@intel.com> writes:
> After resync is stopped sync_action value become 'idle'.
> We treat this case as normal termination of waiting, not as error.
>
> Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
> Reviewed-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
> ---
>  super-intel.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied!

Thanks,
Jes


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] imsm: properly handle values of sync_completed
  2016-06-16  9:31 ` [PATCH 2/2] imsm: properly handle values of sync_completed Alexey Obitotskiy
@ 2016-06-16 17:59   ` Jes Sorensen
  0 siblings, 0 replies; 5+ messages in thread
From: Jes Sorensen @ 2016-06-16 17:59 UTC (permalink / raw)
  To: Alexey Obitotskiy; +Cc: linux-raid

Alexey Obitotskiy <aleksey.obitotskiy@intel.com> writes:
> The sync_completed can be set to such values:
> - two numbers of processed sectors and total during synchronization,
> separated with '/';
> - 'none' if synchronization process is stopped;
> - 'delayed' if synchronization process is delayed.
> Handle value of sync_completed not only as numbers but
> also check for 'none' and 'delayed'.
>
> Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
> Reviewed-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
> ---
>  super-intel.c | 36 ++++++++++++++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/super-intel.c b/super-intel.c
> index 7950bef..b401f3c 100644
> --- a/super-intel.c
> +++ b/super-intel.c
> @@ -10363,6 +10363,33 @@ exit_imsm_reshape_super:
>  	return ret_val;
>  }
>  
> +#define COMPLETED_OK		0
> +#define COMPLETED_NONE		1
> +#define COMPLETED_DELAYED	2
> +
> +static int read_completed(int fd, unsigned long long *val)
> +{
> +	int ret;
> +	char buf[50];
> +
> +	ret = sysfs_fd_get_str(fd, buf, 50);
> +	if (ret < 0)
> +		return ret;
> +
> +	ret = COMPLETED_OK;
> +	if (strncmp(buf, "none", 4) == 0) {
> +		ret = COMPLETED_NONE;
> +	} else if (strncmp(buf, "delayed", 7) == 0) {
> +		ret = COMPLETED_DELAYED;
> +	} else {
> +		char *ep;
> +		*val = strtoull(buf, &ep, 0);
> +		if (ep == buf || (*ep != 0 && *ep != '\n' && *ep != ' '))
> +			ret = -1;
> +	}
> +	return ret;
> +}
> +
>  /*******************************************************************************
>   * Function:	wait_for_reshape_imsm
>   * Description:	Function writes new sync_max value and waits until
> @@ -10417,7 +10444,9 @@ int wait_for_reshape_imsm(struct mdinfo *sra, int ndata)
>  	}
>  
>  	do {
> +		int rc;
>  		char action[20];
> +
>  		int timeout = 3000;
>  		sysfs_wait(fd, &timeout);
>  		if (sysfs_get_str(sra, NULL, "sync_action",

Nit - you shouldn't have a blank line between variable declaration, but
rather put it between the declarations and the code itself. I fixed it
up for you.

Applied!

Cheers,
Jes

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-16 17:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-16  9:31 [PATCH 0/2] imsm: add extra handling of sync_action and sync_completed Alexey Obitotskiy
2016-06-16  9:31 ` [PATCH 1/2] imsm: add handling of sync_action is equal to 'idle' Alexey Obitotskiy
2016-06-16 17:59   ` Jes Sorensen
2016-06-16  9:31 ` [PATCH 2/2] imsm: properly handle values of sync_completed Alexey Obitotskiy
2016-06-16 17:59   ` Jes Sorensen

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).