aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2018-06-05 13:09:34 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-06-06 11:10:26 -0400
commit29cad0b3edaffb65f78f61b63cb0c43f87f98865 (patch)
treeaec35c16de02a9e42e33d3897b9af57f4883a5f1
parent541b5acc85916343a08f72dde17400cbb165417d (diff)
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 <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>
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c5
-rw-r--r--fs/xfs/xfs_export.c15
2 files changed, 12 insertions, 8 deletions
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index eecf654b4188..88ae2bba755a 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -201,11 +201,6 @@ xfs_imap_to_bp(
201 ASSERT(buf_flags & XBF_TRYLOCK); 201 ASSERT(buf_flags & XBF_TRYLOCK);
202 return error; 202 return error;
203 } 203 }
204
205 if (error == -EFSCORRUPTED &&
206 (iget_flags & XFS_IGET_UNTRUSTED))
207 return -EINVAL;
208
209 xfs_warn(mp, "%s: xfs_trans_read_buf() returned error %d.", 204 xfs_warn(mp, "%s: xfs_trans_read_buf() returned error %d.",
210 __func__, error); 205 __func__, error);
211 return error; 206 return error;
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(
140 */ 140 */
141 error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED, 0, &ip); 141 error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED, 0, &ip);
142 if (error) { 142 if (error) {
143
143 /* 144 /*
144 * EINVAL means the inode cluster doesn't exist anymore. 145 * EINVAL means the inode cluster doesn't exist anymore.
145 * This implies the filehandle is stale, so we should 146 * EFSCORRUPTED means the metadata pointing to the inode cluster
146 * translate it here. 147 * or the inode cluster itself is corrupt. This implies the
148 * filehandle is stale, so we should translate it here.
147 * We don't use ESTALE directly down the chain to not 149 * We don't use ESTALE directly down the chain to not
148 * confuse applications using bulkstat that expect EINVAL. 150 * confuse applications using bulkstat that expect EINVAL.
149 */ 151 */
150 if (error == -EINVAL || error == -ENOENT) 152 switch (error) {
153 case -EINVAL:
154 case -ENOENT:
155 case -EFSCORRUPTED:
151 error = -ESTALE; 156 error = -ESTALE;
157 break;
158 default:
159 break;
160 }
152 return ERR_PTR(error); 161 return ERR_PTR(error);
153 } 162 }
154 163