svn commit: r209557 - stable/8/sys/ufs/ufs

Konstantin Belousov kib at FreeBSD.org
Mon Jun 28 01:36:22 UTC 2010


Author: kib
Date: Mon Jun 28 01:36:22 2010
New Revision: 209557
URL: http://svn.freebsd.org/changeset/base/209557

Log:
  MFC r209367:
  Ensure that VOP_ACCESSX is called with exclusively locked vnode for
  the kernel compiled with QUOTA option.

Modified:
  stable/8/sys/ufs/ufs/ufs_lookup.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/ufs/ufs/ufs_lookup.c
==============================================================================
--- stable/8/sys/ufs/ufs/ufs_lookup.c	Mon Jun 28 01:16:34 2010	(r209556)
+++ stable/8/sys/ufs/ufs/ufs_lookup.c	Mon Jun 28 01:36:22 2010	(r209557)
@@ -80,6 +80,32 @@ SYSCTL_INT(_debug, OID_AUTO, dircheck, C
 static int ufs_lookup_(struct vnode *, struct vnode **, struct componentname *,
     ino_t *);
 
+#ifdef QUOTA
+static int
+ufs_lookup_upgrade_lock(struct vnode *vp)
+{
+	int error;
+
+	ASSERT_VOP_LOCKED(vp, __FUNCTION__);
+	if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
+		return (0);
+
+	error = 0;
+
+	/*
+	 * Upgrade vnode lock, since getinoquota()
+	 * requires exclusive lock to modify inode.
+	 */
+	vhold(vp);
+	vn_lock(vp, LK_UPGRADE | LK_RETRY);
+	VI_LOCK(vp);
+	if (vp->v_iflag & VI_DOOMED)
+		error = ENOENT;
+	vdropl(vp);
+	return (error);
+}
+#endif
+
 static int
 ufs_delete_denied(struct vnode *vdp, struct vnode *tdp, struct ucred *cred,
     struct thread *td)
@@ -235,6 +261,13 @@ ufs_lookup_(struct vnode *vdp, struct vn
 	vnode_create_vobject(vdp, DIP(dp, i_size), cnp->cn_thread);
 
 	bmask = VFSTOUFS(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
+#ifdef QUOTA
+	if ((nameiop == DELETE || nameiop == RENAME) && (flags & ISLASTCN)) {
+		error = ufs_lookup_upgrade_lock(vdp);
+		if (error != 0)
+			return (error);
+	}
+#endif
 
 restart:
 	bp = NULL;


More information about the svn-src-all mailing list