Skip to content

Commit 950ee95

Browse files
J. Bruce FieldsAl Viro
authored andcommitted
exportfs: fix 32-bit nfsd handling of 64-bit inode numbers
Symptoms were spurious -ENOENTs on stat of an NFS filesystem from a 32-bit NFS server exporting a very large XFS filesystem, when the server's cache is cold (so the inodes in question are not in cache). Reviewed-by: Christoph Hellwig <hch@lst.de> Reported-by: Trevor Cordes <trevor@tecnopolis.ca> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent b7a6ec5 commit 950ee95

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎fs/exportfs/expfs.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ struct getdents_callback {
215215
struct dir_context ctx;
216216
char *name; /* name that was found. It already points to a
217217
buffer NAME_MAX+1 is size */
218-
unsigned long ino; /* the inum we are looking for */
218+
u64 ino; /* the inum we are looking for */
219219
int found; /* inode matched? */
220220
int sequence; /* sequence counter */
221221
};
@@ -255,10 +255,14 @@ static int get_name(const struct path *path, char *name, struct dentry *child)
255255
struct inode *dir = path->dentry->d_inode;
256256
int error;
257257
struct file *file;
258+
struct kstat stat;
259+
struct path child_path = {
260+
.mnt = path->mnt,
261+
.dentry = child,
262+
};
258263
struct getdents_callback buffer = {
259264
.ctx.actor = filldir_one,
260265
.name = name,
261-
.ino = child->d_inode->i_ino
262266
};
263267

264268
error = -ENOTDIR;
@@ -267,6 +271,16 @@ static int get_name(const struct path *path, char *name, struct dentry *child)
267271
error = -EINVAL;
268272
if (!dir->i_fop)
269273
goto out;
274+
/*
275+
* inode->i_ino is unsigned long, kstat->ino is u64, so the
276+
* former would be insufficient on 32-bit hosts when the
277+
* filesystem supports 64-bit inode numbers. So we need to
278+
* actually call ->getattr, not just read i_ino:
279+
*/
280+
error = vfs_getattr_nosec(&child_path, &stat);
281+
if (error)
282+
return error;
283+
buffer.ino = stat.ino;
270284
/*
271285
* Open the directory ...
272286
*/

0 commit comments

Comments
 (0)