]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nfs: store the full NFS fileid in inode->i_ino
authorJeff Layton <jlayton@kernel.org>
Tue, 12 May 2026 16:12:42 +0000 (12:12 -0400)
committerAnna Schumaker <anna.schumaker@hammerspace.com>
Mon, 8 Jun 2026 14:21:54 +0000 (10:21 -0400)
Now that inode->i_ino is a 64-bit value, store the full NFS fileid in
it directly instead of an XOR-folded hash. This makes NFS_FILEID() and
set_nfs_fileid() operate on inode->i_ino rather than the separate
nfsi->fileid field.

Since iget5_locked() and ilookup5() now accept a u64 hashval, pass the
full fileid as the hash parameter directly.

Convert direct nfsi->fileid accesses in nfs_check_inode_attributes(),
nfs_update_inode(), and nfs_same_file() to use inode->i_ino.

Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
fs/nfs/dir.c
fs/nfs/inode.c
include/linux/nfs_fs.h

index e9ce1883288c55bbf24671c1e4bd1a61a694ae3f..5f8c3ea0bce37341c713e24a922e6f244738a98d 100644 (file)
@@ -650,7 +650,7 @@ int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry)
                return 0;
 
        nfsi = NFS_I(inode);
-       if (entry->fattr->fileid != nfsi->fileid)
+       if (entry->fattr->fileid != inode->i_ino)
                return 0;
        if (entry->fh->size && nfs_compare_fh(entry->fh, &nfsi->fh) != 0)
                return 0;
index e26030e736966b4df4052ee32364b778680e3919..dd9e378c36fb2b4caff413c8f5534fb1fd2a0d75 100644 (file)
@@ -66,10 +66,10 @@ static int nfs_update_inode(struct inode *, struct nfs_fattr *);
 
 static struct kmem_cache * nfs_inode_cachep;
 
-static inline unsigned long
+static inline u64
 nfs_fattr_to_ino_t(struct nfs_fattr *fattr)
 {
-       return nfs_fileid_to_ino_t(fattr->fileid);
+       return fattr->fileid;
 }
 
 int nfs_wait_bit_killable(struct wait_bit_key *key, int mode)
@@ -313,8 +313,7 @@ struct nfs_find_desc {
 };
 
 /*
- * In NFSv3 we can have 64bit inode numbers. In order to support
- * this, and re-exported directories (also seen in NFSv2)
+ * For re-exported directories (also seen in NFSv2)
  * we are forced to allow 2 different inodes to have the same
  * i_ino.
  */
@@ -413,7 +412,7 @@ nfs_ilookup(struct super_block *sb, struct nfs_fattr *fattr, struct nfs_fh *fh)
                .fattr  = fattr,
        };
        struct inode *inode;
-       unsigned long hash;
+       u64 hash;
 
        if (!(fattr->valid & NFS_ATTR_FATTR_FILEID) ||
            !(fattr->valid & NFS_ATTR_FATTR_TYPE))
@@ -456,7 +455,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
        };
        struct inode *inode = ERR_PTR(-ENOENT);
        u64 fattr_supported = NFS_SB(sb)->fattr_valid;
-       unsigned long hash;
+       u64 hash;
 
        nfs_attr_check_mountpoint(sb, fattr);
 
@@ -479,10 +478,6 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
                struct nfs_inode *nfsi = NFS_I(inode);
                unsigned long now = jiffies;
 
-               /* We set i_ino for the few things that still rely on it,
-                * such as stat(2) */
-               inode->i_ino = hash;
-
                /* We can't support update_atime(), since the server will reset it */
                inode->i_flags |= S_NOATIME|S_NOCMTIME;
                inode->i_mode = fattr->mode;
@@ -1672,10 +1667,10 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
                if (fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)
                        return 0;
        /* Has the inode gone and changed behind our back? */
-       } else if (nfsi->fileid != fattr->fileid) {
+       } else if (inode->i_ino != fattr->fileid) {
                /* Is this perhaps the mounted-on fileid? */
                if ((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) &&
-                   nfsi->fileid == fattr->mounted_on_fileid)
+                   inode->i_ino == fattr->mounted_on_fileid)
                        return 0;
                return -ESTALE;
        }
@@ -2262,15 +2257,15 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
                if (fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)
                        return 0;
        /* Has the inode gone and changed behind our back? */
-       } else if (nfsi->fileid != fattr->fileid) {
+       } else if (inode->i_ino != fattr->fileid) {
                /* Is this perhaps the mounted-on fileid? */
                if ((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) &&
-                   nfsi->fileid == fattr->mounted_on_fileid)
+                   inode->i_ino == fattr->mounted_on_fileid)
                        return 0;
                printk(KERN_ERR "NFS: server %s error: fileid changed\n"
                        "fsid %s: expected fileid 0x%Lx, got 0x%Lx\n",
                        NFS_SERVER(inode)->nfs_client->cl_hostname,
-                       inode->i_sb->s_id, (long long)nfsi->fileid,
+                       inode->i_sb->s_id, (long long)inode->i_ino,
                        (long long)fattr->fileid);
                goto out_err;
        }
index 4623262da3c09ebcffb20dc6c53ac53288dadd30..8e48053b3069dbbb3afe0eb9a2b5c315b9ac06fe 100644 (file)
@@ -396,12 +396,12 @@ static inline int NFS_STALE(const struct inode *inode)
 
 static inline __u64 NFS_FILEID(const struct inode *inode)
 {
-       return NFS_I(inode)->fileid;
+       return inode->i_ino;
 }
 
 static inline void set_nfs_fileid(struct inode *inode, __u64 fileid)
 {
-       NFS_I(inode)->fileid = fileid;
+       inode->i_ino = fileid;
 }
 
 static inline void nfs_mark_for_revalidate(struct inode *inode)