Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Feb 2009 20:00:15 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189120 - head/sys/fs/msdosfs
Message-ID:  <200902272000.n1RK0FKI081514@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Feb 27 20:00:15 2009
New Revision: 189120
URL: http://svn.freebsd.org/changeset/base/189120

Log:
  - Hold a reference on the cdev a filesystem is mounted from in the mount.
  - Remove the cdev pointers from the denode and instead use the mountpoint's
    reference to call dev2udev() in getattr().
  
  Reviewed by:	kib, julian

Modified:
  head/sys/fs/msdosfs/denode.h
  head/sys/fs/msdosfs/msdosfs_denode.c
  head/sys/fs/msdosfs/msdosfs_vfsops.c
  head/sys/fs/msdosfs/msdosfs_vnops.c
  head/sys/fs/msdosfs/msdosfsmount.h

Modified: head/sys/fs/msdosfs/denode.h
==============================================================================
--- head/sys/fs/msdosfs/denode.h	Fri Feb 27 19:27:33 2009	(r189119)
+++ head/sys/fs/msdosfs/denode.h	Fri Feb 27 20:00:15 2009	(r189120)
@@ -139,7 +139,6 @@ struct fatcache {
 struct denode {
 	struct vnode *de_vnode;	/* addr of vnode we are part of */
 	u_long de_flag;		/* flag bits */
-	struct cdev *de_dev;	/* device where direntry lives */
 	u_long de_dirclust;	/* cluster of the directory file containing this entry */
 	u_long de_diroffset;	/* offset of this entry in the directory cluster */
 	u_long de_fndoffset;	/* offset of found dir entry */

Modified: head/sys/fs/msdosfs/msdosfs_denode.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_denode.c	Fri Feb 27 19:27:33 2009	(r189119)
+++ head/sys/fs/msdosfs/msdosfs_denode.c	Fri Feb 27 20:00:15 2009	(r189120)
@@ -168,7 +168,6 @@ deget(pmp, dirclust, diroffset, depp)
 	ldep->de_dirclust = dirclust;
 	ldep->de_diroffset = diroffset;
 	ldep->de_inode = inode;
-	ldep->de_dev = pmp->pm_devvp->v_rdev;
 	fc_purge(ldep, 0);	/* init the fat cache for this denode */
 
 	lockmgr(nvp->v_vnlock, LK_EXCLUSIVE, NULL);

Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_vfsops.c	Fri Feb 27 19:27:33 2009	(r189119)
+++ head/sys/fs/msdosfs/msdosfs_vfsops.c	Fri Feb 27 20:00:15 2009	(r189120)
@@ -408,7 +408,7 @@ mountmsdosfs(struct vnode *devvp, struct
 {
 	struct msdosfsmount *pmp;
 	struct buf *bp;
-	struct cdev *dev = devvp->v_rdev;
+	struct cdev *dev;
 	union bootsector *bsp;
 	struct byte_bpb33 *b33;
 	struct byte_bpb50 *b50;
@@ -419,8 +419,12 @@ mountmsdosfs(struct vnode *devvp, struct
 	struct g_consumer *cp;
 	struct bufobj *bo;
 
+	bp = NULL;		/* This and pmp both used in error_exit. */
+	pmp = NULL;
 	ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
-	/* XXX: use VOP_ACCESS to check FS perms */
+
+	dev = devvp->v_rdev;
+	dev_ref(dev);
 	DROP_GIANT();
 	g_topology_lock();
 	error = g_vfs_open(devvp, &cp, "msdosfs", ronly ? 0 : 1);
@@ -428,11 +432,9 @@ mountmsdosfs(struct vnode *devvp, struct
 	PICKUP_GIANT();
 	VOP_UNLOCK(devvp, 0);
 	if (error)
-		return (error);
+		goto error_exit;
 
 	bo = &devvp->v_bufobj;
-	bp = NULL;		/* This and pmp both used in error_exit. */
-	pmp = NULL;
 
 	/*
 	 * Read the boot sector of the filesystem, and then check the
@@ -707,6 +709,7 @@ mountmsdosfs(struct vnode *devvp, struct
 	 * fillinusemap() needs pm_devvp.
 	 */
 	pmp->pm_devvp = devvp;
+	pmp->pm_dev = dev;
 
 	/*
 	 * Have the inuse map filled in.
@@ -763,6 +766,7 @@ error_exit:
 		free(pmp, M_MSDOSFSMNT);
 		mp->mnt_data = NULL;
 	}
+	dev_rel(dev);
 	return (error);
 }
 
@@ -827,6 +831,7 @@ msdosfs_unmount(struct mount *mp, int mn
 	g_topology_unlock();
 	PICKUP_GIANT();
 	vrele(pmp->pm_devvp);
+	dev_rel(pmp->pm_dev);
 	free(pmp->pm_inusemap, M_MSDOSFSFAT);
 	if (pmp->pm_flags & MSDOSFS_LARGEFS)
 		msdosfs_fileno_free(mp);

Modified: head/sys/fs/msdosfs/msdosfs_vnops.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_vnops.c	Fri Feb 27 19:27:33 2009	(r189119)
+++ head/sys/fs/msdosfs/msdosfs_vnops.c	Fri Feb 27 20:00:15 2009	(r189120)
@@ -180,7 +180,6 @@ msdosfs_create(ap)
 	ndirent.de_LowerCase = 0;
 	ndirent.de_StartCluster = 0;
 	ndirent.de_FileSize = 0;
-	ndirent.de_dev = pdep->de_dev;
 	ndirent.de_pmp = pdep->de_pmp;
 	ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
 	getnanotime(&ts);
@@ -302,7 +301,7 @@ msdosfs_getattr(ap)
 
 	getnanotime(&ts);
 	DETIMES(dep, &ts, &ts, &ts);
-	vap->va_fsid = dev2udev(dep->de_dev);
+	vap->va_fsid = dev2udev(pmp->pm_dev);
 	/*
 	 * The following computation of the fileid must be the same as that
 	 * used in msdosfs_readdir() to compute d_fileno. If not, pwd
@@ -1410,7 +1409,6 @@ msdosfs_mkdir(ap)
 	ndirent.de_LowerCase = 0;
 	ndirent.de_StartCluster = newcluster;
 	ndirent.de_FileSize = 0;
-	ndirent.de_dev = pdep->de_dev;
 	error = createde(&ndirent, pdep, &dep, cnp);
 	if (error)
 		goto bad;
@@ -1909,7 +1907,7 @@ msdosfs_print(ap)
 
 	printf("\tstartcluster %lu, dircluster %lu, diroffset %lu, ",
 	       dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
-	printf("on dev %s\n", devtoname(dep->de_dev));
+	printf("on dev %s\n", devtoname(dep->de_pmp->pm_dev));
 	return (0);
 }
 

Modified: head/sys/fs/msdosfs/msdosfsmount.h
==============================================================================
--- head/sys/fs/msdosfs/msdosfsmount.h	Fri Feb 27 19:27:33 2009	(r189119)
+++ head/sys/fs/msdosfs/msdosfsmount.h	Fri Feb 27 20:00:15 2009	(r189120)
@@ -74,7 +74,8 @@ struct msdosfsmount {
 				   for files */
 	mode_t pm_dirmask;	/* mask to and with file protection bits
 				   for directories */
-	struct vnode *pm_devvp;	/* vnode for block device mntd */
+	struct vnode *pm_devvp;	/* vnode for character device mounted */
+	struct cdev *pm_dev;	/* character device mounted */
 	struct bpb50 pm_bpb;	/* BIOS parameter blk for this fs */
 	u_long pm_BlkPerSec;	/* How many DEV_BSIZE blocks fit inside a physical sector */
 	u_long pm_FATsecs;	/* actual number of fat sectors */



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