git: be1776da76c7 - stable/13 - nfsclient: Delete unused function nfscl_getcookie()

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Thu, 10 Feb 2022 03:40:16 UTC
The branch stable/13 has been updated by rmacklem:

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

commit be1776da76c77f9e5015a3f3ef46dbef723c83bb
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2022-01-27 23:30:26 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-02-10 03:39:00 +0000

    nfsclient: Delete unused function nfscl_getcookie()
    
    The function nfscl_getcookie(), which is essentially the
    same as ncl_getcookie(), is never called, so delete it.
    This is probably cruft left over from the port of the
    NFSv4 code to FreeBSD several years ago.
    
    Found while modifying the code to better use the
    directory offset cookies.
    
    (cherry picked from commit 98c788737f71be0a54a23456082453ec674987fe)
---
 sys/fs/nfs/nfs_var.h             |  1 -
 sys/fs/nfsclient/nfs_clcomsubs.c | 53 ----------------------------------------
 2 files changed, 54 deletions(-)

diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h
index b5bc5178187e..c565a8ab579a 100644
--- a/sys/fs/nfs/nfs_var.h
+++ b/sys/fs/nfs/nfs_var.h
@@ -367,7 +367,6 @@ struct mbuf *nfsm_add_ext_pgs(struct mbuf *, int, int *);
 /* nfs_clcomsubs.c */
 void nfsm_uiombuf(struct nfsrv_descript *, struct uio *, int);
 struct mbuf *nfsm_uiombuflist(struct uio *, int, u_int);
-nfsuint64 *nfscl_getcookie(struct nfsnode *, off_t off, int);
 u_int8_t *nfscl_getmyip(struct nfsmount *, struct in6_addr *, int *);
 int nfsm_getfh(struct nfsrv_descript *, struct nfsfh **);
 int nfscl_mtofh(struct nfsrv_descript *, struct nfsfh **,
diff --git a/sys/fs/nfsclient/nfs_clcomsubs.c b/sys/fs/nfsclient/nfs_clcomsubs.c
index c6556d287b1e..8f593a8d3c92 100644
--- a/sys/fs/nfsclient/nfs_clcomsubs.c
+++ b/sys/fs/nfsclient/nfs_clcomsubs.c
@@ -49,8 +49,6 @@ extern enum vtype newnv2tov_type[8];
 extern enum vtype nv34tov_type[8];
 NFSCLSTATEMUTEX;
 
-static nfsuint64 nfs_nullcookie = {{ 0, 0 }};
-
 /*
  * copies a uio scatter/gather list to an mbuf chain.
  * NOTE: can ony handle iovcnt == 1
@@ -326,57 +324,6 @@ nfsmout:
 	return (error);
 }
 
-/*
- * This function finds the directory cookie that corresponds to the
- * logical byte offset given.
- */
-nfsuint64 *
-nfscl_getcookie(struct nfsnode *np, off_t off, int add)
-{
-	struct nfsdmap *dp, *dp2;
-	int pos;
-
-	pos = off / NFS_DIRBLKSIZ;
-	if (pos == 0) {
-		KASSERT(!add, ("nfs getcookie add at 0"));
-		return (&nfs_nullcookie);
-	}
-	pos--;
-	dp = LIST_FIRST(&np->n_cookies);
-	if (!dp) {
-		if (add) {
-			dp = malloc(sizeof (struct nfsdmap),
-				M_NFSDIROFF, M_WAITOK);
-			dp->ndm_eocookie = 0;
-			LIST_INSERT_HEAD(&np->n_cookies, dp, ndm_list);
-		} else
-			return (NULL);
-	}
-	while (pos >= NFSNUMCOOKIES) {
-		pos -= NFSNUMCOOKIES;
-		if (LIST_NEXT(dp, ndm_list) != NULL) {
-			if (!add && dp->ndm_eocookie < NFSNUMCOOKIES &&
-				pos >= dp->ndm_eocookie)
-				return (NULL);
-			dp = LIST_NEXT(dp, ndm_list);
-		} else if (add) {
-			dp2 = malloc(sizeof (struct nfsdmap),
-				M_NFSDIROFF, M_WAITOK);
-			dp2->ndm_eocookie = 0;
-			LIST_INSERT_AFTER(dp, dp2, ndm_list);
-			dp = dp2;
-		} else
-			return (NULL);
-	}
-	if (pos >= dp->ndm_eocookie) {
-		if (add)
-			dp->ndm_eocookie = pos + 1;
-		else
-			return (NULL);
-	}
-	return (&dp->ndm_cookies[pos]);
-}
-
 /*
  * Gets a file handle out of an nfs reply sent to the client and returns
  * the file handle and the file's attributes.