xfs: push corruption -> ESTALE conversion to xfs_nfs_get_inode()
authorDave Chinner <dchinner@redhat.com>
Tue, 5 Jun 2018 17:09:34 +0000 (10:09 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 6 Jun 2018 15:10:26 +0000 (08:10 -0700)
In xfs_imap_to_bp(), we convert a -EFSCORRUPTED error to -EINVAL if
we are doing an untrusted lookup. This is done because we need
failed filehandle lookups to report -ESTALE to the caller, and it
does this by converting -EINVAL and -ENOENT errors to -ESTALE.

The squashing of EFSCORRUPTED in imap_to_bp makes it impossible for
for xfs_iget(UNTRUSTED) callers to determine the difference between
"inode does not exist" and "corruption detected during lookup". We
realy need that distinction in places calling xfS_iget(UNTRUSTED),
so move the filehandle error case handling all the way out to
xfs_nfs_get_inode() where it is needed.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/libxfs/xfs_inode_buf.c
fs/xfs/xfs_export.c

index eecf654b418865034fc1b4f6a0afb50647475bf4..88ae2bba755a883f012ee2ae7770ca8e994da158 100644 (file)
@@ -201,11 +201,6 @@ xfs_imap_to_bp(
                        ASSERT(buf_flags & XBF_TRYLOCK);
                        return error;
                }
-
-               if (error == -EFSCORRUPTED &&
-                   (iget_flags & XFS_IGET_UNTRUSTED))
-                       return -EINVAL;
-
                xfs_warn(mp, "%s: xfs_trans_read_buf() returned error %d.",
                        __func__, error);
                return error;
index eed698aa9f165e5ffa4b4b01edf025ea12b4189e..af540b41ea7570b0d91ebe62162ad2ab68dc85aa 100644 (file)
@@ -140,15 +140,24 @@ xfs_nfs_get_inode(
         */
        error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED, 0, &ip);
        if (error) {
+
                /*
                 * EINVAL means the inode cluster doesn't exist anymore.
-                * This implies the filehandle is stale, so we should
-                * translate it here.
+                * EFSCORRUPTED means the metadata pointing to the inode cluster
+                * or the inode cluster itself is corrupt.  This implies the
+                * filehandle is stale, so we should translate it here.
                 * We don't use ESTALE directly down the chain to not
                 * confuse applications using bulkstat that expect EINVAL.
                 */
-               if (error == -EINVAL || error == -ENOENT)
+               switch (error) {
+               case -EINVAL:
+               case -ENOENT:
+               case -EFSCORRUPTED:
                        error = -ESTALE;
+                       break;
+               default:
+                       break;
+               }
                return ERR_PTR(error);
        }