nfs: fix regression in handling of namlen= option in NFSv4
Subsystems (2)
PATCH 1/1 nfs: fix regression in handling of namlen= option in NFSv4
Setting the maximum length of a pathname component via the namlen= mount option is currently broken in NFSv4.
This patch will fix this issue.
--- fs/nfs/namespace.c | 2 ++ fs/nfs/nfs4client.c | 2 ++ fs/nfs/nfs4namespace.c | 2 ++ 3 files changed, 6 insertions(+)
fs/nfs/namespace.c +2 -0
@@ -277,6 +277,8 @@ int nfs_do_submount(struct fs_context *fc)if (IS_ERR (server))return PTR_ERR (server); +if (ctx->namlen) + server->namelen = ctx->namlen; ctx->server = server; buffer =kmalloc (4096 ,GFP_USER );
fs/nfs/nfs4client.c +2 -0
@@ -1187,6 +1187,8 @@ static int nfs4_init_server(struct nfs_server *server, struct fs_context *fc) server->rsize =nfs_io_size (ctx->rsize, server->nfs_client->cl_proto);if (ctx->wsize) server->wsize =nfs_io_size (ctx->wsize, server->nfs_client->cl_proto); +if (ctx->namlen) + server->namelen = ctx->namlen; server->acregmin = ctx->acregmin *HZ ; server->acregmax = ctx->acregmax *HZ ;
fs/nfs/nfs4namespace.c +2 -0
@@ -465,6 +465,8 @@ int nfs4_submount(struct fs_context *fc, struct nfs_server *server)return PTR_ERR (client); ctx->selected_flavor = client->cl_auth->au_flavor; +if (server->namelen) + ctx->namlen = server->namelen;if (ctx->clone_data.fattr->valid &NFS_ATTR_FATTR_V4_REFERRAL ) { ret =nfs_do_refmount (fc, client); }else {
Signature · 1 line
2.39.1
Quoted 4 lines · Chen Hanxiao
Setting the maximum length of a pathname component via the namlen= mount option is currently broken in NFSv4.
This patch will fix this issue.
Why do we need this? In NFSv3 and NFSv4, the server will communicate the correct value through the protocol.
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 9 lines
-----邮件原件-----
发件人: Trond Myklebust <[email protected]>
发送时间: 2024年2月29日 5:03
收件人: [email protected];
抄送: [email protected]; [email protected]
主题: Re: [PATCH] nfs: fix regression in handling of namlen= option in NFSv4
Quoted 9 lines
Quoted 4 lines · Chen Hanxiao
Setting the maximum length of a pathname component via the namlen= mount option is currently broken in NFSv4.
This patch will fix this issue.
Why do we need this? In NFSv3 and NFSv4, the server will communicate the correct value through the protocol.
In NFSv3, we could set namlen parameters:
#mount -t nfs -o vers=3,namlen=100 192.168.122.210:/nfsroot /mnt
And nfs_server.namelen is set to the values from command line.
# mount ... 192.168.122.210:/nfsroot on /mnt type nfs (rw,relatime,vers=3,rsize=262144,wsize=262144,namlen=100,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.122.210,mountvers=3,mountport=20048,mountproto=udp,local_lock=none,addr=192.168.122.210)
But for NFSv4, mount cmd with namlen could success, but no effect:
# mount -t nfs4 -o vers=4.2,namlen=100 192.168.122.210:/nfsroot /mnt/
# mount ... 192.168.122.210:/nfsroot on /mnt type nfs4 (rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.122.208,local_lock=none,addr=192.168.122.210)
I have some questions:
1) As we can set namlen in NFSv3, does NFS client use this parameter to limit something?
2) If 1) stands, do we need this for NFSv4, or reject namlen in a vers=4 mount?
Regards,
- Chen