Re: Giant around fdfree() in exit1() ?

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 17 Aug 2005 10:23:40 -0400
On Wednesday 17 August 2005 08:44 am, Giorgos Keramidas wrote:
> On 2005-08-17 11:13, Poul-Henning Kamp <phk_at_haven.freebsd.dk> wrote:
> > I'm seeing Giant held in a MNTK_MPSAFE devfs->close without this patch,
> > any insight/comments ?
>
> fdfree() releases POSIX locks the descriptor has.  Is it ok to call
> VOP_ADVLOCK(..., F_UNLCK, ...) and free() without holding Giant?

free() is safe to not need Giant.  However, the call to VOP_ADVLOCK() has a 
VFS_ASSERT_GIANT() in front of it.  fork1() does not hold Giant when calling 
fdfree().  The aio code in vfs_aio.c does hold Giant.  I think you could 
probably push Giant down into fdfree() and remove it from the callers (i.e. 
apply patch below, remove Giant around fdfree() call in the aio code and push 
down Giant in fdfree()).  It seems that Giant needs to be acquired around 
VOP_ADVLOCK if it is needed for vp->v_mount using VFS_LOCK_GIANT(vp->v_mount) 
and a matching VFS_UNLOCK_GIANT() after the VOP.  I'm not sure if vrele() is 
safe yet.  If not, then you'll need to lock Giant around the FILEDESC_LOCK at 
the bottom that contains the calls to vrele() as well.  That means that I 
think you'll still have Giant in your close routine though phk.  Maybe you 
could make the Giant conditional using VFS_LOCK_GIANT() and 
VFS_UNLOCK_GIANT() again.

-- 
John Baldwin <jhb_at_FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org
Received on Wed Aug 17 2005 - 12:26:21 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:41 UTC