diff mbox series

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

Message ID 20200515131656.12890-8-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Large pages in the page cache | expand

Commit Message

Matthew Wilcox May 15, 2020, 1:16 p.m. UTC
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

The page cache needs to know whether the filesystem supports pages >
PAGE_SIZE.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/fs.h      | 1 +
 include/linux/pagemap.h | 5 +++++
 2 files changed, 6 insertions(+)

Comments

Dave Chinner May 21, 2020, 9:55 p.m. UTC | #1
On Fri, May 15, 2020 at 06:16:27AM -0700, Matthew Wilcox wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> 
> The page cache needs to know whether the filesystem supports pages >
> PAGE_SIZE.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  include/linux/fs.h      | 1 +
>  include/linux/pagemap.h | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 55c743925c40..777783c8760b 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2241,6 +2241,7 @@ struct file_system_type {
>  #define FS_HAS_SUBTYPE		4
>  #define FS_USERNS_MOUNT		8	/* Can be mounted by userns root */
>  #define FS_DISALLOW_NOTIFY_PERM	16	/* Disable fanotify permission events */
> +#define FS_LARGE_PAGES		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;
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 36bfc9d855bb..c6db74b5e62f 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -116,6 +116,11 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
>  	m->gfp_mask = mask;
>  }
>  
> +static inline bool mapping_large_pages(struct address_space *mapping)
> +{
> +	return mapping->host->i_sb->s_type->fs_flags & FS_LARGE_PAGES;
> +}

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?

Cheers,

Dave.
Matthew Wilcox May 21, 2020, 11:29 p.m. UTC | #2
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)
diff mbox series

Patch

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 55c743925c40..777783c8760b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2241,6 +2241,7 @@  struct file_system_type {
 #define FS_HAS_SUBTYPE		4
 #define FS_USERNS_MOUNT		8	/* Can be mounted by userns root */
 #define FS_DISALLOW_NOTIFY_PERM	16	/* Disable fanotify permission events */
+#define FS_LARGE_PAGES		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;
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 36bfc9d855bb..c6db74b5e62f 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -116,6 +116,11 @@  static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
 	m->gfp_mask = mask;
 }
 
+static inline bool mapping_large_pages(struct address_space *mapping)
+{
+	return mapping->host->i_sb->s_type->fs_flags & FS_LARGE_PAGES;
+}
+
 void release_pages(struct page **pages, int nr);
 
 /*