]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hugetlbfs: Stop using i_private_data
authorJan Kara <jack@suse.cz>
Thu, 26 Mar 2026 09:54:18 +0000 (10:54 +0100)
committerChristian Brauner <brauner@kernel.org>
Thu, 26 Mar 2026 14:03:30 +0000 (15:03 +0100)
Instead of using i_private_data for resv_map pointer add the pointer
into hugetlbfs private part of the inode.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260326095354.16340-66-jack@suse.cz
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/hugetlbfs/inode.c
include/linux/hugetlb.h
mm/hugetlb.c

index 3f70c47981deb536bfa3f766c5ab490b3a826cea..6ad02493adfd6727d45ac7ab54444aa32f6dd2e2 100644 (file)
@@ -622,13 +622,7 @@ static void hugetlbfs_evict_inode(struct inode *inode)
        trace_hugetlbfs_evict_inode(inode);
        remove_inode_hugepages(inode, 0, LLONG_MAX);
 
-       /*
-        * Get the resv_map from the address space embedded in the inode.
-        * This is the address space which points to any resv_map allocated
-        * at inode creation time.  If this is a device special inode,
-        * i_mapping may not point to the original address space.
-        */
-       resv_map = (struct resv_map *)(&inode->i_data)->i_private_data;
+       resv_map = HUGETLBFS_I(inode)->resv_map;
        /* Only regular and link inodes have associated reserve maps */
        if (resv_map)
                resv_map_release(&resv_map->refs);
@@ -907,6 +901,7 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
                simple_inode_init_ts(inode);
                inode->i_op = &hugetlbfs_dir_inode_operations;
                inode->i_fop = &simple_dir_operations;
+               HUGETLBFS_I(inode)->resv_map = NULL;
                /* directory inodes start off with i_nlink == 2 (for "." entry) */
                inc_nlink(inode);
                lockdep_annotate_inode_mutex_key(inode);
@@ -950,7 +945,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
                                &hugetlbfs_i_mmap_rwsem_key);
                inode->i_mapping->a_ops = &hugetlbfs_aops;
                simple_inode_init_ts(inode);
-               inode->i_mapping->i_private_data = resv_map;
+               info->resv_map = resv_map;
                info->seals = F_SEAL_SEAL;
                switch (mode & S_IFMT) {
                default:
index 65910437be1ca3964e5e8c6745d197d16612c2a3..fc5462fe943f11e532f730435dbf0cb8824268d0 100644 (file)
@@ -518,6 +518,7 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
 
 struct hugetlbfs_inode_info {
        struct inode vfs_inode;
+       struct resv_map *resv_map;
        unsigned int seals;
 };
 
index 0beb6e22bc26914b2be29e4bbcd578023218293f..7ab5c724a7118edf54e0ee64c734d8b57d3fa296 100644 (file)
@@ -1157,15 +1157,7 @@ void resv_map_release(struct kref *ref)
 
 static inline struct resv_map *inode_resv_map(struct inode *inode)
 {
-       /*
-        * At inode evict time, i_mapping may not point to the original
-        * address space within the inode.  This original address space
-        * contains the pointer to the resv_map.  So, always use the
-        * address space embedded within the inode.
-        * The VERY common case is inode->mapping == &inode->i_data but,
-        * this may not be true for device special inodes.
-        */
-       return (struct resv_map *)(&inode->i_data)->i_private_data;
+       return HUGETLBFS_I(inode)->resv_map;
 }
 
 static struct resv_map *vma_resv_map(struct vm_area_struct *vma)