[PATCH 5.15, 5.10, 5.4] NFSv4: Don't clear capabilities that won't be reset

Siddh Raman Pant posted 1 patch 6 days, 10 hours ago
fs/nfs/nfs4proc.c | 1 -
1 file changed, 1 deletion(-)
[PATCH 5.15, 5.10, 5.4] NFSv4: Don't clear capabilities that won't be reset
Posted by Siddh Raman Pant 6 days, 10 hours ago
From: Trond Myklebust <trond.myklebust@hammerspace.com>

Don't clear the capabilities that are not going to get reset by the call
to _nfs4_server_capabilities().

Reported-by: Scott Haiden <scott.b.haiden@gmail.com>
Fixes: b01f21cacde9 ("NFS: Fix the setting of capabilities when automounting a new filesystem")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
(cherry picked from commit 31f1a960ad1a14def94fa0b8c25d62b4c032813f)
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
This got backported till 6.1 but not later for some reason. It got
cherry-picked cleanly.

 fs/nfs/nfs4proc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 5f8de86b2798..f511087d5e1c 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3885,7 +3885,6 @@ int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle)
 	};
 	int err;
 
-	nfs_server_set_init_caps(server);
 	do {
 		err = nfs4_handle_exception(server,
 				_nfs4_server_capabilities(server, fhandle),
-- 
2.51.0
Re: [PATCH 5.15, 5.10, 5.4] NFSv4: Don't clear capabilities that won't be reset
Posted by Greg Kroah-Hartman 2 days, 10 hours ago
On Thu, Sep 25, 2025 at 06:28:00PM +0530, Siddh Raman Pant wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> Don't clear the capabilities that are not going to get reset by the call
> to _nfs4_server_capabilities().
> 
> Reported-by: Scott Haiden <scott.b.haiden@gmail.com>
> Fixes: b01f21cacde9 ("NFS: Fix the setting of capabilities when automounting a new filesystem")
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> (cherry picked from commit 31f1a960ad1a14def94fa0b8c25d62b4c032813f)
> Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
> ---
> This got backported till 6.1 but not later for some reason. It got
> cherry-picked cleanly.

It's in the queue, just not been released yet, thanks.

greg k-h
[PATCH 5.15 1/3] NFSv4: Clear the NFS_CAP_FS_LOCATIONS flag if it is not set
Posted by Siddh Raman Pant 6 days, 10 hours ago
From: Trond Myklebust <trond.myklebust@hammerspace.com>

_nfs4_server_capabilities() is expected to clear any flags that are not
supported by the server.

Fixes: 8a59bb93b7e3 ("NFSv4 store server support for fs_location attribute")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
(cherry picked from commit dd5a8621b886b02f8341c5d4ea68eb2c552ebd3e)
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
 fs/nfs/nfs4proc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 65dae25d6856..3d854e2537bc 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3904,8 +3904,9 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f
 			res.attr_bitmask[2] &= FATTR4_WORD2_NFS42_MASK;
 		}
 		memcpy(server->attr_bitmask, res.attr_bitmask, sizeof(server->attr_bitmask));
-		server->caps &= ~(NFS_CAP_ACLS | NFS_CAP_HARDLINKS |
-				  NFS_CAP_SYMLINKS| NFS_CAP_SECURITY_LABEL);
+		server->caps &=
+			~(NFS_CAP_ACLS | NFS_CAP_HARDLINKS | NFS_CAP_SYMLINKS |
+			  NFS_CAP_SECURITY_LABEL | NFS_CAP_FS_LOCATIONS);
 		server->fattr_valid = NFS_ATTR_FATTR_V4;
 		if (res.attr_bitmask[0] & FATTR4_WORD0_ACL &&
 				res.acl_bitmask & ACL4_SUPPORT_ALLOW_ACL)
-- 
2.51.0
[PATCH 5.15 2/3] NFSv4: Clear NFS_CAP_OPEN_XOR and NFS_CAP_DELEGTIME if not supported
Posted by Siddh Raman Pant 6 days, 10 hours ago
From: Trond Myklebust <trond.myklebust@hammerspace.com>

_nfs4_server_capabilities() should clear capabilities that are not
supported by the server.

Fixes: d2a00cceb93a ("NFSv4: Detect support for OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
(cherry picked from commit b3ac33436030bce37ecb3dcae581ecfaad28078c)
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
 fs/nfs/nfs4proc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 3d854e2537bc..91b95310e107 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3906,7 +3906,8 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f
 		memcpy(server->attr_bitmask, res.attr_bitmask, sizeof(server->attr_bitmask));
 		server->caps &=
 			~(NFS_CAP_ACLS | NFS_CAP_HARDLINKS | NFS_CAP_SYMLINKS |
-			  NFS_CAP_SECURITY_LABEL | NFS_CAP_FS_LOCATIONS);
+			  NFS_CAP_SECURITY_LABEL | NFS_CAP_FS_LOCATIONS |
+			  NFS_CAP_OPEN_XOR | NFS_CAP_DELEGTIME);
 		server->fattr_valid = NFS_ATTR_FATTR_V4;
 		if (res.attr_bitmask[0] & FATTR4_WORD0_ACL &&
 				res.acl_bitmask & ACL4_SUPPORT_ALLOW_ACL)
-- 
2.51.0
Re: [PATCH 5.15 2/3] NFSv4: Clear NFS_CAP_OPEN_XOR and NFS_CAP_DELEGTIME if not supported
Posted by Greg Kroah-Hartman 2 days, 10 hours ago
On Thu, Sep 25, 2025 at 06:31:45PM +0530, Siddh Raman Pant wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> _nfs4_server_capabilities() should clear capabilities that are not
> supported by the server.
> 
> Fixes: d2a00cceb93a ("NFSv4: Detect support for OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION")
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> (cherry picked from commit b3ac33436030bce37ecb3dcae581ecfaad28078c)
> Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
> ---
>  fs/nfs/nfs4proc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 3d854e2537bc..91b95310e107 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -3906,7 +3906,8 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f
>  		memcpy(server->attr_bitmask, res.attr_bitmask, sizeof(server->attr_bitmask));
>  		server->caps &=
>  			~(NFS_CAP_ACLS | NFS_CAP_HARDLINKS | NFS_CAP_SYMLINKS |
> -			  NFS_CAP_SECURITY_LABEL | NFS_CAP_FS_LOCATIONS);
> +			  NFS_CAP_SECURITY_LABEL | NFS_CAP_FS_LOCATIONS |
> +			  NFS_CAP_OPEN_XOR | NFS_CAP_DELEGTIME);
>  		server->fattr_valid = NFS_ATTR_FATTR_V4;
>  		if (res.attr_bitmask[0] & FATTR4_WORD0_ACL &&
>  				res.acl_bitmask & ACL4_SUPPORT_ALLOW_ACL)
> -- 
> 2.51.0
> 

