From 29cad0b3edaffb65f78f61b63cb0c43f87f98865 Mon Sep 17 00:00:00 2001 From: Dave Chinner Date: Tue, 5 Jun 2018 10:09:34 -0700 Subject: xfs: push corruption -> ESTALE conversion to xfs_nfs_get_inode() 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 Reviewed-by: Carlos Maiolino Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_export.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'fs/xfs/xfs_export.c') diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c index eed698aa9f16..af540b41ea75 100644 --- a/fs/xfs/xfs_export.c +++ b/fs/xfs/xfs_export.c @@ -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); } -- cgit v1.2.3