fs: Remove FS_THP_SUPPORT
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sun, 29 Aug 2021 10:07:03 +0000 (06:07 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 17 Nov 2021 15:36:35 +0000 (10:36 -0500)
Instead of setting a bit in the fs_flags to set a bit in the
address_space, set the bit in the address_space directly.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
fs/inode.c
include/linux/fs.h
include/linux/pagemap.h
mm/shmem.c

index 3eba0940ffcf162389ab4ca7fc391b4dc70399bc..6b80a51129d56f4175326e1faf1429e4f730f8b9 100644 (file)
@@ -180,8 +180,6 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
        mapping->a_ops = &empty_aops;
        mapping->host = inode;
        mapping->flags = 0;
-       if (sb->s_type->fs_flags & FS_THP_SUPPORT)
-               __set_bit(AS_THP_SUPPORT, &mapping->flags);
        mapping->wb_err = 0;
        atomic_set(&mapping->i_mmap_writable, 0);
 #ifdef CONFIG_READ_ONLY_THP_FOR_FS
index 1cb616fc11053beda5c7dd6be6da84122a3adc61..bbf812ce89a8c0739cb2e69716183273b69b2573 100644 (file)
@@ -2518,7 +2518,6 @@ struct file_system_type {
 #define FS_USERNS_MOUNT                8       /* Can be mounted by userns root */
 #define FS_DISALLOW_NOTIFY_PERM        16      /* Disable fanotify permission events */
 #define FS_ALLOW_IDMAP         32      /* FS has been updated to handle vfs idmappings. */
-#define FS_THP_SUPPORT         8192    /* Remove once all fs converted */
 #define FS_RENAME_DOES_D_MOVE  32768   /* FS will handle d_move() during rename() internally. */
        int (*init_fs_context)(struct fs_context *);
        const struct fs_parameter_spec *parameters;
index 1a0c646eb6ff7cf34ce2c79a29930c5b5af71201..9e33878bf23b272b1e5e1a6767abd7e89b8487f6 100644 (file)
@@ -176,6 +176,22 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
        m->gfp_mask = mask;
 }
 
+/**
+ * mapping_set_large_folios() - Indicate the file supports large folios.
+ * @mapping: The file.
+ *
+ * The filesystem should call this function in its inode constructor to
+ * indicate that the VFS can use large folios to cache the contents of
+ * the file.
+ *
+ * Context: This should not be called while the inode is active as it
+ * is non-atomic.
+ */
+static inline void mapping_set_large_folios(struct address_space *mapping)
+{
+       __set_bit(AS_THP_SUPPORT, &mapping->flags);
+}
+
 static inline bool mapping_thp_support(struct address_space *mapping)
 {
        return test_bit(AS_THP_SUPPORT, &mapping->flags);
index dc038ce78700ccc3e0c523a3791f36d5b310acbb..18f93c2d68f16e76fb244c12bca5aa0aba6125c6 100644 (file)
@@ -2303,6 +2303,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
                INIT_LIST_HEAD(&info->swaplist);
                simple_xattrs_init(&info->xattrs);
                cache_no_acl(inode);
+               mapping_set_large_folios(inode->i_mapping);
 
                switch (mode & S_IFMT) {
                default:
@@ -3870,7 +3871,7 @@ static struct file_system_type shmem_fs_type = {
        .parameters     = shmem_fs_parameters,
 #endif
        .kill_sb        = kill_litter_super,
-       .fs_flags       = FS_USERNS_MOUNT | FS_THP_SUPPORT,
+       .fs_flags       = FS_USERNS_MOUNT,
 };
 
 int __init shmem_init(void)