From: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx> There are some workloads where READ_PLUS might end up hurting performance, so let's be nice to users and provide a way to disable this operation similar to how READDIR_PLUS can be disabled. Signed-off-by: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx> --- fs/nfs/nfs4client.c | 3 +++ fs/nfs/super.c | 21 +++++++++++++++++++++ include/linux/nfs4.h | 4 ++-- include/linux/nfs_fs_sb.h | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 2548405da1f7..2bb603d1a80f 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -998,6 +998,9 @@ static int nfs4_server_common_setup(struct nfs_server *server, server->caps |= server->nfs_client->cl_mvops->init_caps; if (server->flags & NFS_MOUNT_NORDIRPLUS) server->caps &= ~NFS_CAP_READDIRPLUS; + if (server->options & NFS_OPTION_NO_READ_PLUS) + server->caps &= ~NFS_CAP_READ_PLUS; + /* * Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower * authentication. diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 0570391eaa16..5b8701fca5b9 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -90,6 +90,7 @@ enum { Opt_resvport, Opt_noresvport, Opt_fscache, Opt_nofscache, Opt_migration, Opt_nomigration, + Opt_readplus, Opt_noreadplus, /* Mount options that take integer arguments */ Opt_port, @@ -151,6 +152,8 @@ static const match_table_t nfs_mount_option_tokens = { { Opt_nofscache, "nofsc" }, { Opt_migration, "migration" }, { Opt_nomigration, "nomigration" }, + { Opt_readplus, "readplus" }, + { Opt_noreadplus, "noreadplus" }, { Opt_port, "port=%s" }, { Opt_rsize, "rsize=%s" }, @@ -690,6 +693,11 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, if (nfss->options & NFS_OPTION_MIGRATION) seq_printf(m, ",migration"); + if (nfss->options & NFS_OPTION_NO_READ_PLUS) + seq_printf(m,",noreadplus"); + else + seq_printf(m,",readplus"); + if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) { if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONE) seq_printf(m, ",lookupcache=none"); @@ -1324,6 +1332,12 @@ static int nfs_parse_mount_options(char *raw, case Opt_nomigration: mnt->options &= ~NFS_OPTION_MIGRATION; break; + case Opt_readplus: + mnt->options &= ~NFS_OPTION_NO_READ_PLUS; + break; + case Opt_noreadplus: + mnt->options |= NFS_OPTION_NO_READ_PLUS; + break; /* * options that take numeric values @@ -1626,6 +1640,9 @@ static int nfs_parse_mount_options(char *raw, if (mnt->options & NFS_OPTION_MIGRATION && (mnt->version != 4 || mnt->minorversion != 0)) goto out_migration_misuse; + if (mnt->options & NFS_OPTION_NO_READ_PLUS && + (mnt->version != 4 || mnt->minorversion < 2)) + goto out_noreadplus_misuse; /* * verify that any proto=/mountproto= options match the address @@ -1668,6 +1685,10 @@ static int nfs_parse_mount_options(char *raw, printk(KERN_INFO "NFS: 'migration' not supported for this NFS version\n"); return 0; +out_noreadplus_misuse: + printk(KERN_INFO + "NFS: 'noreadplus' not supported for this NFS version\n"); + return 0; out_nomem: printk(KERN_INFO "NFS: not enough memory to parse option\n"); return 0; diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index db465ad6659b..2fd3cf2061c2 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -535,10 +535,10 @@ enum { NFSPROC4_CLNT_LAYOUTSTATS, NFSPROC4_CLNT_CLONE, NFSPROC4_CLNT_COPY, - NFSPROC4_CLNT_OFFLOAD_CANCEL, - NFSPROC4_CLNT_READ_PLUS, NFSPROC4_CLNT_LOOKUPP, + NFSPROC4_CLNT_OFFLOAD_CANCEL, + NFSPROC4_CLNT_READ_PLUS, }; /* nfs41 types */ diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index e431c2a7affd..c95be09b84f1 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -157,6 +157,7 @@ struct nfs_server { unsigned int clone_blksize; /* granularity of a CLONE operation */ #define NFS_OPTION_FSCACHE 0x00000001 /* - local caching enabled */ #define NFS_OPTION_MIGRATION 0x00000002 /* - NFSv4 migration enabled */ +#define NFS_OPTION_NO_READ_PLUS 0x00000004 /* - NFSv4.2 READ_PLUS enabled */ struct nfs_fsid fsid; __u64 maxfilesize; /* maximum file size */ -- 2.20.1