linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: fix xfs_error_get_cfg for negative errnos
@ 2016-07-08 19:32 Eric Sandeen
  2016-07-09  4:26 ` [PATCH 2/1] " Eric Sandeen
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Eric Sandeen @ 2016-07-08 19:32 UTC (permalink / raw)
  To: xfs-oss

xfs_error_get_cfg() is called with bp->b_error as an arg,
which is negative, so the switch statement won't ever find
any matches.

This results in only the default error handler having
any effect, as EIO/ENOSPC/ENODEV get ignored due to the
wrong sign.

It seems simplest to always flip the error sign to positive,
so that we can handle either negative errors in bp->b_error,
or possibly a positive errno via something like
xfs_error_get_cfg(EIO) - this future-proofs the function.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

I'm still chasing down some odd behaviors in the error handling
patches but this seems worth sending now :)

diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 4c2c550..79cfd3f 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -634,6 +634,9 @@ xfs_error_get_cfg(
 {
 	struct xfs_error_cfg	*cfg;
 
+	if (error < 0)
+		error = -error;
+
 	switch (error) {
 	case EIO:
 		cfg = &mp->m_error_cfg[error_class][XFS_ERR_EIO];

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 2/1] xfs: fix xfs_error_get_cfg for negative errnos
  2016-07-08 19:32 [PATCH] xfs: fix xfs_error_get_cfg for negative errnos Eric Sandeen
@ 2016-07-09  4:26 ` Eric Sandeen
  2016-07-09  4:28 ` [PATCH 2/1 V2] xfs: remove extraneous buffer flag changes Eric Sandeen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Eric Sandeen @ 2016-07-09  4:26 UTC (permalink / raw)
  To: xfs

Fix up a couple places where flag manipulation is unclear.

In the first case we clear XBF_ASYNC and then immediately
reset it.

In the 2nd case we are at a point in the function where the
buffer must already be async, so no need to reset it.

Add consistent spacing around the " | " while we're at it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index e71cfbd..5d52e44 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1816,7 +1816,7 @@ __xfs_buf_delwri_submit(
 
 	blk_start_plug(&plug);
 	list_for_each_entry_safe(bp, n, io_list, b_list) {
-		bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC | XBF_WRITE_FAIL);
+		bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_WRITE_FAIL);
 		bp->b_flags |= XBF_WRITE | XBF_ASYNC;
 
 		/*
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 3425799..6a2f429 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -1080,10 +1080,9 @@ xfs_buf_iodone_callback_error(
 	 * async write failure at least once, but we also need to set the buffer
 	 * up to behave correctly now for repeated failures.
 	 */
-	if (!(bp->b_flags & (XBF_STALE|XBF_WRITE_FAIL)) ||
+	if (!(bp->b_flags & (XBF_STALE | XBF_WRITE_FAIL)) ||
 	     bp->b_last_error != bp->b_error) {
-		bp->b_flags |= (XBF_WRITE | XBF_ASYNC |
-			        XBF_DONE | XBF_WRITE_FAIL);
+		bp->b_flags |= (XBF_WRITE | XBF_DONE | XBF_WRITE_FAIL);
 		bp->b_last_error = bp->b_error;
 		bp->b_retries = 0;
 		bp->b_first_retry_time = jiffies;

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 2/1 V2] xfs: remove extraneous buffer flag changes
  2016-07-08 19:32 [PATCH] xfs: fix xfs_error_get_cfg for negative errnos Eric Sandeen
  2016-07-09  4:26 ` [PATCH 2/1] " Eric Sandeen
@ 2016-07-09  4:28 ` Eric Sandeen
  2016-07-19  7:57   ` Carlos Maiolino
  2016-07-09  4:33 ` [PATCH 3/1] xfs: don't reset b_retries to 0 on every failure Eric Sandeen
  2016-07-19  7:52 ` [PATCH] xfs: fix xfs_error_get_cfg for negative errnos Carlos Maiolino
  3 siblings, 1 reply; 7+ messages in thread
From: Eric Sandeen @ 2016-07-09  4:28 UTC (permalink / raw)
  To: xfs

