Subject: vnode locking problem
To: None <tech-kern@netbsd.org>
From: Matthias Drochner <drochner@zel459.zel.kfa-juelich.de>
List: tech-kern
Date: 03/23/1999 20:56:28
There were people looking into locking issues - may I direct your
attention to PR kern/4629. There is a "locking against myself" if
a program reads its own inode while the vm system tries to page in
something.
As long as there is no UBC - couldn't a fix be as easy as the
appended patch? Or is this a can of worms?

best regards
Matthias


Index: kern/vfs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_vnops.c,v
retrieving revision 1.32
diff -c -2 -r1.32 vfs_vnops.c
*** vfs_vnops.c	1999/02/26 23:38:55	1.32
--- vfs_vnops.c	1999/03/23 18:26:08
***************
*** 366,370 ****
  	if ((fp->f_flag & (FFSYNC | FRSYNC)) == (FFSYNC | FRSYNC))
  		ioflag |= IO_SYNC;
! 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
  	uio->uio_offset = *offset;
  	count = uio->uio_resid;
--- 366,370 ----
  	if ((fp->f_flag & (FFSYNC | FRSYNC)) == (FFSYNC | FRSYNC))
  		ioflag |= IO_SYNC;
! 	vn_lock(vp, LK_SHARED | LK_RETRY);
  	uio->uio_offset = *offset;
  	count = uio->uio_resid;
Index: uvm/uvm_vnode.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_vnode.c,v
retrieving revision 1.19
diff -c -2 -r1.19 uvm_vnode.c
*** uvm_vnode.c	1999/03/04 06:48:54	1.19
--- uvm_vnode.c	1999/03/23 18:26:09
***************
*** 1703,1707 ****
  
  	if ((uvn->u_flags & UVM_VNODE_VNISLOCKED) == 0)
! 		vn_lock(vn, LK_EXCLUSIVE | LK_RETRY);
  	/* NOTE: vnode now locked! */
  
--- 1703,1708 ----
  
  	if ((uvn->u_flags & UVM_VNODE_VNISLOCKED) == 0)
! 		vn_lock(vn, rw == UIO_READ ? LK_SHARED | LK_RETRY :
! 			LK_EXCLUSIVE | LK_RETRY);
  	/* NOTE: vnode now locked! */