git: 59e85819be69 - main - lockf: remove lf_inode from struct lockf_entry

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 09 Apr 2022 21:48:18 UTC
The branch main has been updated by kib:

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

commit 59e85819be69d354fa6f390b791fd9cd06a80f35
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-04-01 20:34:59 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-04-09 21:43:53 +0000

    lockf: remove lf_inode from struct lockf_entry
    
    The UFS-specific struct inode cannot be used in generic advisory lock
    code.  It was probably used as a shortcut for the debugging, as the
    remnants of the code around it indicates.
    
    Use somewhat more verbose and less concentrated, but universal,
    VOP_PRINT(), where needed.
    
    Reviewed by:    markj, rmacklem
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D34756
---
 sys/kern/kern_lockf.c | 20 +++-----------------
 sys/sys/lockf.h       |  1 -
 2 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c
index 8a54e4700d20..079f7b999835 100644
--- a/sys/kern/kern_lockf.c
+++ b/sys/kern/kern_lockf.c
@@ -571,13 +571,6 @@ retry_setlock:
 		vref(vp);
 	}
 
-	/*
-	 * XXX The problem is that VTOI is ufs specific, so it will
-	 * break LOCKF_DEBUG for all other FS's other than UFS because
-	 * it casts the vnode->data ptr to struct inode *.
-	 */
-/*	lock->lf_inode = VTOI(ap->a_vp); */
-	lock->lf_inode = (struct inode *)0;
 	lock->lf_type = fl->l_type;
 	LIST_INIT(&lock->lf_outedges);
 	LIST_INIT(&lock->lf_inedges);
@@ -2498,10 +2491,8 @@ lf_print(char *tag, struct lockf_entry *lock)
 
 	printf("%s: lock %p for ", tag, (void *)lock);
 	lf_print_owner(lock->lf_owner);
-	if (lock->lf_inode != (struct inode *)0)
-		printf(" in ino %ju on dev <%s>,",
-		    (uintmax_t)lock->lf_inode->i_number,
-		    devtoname(ITODEV(lock->lf_inode)));
+	printf("\nvnode %p", lock->lf_vnode);
+	VOP_PRINT(lock->lf_vnode);
 	printf(" %s, start %jd, end ",
 	    lock->lf_type == F_RDLCK ? "shared" :
 	    lock->lf_type == F_WRLCK ? "exclusive" :
@@ -2524,12 +2515,7 @@ lf_printlist(char *tag, struct lockf_entry *lock)
 	struct lockf_entry *lf, *blk;
 	struct lockf_edge *e;
 
-	if (lock->lf_inode == (struct inode *)0)
-		return;
-
-	printf("%s: Lock list for ino %ju on dev <%s>:\n",
-	    tag, (uintmax_t)lock->lf_inode->i_number,
-	    devtoname(ITODEV(lock->lf_inode)));
+	printf("%s: Lock list for vnode %p:\n", tag, lock->lf_vnode);
 	LIST_FOREACH(lf, &lock->lf_vnode->v_lockf->ls_active, lf_link) {
 		printf("\tlock %p for ",(void *)lf);
 		lf_print_owner(lock->lf_owner);
diff --git a/sys/sys/lockf.h b/sys/sys/lockf.h
index 368c773283ec..cca02501a462 100644
--- a/sys/sys/lockf.h
+++ b/sys/sys/lockf.h
@@ -77,7 +77,6 @@ struct lockf_entry {
 	off_t	lf_end;		    /* (s) Byte # of the end of the lock (OFF_MAX=EOF) */
 	struct	lock_owner *lf_owner; /* (c) Owner of the lock */
 	struct	vnode *lf_vnode;    /* (c) File being locked (only valid for active lock) */
-	struct	inode *lf_inode;    /* (c) Back pointer to the inode */
 	struct	task *lf_async_task;/* (c) Async lock callback */
 	LIST_ENTRY(lockf_entry) lf_link;  /* (s) Linkage for lock lists */
 	struct lockf_edge_list lf_outedges; /* (s) list of out-edges */