Date: Fri, 16 Nov 2001 14:56:59 +0300 (MSK) From: Maxim Konovalov <maxim@macomnet.ru> To: Alfred Perlstein <bright@mu.org> Cc: John Baldwin <jhb@FreeBSD.org>, <hackers@FreeBSD.org> Subject: Re: has 'options LOCKF_DEBUG' ever worked? (w/ patch) (fwd) Message-ID: <20011116113214.S13973-100000@news1.macomnet.ru> In-Reply-To: <20011115153239.T13393@elvis.mu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hello, On Thu, 15 Nov 2001, Alfred Perlstein wrote: > Yes I saw this, I have no idea what 'JH' stands for either that's why > I left it as is. > > The problem is that VTOI is ufs specific, this "fix" will break > LOCKF_DEBUG for all other FS's other than UFS because it casts > the vnode->data ptr to struct inode *. > > So your "fix" is broken. Alfred, John, thanks you very much for your answers. I expected something similar. Btw are there any smart ways to find out does underlying FS support inode concept or not? Yes, I know about vnode.v_tag, but comparing it with VT_UFS/VT_NFS/VT_MFS etc does not look OK for me. > Please just fix lf_print to not deref the inode ptr in the struct. Here it is. I put you comment, Alfred, above lf_inode assignment. Index: kern_lockf.c =================================================================== RCS file: /vol0/cvs/ncvs/src/sys/kern/kern_lockf.c,v retrieving revision 1.38 diff -u -r1.38 kern_lockf.c --- kern_lockf.c 2001/09/12 08:37:44 1.38 +++ kern_lockf.c 2001/11/16 11:49:42 @@ -163,7 +163,13 @@ lock->lf_start = start; lock->lf_end = end; lock->lf_id = ap->a_id; -/* lock->lf_inode = ip; */ /* XXX JH */ + /* + * 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; lock->lf_head = head; lock->lf_next = (struct lockf *)0; @@ -768,15 +774,22 @@ printf("proc %ld", (long)((struct proc *)lock->lf_id)->p_pid); else printf("id %p", (void *)lock->lf_id); - /* XXX no %qd in kernel. Truncate. */ - printf(" in ino %lu on dev <%d, %d>, %s, start %ld, end %ld", - (u_long)lock->lf_inode->i_number, - major(lock->lf_inode->i_dev), - minor(lock->lf_inode->i_dev), - lock->lf_type == F_RDLCK ? "shared" : - lock->lf_type == F_WRLCK ? "exclusive" : - lock->lf_type == F_UNLCK ? "unlock" : - "unknown", (long)lock->lf_start, (long)lock->lf_end); + if (lock->lf_inode != (struct inode *)0) + /* XXX no %qd in kernel. Truncate. */ + printf(" in ino %lu on dev <%d, %d>, %s, start %ld, end %ld", + (u_long)lock->lf_inode->i_number, + major(lock->lf_inode->i_dev), + minor(lock->lf_inode->i_dev), + lock->lf_type == F_RDLCK ? "shared" : + lock->lf_type == F_WRLCK ? "exclusive" : + lock->lf_type == F_UNLCK ? "unlock" : + "unknown", (long)lock->lf_start, (long)lock->lf_end); + else + printf(" %s, start %ld, end %ld", + lock->lf_type == F_RDLCK ? "shared" : + lock->lf_type == F_WRLCK ? "exclusive" : + lock->lf_type == F_UNLCK ? "unlock" : + "unknown", (long)lock->lf_start, (long)lock->lf_end); if (!TAILQ_EMPTY(&lock->lf_blkhd)) printf(" block %p\n", (void *)TAILQ_FIRST(&lock->lf_blkhd)); else @@ -789,6 +802,9 @@ struct lockf *lock; { register struct lockf *lf, *blk; + + if (lock->lf_inode == (struct inode *)0) + return; printf("%s: Lock list for ino %lu on dev <%d, %d>:\n", tag, (u_long)lock->lf_inode->i_number, > -Alfred tested on -stable. - -maxim -- Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011116113214.S13973-100000>