This breaks the build :(
Re: [PATCH 5.15 2/3] NFSv4: Clear NFS_CAP_OPEN_XOR and NFS_CAP_DELEGTIME if not supported
Posted by Siddh Raman Pant 2 days, 9 hours ago
On Mon, Sep 29 2025 at 18:54:09 +0530, Greg Kroah-Hartman wrote:
> [...]
> >  			~(NFS_CAP_ACLS | NFS_CAP_HARDLINKS | NFS_CAP_SYMLINKS |
> > -			  NFS_CAP_SECURITY_LABEL | NFS_CAP_FS_LOCATIONS);
> > +			  NFS_CAP_SECURITY_LABEL | NFS_CAP_FS_LOCATIONS |
> > +			  NFS_CAP_OPEN_XOR | NFS_CAP_DELEGTIME);
> > [...]
> 
> This breaks the build :(

Oops, I am extremely sorry for posting this.

Please ignore/drop this one as those flags don't exist.

Build succeeds after this.

Thanks,
Siddh
[PATCH 5.15 3/3] NFSv4: Clear the NFS_CAP_XATTR flag if not supported by the server
Posted by Siddh Raman Pant 6 days, 10 hours ago
From: Trond Myklebust <trond.myklebust@hammerspace.com>

nfs_server_set_fsinfo() shouldn't assume that NFS_CAP_XATTR is unset
on entry to the function.

Fixes: b78ef845c35d ("NFSv4.2: query the server for extended attribute support")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
(cherry picked from commit 4fb2b677fc1f70ee642c0beecc3cabf226ef5707)
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
 fs/nfs/client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 443b67beec37..c29bc0a30dd7 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -862,6 +862,8 @@ static void nfs_server_set_fsinfo(struct nfs_server *server,
 
 	if (fsinfo->xattr_support)
 		server->caps |= NFS_CAP_XATTR;
+	else
+		server->caps &= ~NFS_CAP_XATTR;
 #endif
 }
 
-- 
2.51.0
[PATCH 5.10] NFSv4: Clear the NFS_CAP_XATTR flag if not supported by the server
Posted by Siddh Raman Pant 6 days, 10 hours ago
From: Trond Myklebust <trond.myklebust@hammerspace.com>

nfs_server_set_fsinfo() shouldn't assume that NFS_CAP_XATTR is unset
on entry to the function.

Fixes: b78ef845c35d ("NFSv4.2: query the server for extended attribute support")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
(cherry picked from commit 4fb2b677fc1f70ee642c0beecc3cabf226ef5707)
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
 fs/nfs/client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index ac2fbbba1521..6134101184fa 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -850,6 +850,8 @@ static void nfs_server_set_fsinfo(struct nfs_server *server,
 
 	if (fsinfo->xattr_support)
 		server->caps |= NFS_CAP_XATTR;
+	else
+		server->caps &= ~NFS_CAP_XATTR;
 #endif
 }
 
-- 
2.51.0