Add a new flag SB_I_NO_PAGECACHE for superblock. Skip scanning the inode lists of filesystems that have no page cache in drop_pagecache_sb(), as indicated by the SB_I_NO_PAGECACHE flag. This patch only changes the procfs. Signed-off-by: Huang Shijie --- fs/drop_caches.c | 3 +++ fs/proc/root.c | 2 +- include/linux/fs/super_types.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 49f56a598ecb..27caf748b3c5 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -20,6 +20,9 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) { struct inode *inode, *toput_inode = NULL; + if (sb->s_iflags & SB_I_NO_PAGECACHE) + return; + spin_lock(&sb->s_inode_list_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { spin_lock(&inode->i_lock); diff --git a/fs/proc/root.c b/fs/proc/root.c index 99adddfeb4a4..d45f5af5ab53 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -266,7 +266,7 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc) return ret; /* User space would break if executables or devices appear on proc */ - s->s_iflags |= SB_I_NOEXEC | SB_I_NODEV; + s->s_iflags |= SB_I_NOEXEC | SB_I_NODEV | SB_I_NO_PAGECACHE; s->s_flags |= SB_NODIRATIME | SB_NOSUID | SB_NOEXEC; s->s_blocksize = 1024; s->s_blocksize_bits = 10; diff --git a/include/linux/fs/super_types.h b/include/linux/fs/super_types.h index ecd96aeb1cee..1a596caf58a8 100644 --- a/include/linux/fs/super_types.h +++ b/include/linux/fs/super_types.h @@ -352,5 +352,6 @@ struct super_block { #define SB_I_NOIDMAP 0x00002000 /* No idmapped mounts on this superblock */ #define SB_I_ALLOW_HSM 0x00004000 /* Allow HSM events on this superblock */ #define SB_I_NO_DATA_INTEGRITY 0x00008000 /* fs cannot guarantee data persistence on sync */ +#define SB_I_NO_PAGECACHE 0x00010000 /* this file system has no page cache */ #endif /* _LINUX_FS_SUPER_TYPES_H */ -- 2.53.0