Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Feb 2010 17:07:49 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r204466 - head/sys/fs/msdosfs
Message-ID:  <201002281707.o1SH7n6b039382@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Feb 28 17:07:49 2010
New Revision: 204466
URL: http://svn.freebsd.org/changeset/base/204466

Log:
  Assert that the msdosfs vnode is (e)locked in several places.
  The plan is to use vnode lock to protect denode and fat cache,
  and having separate lock for block use map.
  
  Change the check and return on impossible condition into KASSERT().
  
  Tested by:	pho
  MFC after:	3 weeks

Modified:
  head/sys/fs/msdosfs/msdosfs_denode.c
  head/sys/fs/msdosfs/msdosfs_fat.c

Modified: head/sys/fs/msdosfs/msdosfs_denode.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_denode.c	Sun Feb 28 17:06:42 2010	(r204465)
+++ head/sys/fs/msdosfs/msdosfs_denode.c	Sun Feb 28 17:07:49 2010	(r204466)
@@ -167,9 +167,8 @@ deget(pmp, dirclust, diroffset, depp)
 	ldep->de_dirclust = dirclust;
 	ldep->de_diroffset = diroffset;
 	ldep->de_inode = inode;
-	fc_purge(ldep, 0);	/* init the fat cache for this denode */
-
 	lockmgr(nvp->v_vnlock, LK_EXCLUSIVE, NULL);
+	fc_purge(ldep, 0);	/* init the fat cache for this denode */
 	error = insmntque(nvp, mntp);
 	if (error != 0) {
 		free(ldep, M_MSDOSFSNODE);

Modified: head/sys/fs/msdosfs/msdosfs_fat.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_fat.c	Sun Feb 28 17:06:42 2010	(r204465)
+++ head/sys/fs/msdosfs/msdosfs_fat.c	Sun Feb 28 17:07:49 2010	(r204466)
@@ -139,12 +139,9 @@ pcbmap(dep, findcn, bnp, cnp, sp)
 	struct msdosfsmount *pmp = dep->de_pmp;
 	u_long bsize;
 
-	/*
-	 * If they don't give us someplace to return a value then don't
-	 * bother doing anything.
-	 */
-	if (bnp == NULL && cnp == NULL && sp == NULL)
-		return (0);
+	KASSERT(bnp != NULL || cnp != NULL || sp != NULL,
+	    ("pcbmap: extra call"));
+	ASSERT_VOP_ELOCKED(DETOV(dep), "pcbmap");
 
 	cn = dep->de_StartCluster;
 	/*
@@ -270,6 +267,8 @@ fc_lookup(dep, findcn, frcnp, fsrcnp)
 	u_long cn;
 	struct fatcache *closest = 0;
 
+	ASSERT_VOP_LOCKED(DETOV(dep), "fc_lookup");
+
 	for (i = 0; i < FC_SIZE; i++) {
 		cn = dep->de_fc[i].fc_frcn;
 		if (cn != FCE_EMPTY && cn <= findcn) {
@@ -295,6 +294,8 @@ fc_purge(dep, frcn)
 	int i;
 	struct fatcache *fcp;
 
+	ASSERT_VOP_ELOCKED(DETOV(dep), "fc_purge");
+
 	fcp = dep->de_fc;
 	for (i = 0; i < FC_SIZE; i++, fcp++) {
 		if (fcp->fc_frcn >= frcn)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002281707.o1SH7n6b039382>