inconsistency in using vn_fullpath1()

Robert Watson rwatson at FreeBSD.org
Sun Mar 4 11:27:41 UTC 2007


On Sun, 4 Mar 2007, Divacky Roman wrote:

> I noticed that kern___getcwd() calls vn_fullpath1() with Giant held like 
> this:
>
> 	mtx_lock(&Giant);
> 	FILEDESC_LOCK(fdp);
>        error = vn_fullpath1(td, fdp->fd_cdir, fdp->fd_rdir, tmpbuf,
>            &bp, buflen);
>        FILEDESC_UNLOCK(fdp);
>        mtx_unlock(&Giant);
>
> on the other hand vn_fullpath() calls it without Giant held like this:
>
> 	FILEDESC_LOCK(fdp);
>        error = vn_fullpath1(td, vn, fdp->fd_rdir, buf, retbuf, MAXPATHLEN);
>        FILEDESC_UNLOCK(fdp);
>
> I dont see much difference in the callings so I wonder if holding Giant is 
> necessary when calling vn_fullpath1(). Because we either - do one unecessary 
> locking operation or unsufficiently lock it.
>
> thnx for explaining to me and possibly fixing it.

I suspect that the Giant acquisition there is a conservative acquisition based 
on VFS not having been MPSAFE, and can be removed.

Robert N M Watson
Computer Laboratory
University of Cambridge


More information about the freebsd-hackers mailing list