diff options
author | Christoph Hellwig <hch@infradead.org> | 2009-01-01 14:21:16 -0500 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2009-01-08 23:17:17 -0500 |
commit | c9a98553d513dfc82cdce869970d5662c1f22c68 (patch) | |
tree | d68cc98fa807d9f9719cb04307739ab9f9d9b9b5 | |
parent | 9e42d0cf5020aaf217433cad1a224745241d212a (diff) |
[XFS] pass XFS_IGET_BULKSTAT to xfs_iget for handle operations
NFS clients or users of the handle ioctls can pass us arbitrary inode
numbers through the exportfs interface. Make sure we use the
XFS_IGET_BULKSTAT so that these don't cause shutdowns due to the corruption
checks. Also translate the EINVAL we get back for invalid inode clusters
into an ESTALE which is more appropinquate, and remove the useless check
for a NULL inode on a successfull xfs_iget return.
I have a testcase to reproduce this using the handle interface which
I will submit to xfsqa.
Reported-by: Mario Becroft <mb@gem.win.co.nz>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
-rw-r--r-- | fs/xfs/linux-2.6/xfs_export.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c index 595751f78350..87b8cbd23d4b 100644 --- a/fs/xfs/linux-2.6/xfs_export.c +++ b/fs/xfs/linux-2.6/xfs_export.c | |||
@@ -126,11 +126,26 @@ xfs_nfs_get_inode( | |||
126 | if (ino == 0) | 126 | if (ino == 0) |
127 | return ERR_PTR(-ESTALE); | 127 | return ERR_PTR(-ESTALE); |
128 | 128 | ||
129 | error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0); | 129 | /* |
130 | if (error) | 130 | * The XFS_IGET_BULKSTAT means that an invalid inode number is just |
131 | * fine and not an indication of a corrupted filesystem. Because | ||
132 | * clients can send any kind of invalid file handle, e.g. after | ||
133 | * a restore on the server we have to deal with this case gracefully. | ||
134 | */ | ||
135 | error = xfs_iget(mp, NULL, ino, XFS_IGET_BULKSTAT, | ||
136 | XFS_ILOCK_SHARED, &ip, 0); | ||
137 | if (error) { | ||
138 | /* | ||
139 | * EINVAL means the inode cluster doesn't exist anymore. | ||
140 | * This implies the filehandle is stale, so we should | ||
141 | * translate it here. | ||
142 | * We don't use ESTALE directly down the chain to not | ||
143 | * confuse applications using bulkstat that expect EINVAL. | ||
144 | */ | ||
145 | if (error == EINVAL) | ||
146 | error = ESTALE; | ||
131 | return ERR_PTR(-error); | 147 | return ERR_PTR(-error); |
132 | if (!ip) | 148 | } |
133 | return ERR_PTR(-EIO); | ||
134 | 149 | ||
135 | if (ip->i_d.di_gen != generation) { | 150 | if (ip->i_d.di_gen != generation) { |
136 | xfs_iput_new(ip, XFS_ILOCK_SHARED); | 151 | xfs_iput_new(ip, XFS_ILOCK_SHARED); |