diff mbox

xfs: fix xfs_error_get_cfg for negative errnos

Message ID 9810c6bf-9fd7-bf41-13ab-a96bec861457@redhat.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Eric Sandeen July 8, 2016, 7:32 p.m. UTC
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 :)

Comments

Carlos Maiolino July 19, 2016, 7:52 a.m. UTC | #1
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
diff mbox

Patch

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];