git: fbe965591f8a - main - nfscl: Do not do readahead for directories

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Fri, 10 May 2024 01:35:55 UTC
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=fbe965591f8a0a32c805a279a2505d4c20d22d26

commit fbe965591f8a0a32c805a279a2505d4c20d22d26
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2024-05-10 01:33:13 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2024-05-10 01:35:10 +0000

    nfscl: Do not do readahead for directories
    
    For a very long time, the NFS client has done readahead for
    directory blocks.  Unlike data blocks, the readahead cannot
    begin until the Readdir RPC reply has been received, since
    the directory offset cookie in that Readdir RPC reply is needed.
    As such, the readahead is serialized and does not seem to
    provide any real benefit.
    
    Recent testing/benchmarking shows that removing this
    readahead code for Readdir does not have a negative impact
    on performance.
    
    Therefore, this patch deletes the readahead code for Readdir,
    which simplifies the code and may make future changes simpler.
    
    MFC after:      1 month
---
 sys/fs/nfsclient/nfs_clbio.c | 31 +------------------------------
 1 file changed, 1 insertion(+), 30 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c
index c691e797aa01..ed7149c27903 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -679,36 +679,6 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
 			    goto out;
 		}
 
-		/*
-		 * If not eof and read aheads are enabled, start one.
-		 * (You need the current block first, so that you have the
-		 *  directory offset cookie of the next block.)
-		 */
-		NFSLOCKNODE(np);
-		if (nmp->nm_readahead > 0 && ncl_bioread_dora(vp) &&
-		    (bp->b_flags & B_INVAL) == 0 &&
-		    (np->n_direofoffset == 0 ||
-		    (lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) &&
-		    incore(&vp->v_bufobj, lbn + 1) == NULL) {
-			NFSUNLOCKNODE(np);
-			rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, td);
-			if (rabp) {
-			    if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) {
-				rabp->b_flags |= B_ASYNC;
-				rabp->b_iocmd = BIO_READ;
-				vfs_busy_pages(rabp, 0);
-				if (ncl_asyncio(nmp, rabp, cred, td)) {
-				    rabp->b_flags |= B_INVAL;
-				    rabp->b_ioflags |= BIO_ERROR;
-				    vfs_unbusy_pages(rabp);
-				    brelse(rabp);
-				}
-			    } else {
-				brelse(rabp);
-			    }
-			}
-			NFSLOCKNODE(np);
-		}
 		/*
 		 * Unlike VREG files, whos buffer size ( bp->b_bcount ) is
 		 * chopped for the EOF condition, we cannot tell how large
@@ -721,6 +691,7 @@ ncl_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
 		 * in np->n_direofoffset and chop it off as an extra step
 		 * right here.
 		 */
+		NFSLOCKNODE(np);
 		n = lmin(uio->uio_resid, NFS_DIRBLKSIZ - bp->b_resid - on);
 		if (np->n_direofoffset && n > np->n_direofoffset - uio->uio_offset)
 			n = np->n_direofoffset - uio->uio_offset;