Fix up a couple places where extra flag manipulation occurs.

In the first case we clear XBF_ASYNC and then immediately
reset it - so don't bother clearing in the first place.

In the 2nd case we are at a point in the function where the
buffer must already be async, so there is no need to reset it.

Add consistent spacing around the " | " while we're at it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

V2: fix subject, sorry!

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index e71cfbd..5d52e44 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1816,7 +1816,7 @@ __xfs_buf_delwri_submit(
 
 	blk_start_plug(&plug);
 	list_for_each_entry_safe(bp, n, io_list, b_list) {
-		bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC | XBF_WRITE_FAIL);
+		bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_WRITE_FAIL);
 		bp->b_flags |= XBF_WRITE | XBF_ASYNC;
 
 		/*
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 3425799..6a2f429 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -1080,10 +1080,9 @@ xfs_buf_iodone_callback_error(
 	 * async write failure at least once, but we also need to set the buffer
 	 * up to behave correctly now for repeated failures.
 	 */
-	if (!(bp->b_flags & (XBF_STALE|XBF_WRITE_FAIL)) ||
+	if (!(bp->b_flags & (XBF_STALE | XBF_WRITE_FAIL)) ||
 	     bp->b_last_error != bp->b_error) {
-		bp->b_flags |= (XBF_WRITE | XBF_ASYNC |
-			        XBF_DONE | XBF_WRITE_FAIL);
+		bp->b_flags |= (XBF_WRITE | XBF_DONE | XBF_WRITE_FAIL);
 		bp->b_last_error = bp->b_error;
 		bp->b_retries = 0;
 		bp->b_first_retry_time = jiffies;

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 3/1] xfs: don't reset b_retries to 0 on every failure
  2016-07-08 19:32 [PATCH] xfs: fix xfs_error_get_cfg for negative errnos Eric Sandeen
  2016-07-09  4:26 ` [PATCH 2/1] " Eric Sandeen
  2016-07-09  4:28 ` [PATCH 2/1 V2] xfs: remove extraneous buffer flag changes Eric Sandeen
@ 2016-07-09  4:33 ` Eric Sandeen
  2016-07-19  7:42   ` Carlos Maiolino
  2016-07-19  7:52 ` [PATCH] xfs: fix xfs_error_get_cfg for negative errnos Carlos Maiolino
  3 siblings, 1 reply; 7+ messages in thread
From: Eric Sandeen @ 2016-07-09  4:33 UTC (permalink / raw)
  To: xfs

With the code as it stands today, b_retries never increments
because it gets reset to 0 in the error callback.

Remove that, and fix a similar problem where the first retry
time was constantly being overwritten, which defeated the
timeout tunable as well.

We now only set first retry time if a non-zero timeout is
set, to match the behavior of only incrementing retries if
a retry value is set.

This way max retries & timeouts consistently take effect after
a tunable is set, rather than acting retroactively on a buffer
which has failed at some point in the past and has accumulated
state from those prior failures.

Thanks to dchinner for talking through this with me.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 6a2f429..3b19e52 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -1073,6 +1073,8 @@ xfs_buf_iodone_callback_error(
 	trace_xfs_buf_item_iodone_async(bp, _RET_IP_);
 	ASSERT(bp->b_iodone != NULL);
 
+	cfg = xfs_error_get_cfg(mp, XFS_ERR_METADATA, bp->b_error);
+
 	/*
 	 * If the write was asynchronous then no one will be looking for the
 	 * error.  If this is the first failure of this type, clear the error
@@ -1084,8 +1086,8 @@ xfs_buf_iodone_callback_error(
 	     bp->b_last_error != bp->b_error) {
 		bp->b_flags |= (XBF_WRITE | XBF_DONE | XBF_WRITE_FAIL);
 		bp->b_last_error = bp->b_error;
-		bp->b_retries = 0;
-		bp->b_first_retry_time = jiffies;
+		if (cfg->retry_timeout && !bp->b_first_retry_time)
+			bp->b_first_retry_time = jiffies;
 
 		xfs_buf_ioerror(bp, 0);
 		xfs_buf_submit(bp);
@@ -1096,7 +1098,6 @@ xfs_buf_iodone_callback_error(
 	 * Repeated failure on an async write. Take action according to the
 	 * error configuration we have been set up to use.
 	 */
-	cfg = xfs_error_get_cfg(mp, XFS_ERR_METADATA, bp->b_error);
 
 	if (cfg->max_retries != XFS_ERR_RETRY_FOREVER &&
 	    ++bp->b_retries > cfg->max_retries)


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 3/1] xfs: don't reset b_retries to 0 on every failure
  2016-07-09  4:33 ` [PATCH 3/1] xfs: don't reset b_retries to 0 on every failure Eric Sandeen
@ 2016-07-19  7:42   ` Carlos Maiolino
  0 siblings, 0 replies; 7+ messages in thread
From: Carlos Maiolino @ 2016-07-19  7:42 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

On Fri, Jul 08, 2016 at 11:33:23PM -0500, Eric Sandeen wrote:
> With the code as it stands today, b_retries never increments
> because it gets reset to 0 in the error callback.
> 
> Remove that, and fix a similar problem where the first retry
> time was constantly being overwritten, which defeated the
> timeout tunable as well.
> 
> We now only set first retry time if a non-zero timeout is
> set, to match the behavior of only incrementing retries if
> a retry value is set.
> 
> This way max retries & timeouts consistently take effect after
> a tunable is set, rather than acting retroactively on a buffer
> which has failed at some point in the past and has accumulated
> state from those prior failures.
> 
> Thanks to dchinner for talking through this with me.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

This patch looks good, thanks Eric :)

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> ---
> 
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index 6a2f429..3b19e52 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -1073,6 +1073,8 @@ xfs_buf_iodone_callback_error(
>  	trace_xfs_buf_item_iodone_async(bp, _RET_IP_);
>  	ASSERT(bp->b_iodone != NULL);
>  
> +	cfg = xfs_error_get_cfg(mp, XFS_ERR_METADATA, bp->b_error);
> +
>  	/*
>  	 * If the write was asynchronous then no one will be looking for the
>  	 * error.  If this is the first failure of this type, clear the error
> @@ -1084,8 +1086,8 @@ xfs_buf_iodone_callback_error(
>  	     bp->b_last_error != bp->b_error) {
>  		bp->b_flags |= (XBF_WRITE | XBF_DONE | XBF_WRITE_FAIL);
>  		bp->b_last_error = bp->b_error;
> -		bp->b_retries = 0;
> -		bp->b_first_retry_time = jiffies;
> +		if (cfg->retry_timeout && !bp->b_first_retry_time)
> +			bp->b_first_retry_time = jiffies;
>  
>  		xfs_buf_ioerror(bp, 0);
>  		xfs_buf_submit(bp);
> @@ -1096,7 +1098,6 @@ xfs_buf_iodone_callback_error(
>  	 * Repeated failure on an async write. Take action according to the
>  	 * error configuration we have been set up to use.
>  	 */
> -	cfg = xfs_error_get_cfg(mp, XFS_ERR_METADATA, bp->b_error);
>  
>  	if (cfg->max_retries != XFS_ERR_RETRY_FOREVER &&
>  	    ++bp->b_retries > cfg->max_retries)
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

-- 
Carlos

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] xfs: fix xfs_error_get_cfg for negative errnos
  2016-07-08 19:32 [PATCH] xfs: fix xfs_error_get_cfg for negative errnos Eric Sandeen
                   ` (2 preceding siblings ...)
  2016-07-09  4:33 ` [PATCH 3/1] xfs: don't reset b_retries to 0 on every failure Eric Sandeen
@ 2016-07-19  7:52 ` Carlos Maiolino
  3 siblings, 0 replies; 7+ messages in thread
From: Carlos Maiolino @ 2016-07-19  7:52 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

On Fri, Jul 08, 2016 at 02:32:17PM -0500, Eric Sandeen wrote:
> xfs_error_get_cfg() is called with bp->b_error as an arg,
> which is negative, so the switch statement won't ever find
> any matches.
> 
> This results in only the default error handler having
> any effect, as EIO/ENOSPC/ENODEV get ignored due to the
> wrong sign.
> 
> It seems simplest to always flip the error sign to positive,
> so that we can handle either negative errors in bp->b_error,
> or possibly a positive errno via something like
> xfs_error_get_cfg(EIO) - this future-proofs the function.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

This looks the right thing to do for me too.

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> ---
> 
> I'm still chasing down some odd behaviors in the error handling
> patches but this seems worth sending now :)
> 
> diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
> index 4c2c550..79cfd3f 100644
> --- a/fs/xfs/xfs_sysfs.c
> +++ b/fs/xfs/xfs_sysfs.c
> @@ -634,6 +634,9 @@ xfs_error_get_cfg(
>  {
>  	struct xfs_error_cfg	*cfg;
>  
> +	if (error < 0)
> +		error = -error;
> +
>  	switch (error) {
>  	case EIO:
>  		cfg = &mp->m_error_cfg[error_class][XFS_ERR_EIO];
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

-- 
Carlos

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 2/1 V2] xfs: remove extraneous buffer flag changes
  2016-07-09  4:28 ` [PATCH 2/1 V2] xfs: remove extraneous buffer flag changes Eric Sandeen
@ 2016-07-19  7:57   ` Carlos Maiolino
  0 siblings, 0 replies; 7+ messages in thread
From: Carlos Maiolino @ 2016-07-19  7:57 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

On Fri, Jul 08, 2016 at 11:28:02PM -0500, Eric Sandeen wrote:
> Fix up a couple places where extra flag manipulation occurs.
> 
> In the first case we clear XBF_ASYNC and then immediately
> reset it - so don't bother clearing in the first place.
> 
> In the 2nd case we are at a point in the function where the
> buffer must already be async, so there is no need to reset it.
> 
> Add consistent spacing around the " | " while we're at it.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

This makes sense too.

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> ---
> 
> V2: fix subject, sorry!
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index e71cfbd..5d52e44 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -1816,7 +1816,7 @@ __xfs_buf_delwri_submit(
>  
>  	blk_start_plug(&plug);
>  	list_for_each_entry_safe(bp, n, io_list, b_list) {
> -		bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC | XBF_WRITE_FAIL);
> +		bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_WRITE_FAIL);
>  		bp->b_flags |= XBF_WRITE | XBF_ASYNC;
>  
>  		/*
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index 3425799..6a2f429 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -1080,10 +1080,9 @@ xfs_buf_iodone_callback_error(
>  	 * async write failure at least once, but we also need to set the buffer
>  	 * up to behave correctly now for repeated failures.
>  	 */
> -	if (!(bp->b_flags & (XBF_STALE|XBF_WRITE_FAIL)) ||
> +	if (!(bp->b_flags & (XBF_STALE | XBF_WRITE_FAIL)) ||
>  	     bp->b_last_error != bp->b_error) {
> -		bp->b_flags |= (XBF_WRITE | XBF_ASYNC |
> -			        XBF_DONE | XBF_WRITE_FAIL);
> +		bp->b_flags |= (XBF_WRITE | XBF_DONE | XBF_WRITE_FAIL);
>  		bp->b_last_error = bp->b_error;
>  		bp->b_retries = 0;
>  		bp->b_first_retry_time = jiffies;
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

-- 
Carlos

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2016-07-19  7:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-08 19:32 [PATCH] xfs: fix xfs_error_get_cfg for negative errnos Eric Sandeen
2016-07-09  4:26 ` [PATCH 2/1] " Eric Sandeen
2016-07-09  4:28 ` [PATCH 2/1 V2] xfs: remove extraneous buffer flag changes Eric Sandeen
2016-07-19  7:57   ` Carlos Maiolino
2016-07-09  4:33 ` [PATCH 3/1] xfs: don't reset b_retries to 0 on every failure Eric Sandeen
2016-07-19  7:42   ` Carlos Maiolino
2016-07-19  7:52 ` [PATCH] xfs: fix xfs_error_get_cfg for negative errnos Carlos Maiolino

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