Author: avg
Date: Sat Apr  3 08:53:53 2010
New Revision: 206130
URL: http://svn.freebsd.org/changeset/base/206130

Log:
  g_vfs_open: allow only one mount per device vnode
  
  In other words, deny multiple read-only mounts of the same device.
  Shared read-only mounts should theoretically be possible, but,
  unfortunately, can not be implemented correctly using current
  buffer cache code/interface and results in an eventual system crash.
  Also, using nullfs seems to be a more efficient way to achieve the same
  goal.
  
  This gets us back to where we were before GEOM and where other BSDs are.
  
  Submitted by: pjd (idea for checking for shared mounting)
  Discussed with:       phk, pjd
  Silence from: fs@, geom@
  MFC after:    2 weeks

Modified:
  head/sys/geom/geom_vfs.c

Modified: head/sys/geom/geom_vfs.c
==============================================================================
--- head/sys/geom/geom_vfs.c    Sat Apr  3 08:39:00 2010        (r206129)
+++ head/sys/geom/geom_vfs.c    Sat Apr  3 08:53:53 2010        (r206130)
@@ -161,6 +161,10 @@ g_vfs_open(struct vnode *vp, struct g_co
        g_topology_assert();
 
        *cpp = NULL;
+       bo = &vp->v_bufobj;
+       if (bo->bo_private != vp)
+               return (EBUSY);
+
        pp = g_dev_getprovider(vp->v_rdev);
        if (pp == NULL)
                return (ENOENT);
@@ -176,7 +180,7 @@ g_vfs_open(struct vnode *vp, struct g_co
        vnode_create_vobject(vp, pp->mediasize, curthread);
        VFS_UNLOCK_GIANT(vfslocked);
        *cpp = cp;
-       bo = &vp->v_bufobj;
+       cp->private = vp;
        bo->bo_ops = g_vfs_bufops;
        bo->bo_private = cp;
        bo->bo_bsize = pp->sectorsize;
@@ -196,5 +200,6 @@ g_vfs_close(struct g_consumer *cp)
        gp = cp->geom;
        bo = gp->softc;
        bufobj_invalbuf(bo, V_SAVE, 0, 0);
+       bo->bo_private = cp->private;
        g_wither_geom_close(gp, ENXIO);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to