Re: [PATCH v4 07/36] fs: Add a filesystem flag for large pages

From: Matthew Wilcox
Date: Thu May 21 2020 - 19:29:11 EST


On Fri, May 22, 2020 at 07:55:23AM +1000, Dave Chinner wrote:
> If you've got to dereference 4 layers deep to check a behaviour
> flag, the object needs it's own flag. Can you just propagate this
> to the address space when the inode is instantiated and the address
> space initialised?

Sure. I'll fold in something like this:

+++ b/fs/inode.c
@@ -181,6 +181,8 @@ 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_LARGE_PAGES)
+ __set_bit(AS_LARGE_PAGES, &mapping->flags);
mapping->wb_err = 0;
atomic_set(&mapping->i_mmap_writable, 0);
#ifdef CONFIG_READ_ONLY_THP_FOR_FS
+++ b/include/linux/pagemap.h
@@ -29,6 +29,7 @@ enum mapping_flags {
AS_EXITING = 4, /* final truncate in progress */
/* writeback related tags are not used */
AS_NO_WRITEBACK_TAGS = 5,
+ AS_LARGE_PAGES = 6, /* large pages supported */
};

/**
@@ -118,7 +119,7 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)

static inline bool mapping_large_pages(struct address_space *mapping)
{
- return mapping->host->i_sb->s_type->fs_flags & FS_LARGE_PAGES;
+ return test_bit(AS_LARGE_PAGES, &mapping->flags);
}

static inline int filemap_nr_thps(struct address_space *mapping)