Author: mckusick
Date: Sun Jul 10 00:41:31 2011
New Revision: 223900
URL: http://svn.freebsd.org/changeset/base/223900

Log:
  Allow disk partitions associated with UFS read-only mounted
  filesystems to be opened for writing. This functionality used to
  be special-cased for just the root filesystem, but with this change
  is now available for all UFS filesystems. This change is needed for
  journaled soft updates recovery.
  
  Discussed with: Jeff Roberson

Modified:
  head/sys/geom/geom_vfs.c
  head/sys/ufs/ffs/ffs_vfsops.c

Modified: head/sys/geom/geom_vfs.c
==============================================================================
--- head/sys/geom/geom_vfs.c    Sat Jul  9 23:05:50 2011        (r223899)
+++ head/sys/geom/geom_vfs.c    Sun Jul 10 00:41:31 2011        (r223900)
@@ -171,7 +171,7 @@ g_vfs_open(struct vnode *vp, struct g_co
        gp = g_new_geomf(&g_vfs_class, "%s.%s", fsname, pp->name);
        cp = g_new_consumer(gp);
        g_attach(cp, pp);
-       error = g_access(cp, 1, wr, 1);
+       error = g_access(cp, 1, wr, wr);
        if (error) {
                g_wither_geom(gp, ENXIO);
                return (error);

Modified: head/sys/ufs/ffs/ffs_vfsops.c
==============================================================================
--- head/sys/ufs/ffs/ffs_vfsops.c       Sat Jul  9 23:05:50 2011        
(r223899)
+++ head/sys/ufs/ffs/ffs_vfsops.c       Sun Jul 10 00:41:31 2011        
(r223900)
@@ -273,7 +273,10 @@ ffs_mount(struct mount *mp)
                                softdep_unmount(mp);
                        DROP_GIANT();
                        g_topology_lock();
-                       g_access(ump->um_cp, 0, -1, 0);
+                       /*
+                        * Drop our write and exclusive access.
+                        */
+                       g_access(ump->um_cp, 0, -1, -1);
                        g_topology_unlock();
                        PICKUP_GIANT();
                        fs->fs_ronly = 1;
@@ -327,13 +330,9 @@ ffs_mount(struct mount *mp)
                        DROP_GIANT();
                        g_topology_lock();
                        /*
-                        * If we're the root device, we may not have an E count
-                        * yet, get it now.
+                        * Request exclusive write access.
                         */
-                       if (ump->um_cp->ace == 0)
-                               error = g_access(ump->um_cp, 0, 1, 1);
-                       else
-                               error = g_access(ump->um_cp, 0, 1, 0);
+                       error = g_access(ump->um_cp, 0, 1, 1);
                        g_topology_unlock();
                        PICKUP_GIANT();
                        if (error)
@@ -665,13 +664,6 @@ ffs_mountfs(devvp, mp, td)
        DROP_GIANT();
        g_topology_lock();
        error = g_vfs_open(devvp, &cp, "ffs", ronly ? 0 : 1);
-
-       /*
-        * If we are a root mount, drop the E flag so fsck can do its magic.
-        * We will pick it up again when we remount R/W.
-        */
-       if (error == 0 && ronly && (mp->mnt_flag & MNT_ROOTFS))
-               error = g_access(cp, 0, 0, -1);
        g_topology_unlock();
        PICKUP_GIANT();
        VOP_UNLOCK(devvp, 0);
@@ -932,7 +924,7 @@ ffs_mountfs(devvp, mp, td)
        strlcpy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname, MAXMNTLEN);
        mp->mnt_stat.f_iosize = fs->fs_bsize;
 
-       if( mp->mnt_flag & MNT_ROOTFS) {
+       if (mp->mnt_flag & MNT_ROOTFS) {
                /*
                 * Root mount; update timestamp in mount structure.
                 * this will be used by the common root mount code
_______________________________________________
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