Re: [PATCH] Make udf(4) MPSAFE and use shared lookups

From: Attilio Rao <attilio_at_freebsd.org>
Date: Thu, 20 Nov 2008 23:02:29 +0100
2008/11/20, John Baldwin <jhb_at_freebsd.org>:
> So this patch is fairly minimal since udf(4) is currently read-only.  The
>  changes include:
>
>  * Set VV_ROOT in udf_vget() if we ever return a vnode instead of doing it only
>   in udf_root().  This matches the behavior of other operating systems and
>   correctly tags the root vnode with VV_ROOT in the unlikely case that we
>   create the vnode during a call to ufs_vget() that does not come from
>   ufs_root().
>  * If the hash lookup in ufs_vget() fails, ensure an exclusive vnode lock is
>   used while creating the new vnode (same as UFS).
>  * Allow lock recursion (XXX: not really sure this is needed actually).
>  * Allow shared vnode locks on non-fifos.
>  * Honor the requested locking flags (shared vs exclusive) instead of always
>   using exclusive vnode locks during a lookup operation.
>  * Handle "." lookups the same way other filesystems do by just bumping the
>   reference on 'dvp' rather than calling udf_vget().
>
>  http://www.FreeBSD.org/~jhb/patches/udf_mpsafe.patch

_at__at_ -589,6 +582,22 _at__at_
 	if (error || *vpp != NULL)
 		return (error);

+	/*
+	 * We must promote to an exclusive lock for vnode creation.  This
+	 * can happen if lookup is passed LOCKSHARED.
+ 	 */
+	if ((flags & LK_TYPE_MASK) == LK_SHARED) {
+		flags &= ~LK_TYPE_MASK;
+		flags |= LK_EXCLUSIVE;
+	}
+

On -CURRENT, operations are bitwise (differently from 7.x and such).
What you want to do is just:
flag = (flag & ~LK_SHARED) | LK_EXCLUSIVE;

The other parts look good (except that IIRC stlye wants all multi-line
comments to be preceeded by a white, empty line).

Thanks,
Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
Received on Thu Nov 20 2008 - 21:02:31 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:37 UTC