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.
Unified · Split
| @@ -180,8 +180,6 @@ int inode_init_always(struct super_block *sb, struct inode *inode) · 179 unmodified lines | |||
| 180 | mapping->a_ops = &empty_aops; | 180 | mapping->a_ops = &empty_aops; |
| 181 | mapping->host = inode; | 181 | mapping->host = inode; |
| 182 | mapping->flags = 0; | 182 | mapping->flags = 0; |
| 183 | if (sb->s_type->fs_flags & FS_THP_SUPPORT) | ||
| 184 | __set_bit(AS_THP_SUPPORT, &mapping->flags); | ||
| 185 | mapping->wb_err = 0; | 183 | mapping->wb_err = 0; |
| 186 | atomic_set(&mapping->i_mmap_writable, 0); | 184 | atomic_set(&mapping->i_mmap_writable, 0); |
| 187 | #ifdef CONFIG_READ_ONLY_THP_FOR_FS | 185 | #ifdef CONFIG_READ_ONLY_THP_FOR_FS |
| @@ -2518,7 +2518,6 @@ struct file_system_type { · 2517 unmodified lines | |||
| 2518 | #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ | 2518 | #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ |
| 2519 | #define FS_DISALLOW_NOTIFY_PERM 16 /* Disable fanotify permission events */ | 2519 | #define FS_DISALLOW_NOTIFY_PERM 16 /* Disable fanotify permission events */ |
| 2520 | #define FS_ALLOW_IDMAP 32 /* FS has been updated to handle vfs idmappings. */ | 2520 | #define FS_ALLOW_IDMAP 32 /* FS has been updated to handle vfs idmappings. */ |
| 2521 | #define FS_THP_SUPPORT 8192 /* Remove once all fs converted */ | ||
| 2522 | #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ | 2521 | #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ |
| 2523 | int (*init_fs_context)(struct fs_context *); | 2522 | int (*init_fs_context)(struct fs_context *); |
| 2524 | const struct fs_parameter_spec *parameters; | 2523 | const struct fs_parameter_spec *parameters; |
| @@ -176,6 +176,22 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) · 175 unmodified lines | |||
| 176 | m->gfp_mask = mask; | 176 | m->gfp_mask = mask; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | /** | ||
| 180 | * mapping_set_large_folios() - Indicate the file supports large folios. | ||
| 181 | * @mapping: The file. | ||
| 182 | * | ||
| 183 | * The filesystem should call this function in its inode constructor to | ||
| 184 | * indicate that the VFS can use large folios to cache the contents of | ||
| 185 | * the file. | ||
| 186 | * | ||
| 187 | * Context: This should not be called while the inode is active as it | ||
| 188 | * is non-atomic. | ||
| 189 | */ | ||
| 190 | static inline void mapping_set_large_folios(struct address_space *mapping) | ||
| 191 | { | ||
| 192 | __set_bit(AS_THP_SUPPORT, &mapping->flags); | ||
| 193 | } | ||
| 194 | |||
| 179 | static inline bool mapping_thp_support(struct address_space *mapping) | 195 | static inline bool mapping_thp_support(struct address_space *mapping) |
| 180 | { | 196 | { |
| 181 | return test_bit(AS_THP_SUPPORT, &mapping->flags); | 197 | return test_bit(AS_THP_SUPPORT, &mapping->flags); |
| @@ -2303,6 +2303,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode · 2302 unmodified lines | |||
| 2303 | INIT_LIST_HEAD(&info->swaplist); | 2303 | INIT_LIST_HEAD(&info->swaplist); |
| 2304 | simple_xattrs_init(&info->xattrs); | 2304 | simple_xattrs_init(&info->xattrs); |
| 2305 | cache_no_acl(inode); | 2305 | cache_no_acl(inode); |
| 2306 | mapping_set_large_folios(inode->i_mapping); | ||
| 2306 | 2307 | ||
| 2307 | switch (mode & S_IFMT) { | 2308 | switch (mode & S_IFMT) { |
| 2308 | default: | 2309 | default: |
| @@ -3870,7 +3871,7 @@ static struct file_system_type shmem_fs_type = { · 1561 unmodified lines | |||
| 3870 | .parameters = shmem_fs_parameters, | 3871 | .parameters = shmem_fs_parameters, |
| 3871 | #endif | 3872 | #endif |
| 3872 | .kill_sb = kill_litter_super, | 3873 | .kill_sb = kill_litter_super, |
| 3873 | .fs_flags = FS_USERNS_MOUNT | FS_THP_SUPPORT, | 3874 | .fs_flags = FS_USERNS_MOUNT, |
| 3874 | }; | 3875 | }; |
| 3875 | 3876 | ||
| 3876 | int __init shmem_init(void) | 3877 | int __init shmem_init(void) |