Skip to content

Commit 30d3e6a

Browse files
committed
Merge: NFS: Extend rdirplus mount option with "force|none"
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6716 JIRA: https://issues.redhat.com/browse/RHEL-86674 Conflicts: slight context difference in nfs_fs_sb.h commit cfe1f87 Author: Benjamin Coddington <bcodding@redhat.com> Date: Thu Mar 13 13:01:22 2025 -0400 NFS: Extend rdirplus mount option with "force|none" There are certain users that wish to force the NFS client to choose READDIRPLUS over READDIR for a particular mount. Update the "rdirplus" mount option to optionally accept values. For "rdirplus=force", the NFS client will always attempt to use READDDIRPLUS. The setting of "rdirplus=none" is aliased to the existing "nordirplus". Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Link: https://lore.kernel.org/r/c4cf0de4c8be0930b91bc74bee310d289781cd3b.1741885071.git.bcodding@redhat.com Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Approved-by: Olga Kornievskaia <okorniev@redhat.com> Approved-by: Scott Mayhew <smayhew@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents 0570654 + dd8e0ed commit 30d3e6a

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

fs/nfs/dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,8 @@ static bool nfs_use_readdirplus(struct inode *dir, struct dir_context *ctx,
667667
{
668668
if (!nfs_server_capable(dir, NFS_CAP_READDIRPLUS))
669669
return false;
670+
if (NFS_SERVER(dir)->flags & NFS_MOUNT_FORCE_RDIRPLUS)
671+
return true;
670672
if (ctx->pos == 0 ||
671673
cache_hits + cache_misses > NFS_READDIR_CACHE_USAGE_THRESHOLD)
672674
return true;

fs/nfs/fs_context.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ enum nfs_param {
7171
Opt_posix,
7272
Opt_proto,
7373
Opt_rdirplus,
74+
Opt_rdirplus_none,
75+
Opt_rdirplus_force,
7476
Opt_rdma,
7577
Opt_resvport,
7678
Opt_retrans,
@@ -172,7 +174,8 @@ static const struct fs_parameter_spec nfs_fs_parameters[] = {
172174
fsparam_u32 ("port", Opt_port),
173175
fsparam_flag_no("posix", Opt_posix),
174176
fsparam_string("proto", Opt_proto),
175-
fsparam_flag_no("rdirplus", Opt_rdirplus),
177+
fsparam_flag_no("rdirplus", Opt_rdirplus), // rdirplus|nordirplus
178+
fsparam_string("rdirplus", Opt_rdirplus), // rdirplus=...
176179
fsparam_flag ("rdma", Opt_rdma),
177180
fsparam_flag_no("resvport", Opt_resvport),
178181
fsparam_u32 ("retrans", Opt_retrans),
@@ -286,6 +289,12 @@ static const struct constant_table nfs_xprtsec_policies[] = {
286289
{}
287290
};
288291

292+
static const struct constant_table nfs_rdirplus_tokens[] = {
293+
{ "none", Opt_rdirplus_none },
294+
{ "force", Opt_rdirplus_force },
295+
{}
296+
};
297+
289298
/*
290299
* Sanity-check a server address provided by the mount command.
291300
*
@@ -628,10 +637,25 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
628637
ctx->flags &= ~NFS_MOUNT_NOACL;
629638
break;
630639
case Opt_rdirplus:
631-
if (result.negated)
640+
if (result.negated) {
641+
ctx->flags &= ~NFS_MOUNT_FORCE_RDIRPLUS;
632642
ctx->flags |= NFS_MOUNT_NORDIRPLUS;
633-
else
634-
ctx->flags &= ~NFS_MOUNT_NORDIRPLUS;
643+
} else if (!param->string) {
644+
ctx->flags &= ~(NFS_MOUNT_NORDIRPLUS | NFS_MOUNT_FORCE_RDIRPLUS);
645+
} else {
646+
switch (lookup_constant(nfs_rdirplus_tokens, param->string, -1)) {
647+
case Opt_rdirplus_none:
648+
ctx->flags &= ~NFS_MOUNT_FORCE_RDIRPLUS;
649+
ctx->flags |= NFS_MOUNT_NORDIRPLUS;
650+
break;
651+
case Opt_rdirplus_force:
652+
ctx->flags &= ~NFS_MOUNT_NORDIRPLUS;
653+
ctx->flags |= NFS_MOUNT_FORCE_RDIRPLUS;
654+
break;
655+
default:
656+
goto out_invalid_value;
657+
}
658+
}
635659
break;
636660
case Opt_sharecache:
637661
if (result.negated)

fs/nfs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
448448
{ NFS_MOUNT_NONLM, ",nolock", "" },
449449
{ NFS_MOUNT_NOACL, ",noacl", "" },
450450
{ NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
451+
{ NFS_MOUNT_FORCE_RDIRPLUS, ",rdirplus=force", "" },
451452
{ NFS_MOUNT_UNSHARED, ",nosharecache", "" },
452453
{ NFS_MOUNT_NORESVPORT, ",noresvport", "" },
453454
{ 0, NULL, NULL }

include/linux/nfs_fs_sb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ struct nfs_server {
158158
#define NFS_MOUNT_WRITE_WAIT 0x02000000
159159
#define NFS_MOUNT_TRUNK_DISCOVERY 0x04000000
160160
#define NFS_MOUNT_SHUTDOWN 0x08000000
161+
#define NFS_MOUNT_FORCE_RDIRPLUS 0x20000000
161162

162163
unsigned int fattr_valid; /* Valid attributes */
163164
unsigned int caps; /* server capabilities */

0 commit comments

Comments
 (0)