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
This commit is contained in:
Konstantin Belousov 2022-04-01 23:34:59 +03:00
parent 5c075d6404
commit 59e85819be
2 changed files with 3 additions and 18 deletions

View File

@ -571,13 +571,6 @@ lf_advlockasync(struct vop_advlockasync_args *ap, struct lockf **statep,
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);

View File

@ -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 */