xfs: fix xfs_error_get_cfg for negative errnos
authorEric Sandeen <sandeen@redhat.com>
Wed, 20 Jul 2016 00:48:51 +0000 (10:48 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 20 Jul 2016 00:48:51 +0000 (10:48 +1000)
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>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_sysfs.c

index 4c2c5508620819ea4075fe65c1b7390a47246add..79cfd3fc53240da3577608d4f4a04f7cf1f14399 100644 (file)
@@ -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];