linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero
@ 2021-09-30 19:44 trondmy
  2021-09-30 19:44 ` [PATCH 2/2] nfsd: Fix a warning for nfsd_file_close_inode trondmy
  2021-10-01 15:59 ` [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero Chuck Lever III
  0 siblings, 2 replies; 3+ messages in thread
From: trondmy @ 2021-09-30 19:44 UTC (permalink / raw)
  To: J. Bruce Fields, Chuck Lever; +Cc: linux-nfs

From: Trond Myklebust <trond.myklebust@hammerspace.com>

RFC3530 notes that the 'dircount' field may be zero, in which case the
recommendation is to ignore it, and only enforce the 'maxcount' field.
In RFC5661, this recommendation to ignore a zero valued field becomes a
requirement.

Fixes: aee377644146 ("nfsd4: fix rd_dircount enforcement")
Cc: <stable@vger.kernel.org>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfsd/nfs4xdr.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 7abeccb975b2..cf030ebe2827 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3544,15 +3544,18 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
 		goto fail;
 	cd->rd_maxcount -= entry_bytes;
 	/*
-	 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", so
-	 * let's always let through the first entry, at least:
+	 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", and
+	 * notes that it could be zero. If it is zero, then the server
+	 * should enforce only the rd_maxcount value.
 	 */
-	if (!cd->rd_dircount)
-		goto fail;
-	name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8;
-	if (name_and_cookie > cd->rd_dircount && cd->cookie_offset)
-		goto fail;
-	cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie);
+	if (cd->rd_dircount) {
+		name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8;
+		if (name_and_cookie > cd->rd_dircount && cd->cookie_offset)
+			goto fail;
+		cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie);
+		if (!cd->rd_dircount)
+			cd->rd_maxcount = 0;
+	}
 
 	cd->cookie_offset = cookie_offset;
 skip_entry:
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] nfsd: Fix a warning for nfsd_file_close_inode
  2021-09-30 19:44 [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero trondmy
@ 2021-09-30 19:44 ` trondmy
  2021-10-01 15:59 ` [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero Chuck Lever III
  1 sibling, 0 replies; 3+ messages in thread
From: trondmy @ 2021-09-30 19:44 UTC (permalink / raw)
  To: J. Bruce Fields, Chuck Lever; +Cc: linux-nfs

From: Trond Myklebust <trond.myklebust@hammerspace.com>

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfsd/filecache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index 7629248fdd53..be3c1aad50ea 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -542,7 +542,7 @@ nfsd_file_close_inode_sync(struct inode *inode)
 }
 
 /**
- * nfsd_file_close_inode_sync - attempt to forcibly close a nfsd_file
+ * nfsd_file_close_inode - attempt a delayed close of a nfsd_file
  * @inode: inode of the file to attempt to remove
  *
  * Walk the whole hash bucket, looking for any files that correspond to "inode".
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero
  2021-09-30 19:44 [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero trondmy
  2021-09-30 19:44 ` [PATCH 2/2] nfsd: Fix a warning for nfsd_file_close_inode trondmy
@ 2021-10-01 15:59 ` Chuck Lever III
  1 sibling, 0 replies; 3+ messages in thread
From: Chuck Lever III @ 2021-10-01 15:59 UTC (permalink / raw)
  To: trondmy; +Cc: Bruce Fields, Linux NFS Mailing List



> On Sep 30, 2021, at 3:44 PM, trondmy@kernel.org wrote:
> 
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> RFC3530 notes that the 'dircount' field may be zero, in which case the
> recommendation is to ignore it, and only enforce the 'maxcount' field.
> In RFC5661, this recommendation to ignore a zero valued field becomes a
> requirement.
> 
> Fixes: aee377644146 ("nfsd4: fix rd_dircount enforcement")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

Pulled into the next 5.15-rc for NFSD. Thanks!


> ---
> fs/nfsd/nfs4xdr.c | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 7abeccb975b2..cf030ebe2827 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -3544,15 +3544,18 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
> 		goto fail;
> 	cd->rd_maxcount -= entry_bytes;
> 	/*
> -	 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", so
> -	 * let's always let through the first entry, at least:
> +	 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", and
> +	 * notes that it could be zero. If it is zero, then the server
> +	 * should enforce only the rd_maxcount value.
> 	 */
> -	if (!cd->rd_dircount)
> -		goto fail;
> -	name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8;
> -	if (name_and_cookie > cd->rd_dircount && cd->cookie_offset)
> -		goto fail;
> -	cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie);
> +	if (cd->rd_dircount) {
> +		name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8;
> +		if (name_and_cookie > cd->rd_dircount && cd->cookie_offset)
> +			goto fail;
> +		cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie);
> +		if (!cd->rd_dircount)
> +			cd->rd_maxcount = 0;
> +	}
> 
> 	cd->cookie_offset = cookie_offset;
> skip_entry:
> -- 
> 2.31.1
> 

--
Chuck Lever




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-01 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 19:44 [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero trondmy
2021-09-30 19:44 ` [PATCH 2/2] nfsd: Fix a warning for nfsd_file_close_inode trondmy
2021-10-01 15:59 ` [PATCH 1/2] nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero Chuck Lever III

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).