RFC: adding a lock flags argument to VFS_FHTOVP() for FreeBSD9

Kostik Belousov kostikbel at gmail.com
Wed May 18 23:24:30 UTC 2011


On Wed, May 18, 2011 at 04:37:39PM -0400, Rick Macklem wrote:
> > Yes, the flag to specify the locking mode does only specify the
> > minimal
> > locking requirements, and filesystem is allowed to upgrade it to the
> > more strict lock type. E.g. UFS would only return shared lock if the
> > vnode was found in hash, AFAIR. If not told otherwise, getnewvnode(9)
> > forces lockmgr to convert all lock requests into exclusive.
> > 
> That's exactly what UFS does, but I did notice some inconsistencies
> w.r.t. the various file systems.
> 
> For VFS_VGET(), ffs/cd9660/udf do basically the following:
> 1	error = vfs_hash_get(mp, ino, flags, curthread, vpp, NULL, NULL);
>         ...
> 2	if ((flags & LK_TYPE_MASK) == LK_SHARED) {
> 		flags &= ~LK_TYPE_MASK;
> 		flags |= LK_EXCLUSIVE;
> 	}
> 	...
> 3	lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL);
> 	...
> 4	error = vfs_hash_insert(vp, ino, flags, curthread, vpp, NULL, NULL);
> 
> but hpfs/ext2fs do something similar to the above, except
> they omit step #2. (ie. They would do #4 with LK_SHARED, if
> that was what flags is passed in as.)
> 
> Looking at vfs_hash_insert(), the "flags" argument is just
> used for vget(), so it isn't obvious to me if it needs to
> be LK_EXCLUSIVE or not.
I would say that what ext2fs and hpfs trying to do is legitimate,
since the caller expects to get only the lock specified in the flags.

But, in fact, all locks for ext2fs and hpfs are exclusive, since
as I said in the previous message, getnewvnode() initializes vnode lock
for automatic converstion shared->exclusive, and ext2fs/hpfs do not
override this.
> 
> So, does anyone know if this depend on the file system or are hpfs/ext2fs
> broken?
> 
> Thanks in advance for any help with this, rick
> ps: Fortunately, for my patch, I can just ignore the "flags"
>     argument for VFS_FHTOVP() for the file systems I'm not
>     sure about, so they'll just return LK_EXCLUSIVE locked
>     vnodes.
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20110518/bb5a2aec/attachment.pgp


More information about the freebsd-fs mailing list