HAMMER VFS - Fix two minor bugs.
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 6 Apr 2011 04:09:09 +0000 (21:09 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 6 Apr 2011 04:09:09 +0000 (21:09 -0700)
* When downgrading a volume to read-only due to a critical HAMMER error
  also properly downgrade the VOP_OPEN/VOP_CLOSE state so the opencount
  and writecount match up.

  This should fix issues disconnecting the related disk device after
  umounting a HAMMER partition which has had a critical error.

* When adding or removing a volume to an existing HAMMER mount flush
  disk buffers before calling VOP_CLOSE() instead of after.

sys/vfs/hammer/hammer_vfsops.c
sys/vfs/hammer/hammer_volume.c

index d83d900..05dc0ff 100644 (file)
@@ -953,6 +953,8 @@ hammer_critical_error(hammer_mount_t hmp, hammer_inode_t ip,
        if (hmp->ronly == 0) {
                hmp->ronly = 2;         /* special errored read-only mode */
                hmp->mp->mnt_flag |= MNT_RDONLY;
+               RB_SCAN(hammer_vol_rb_tree, &hmp->rb_vols_root, NULL,
+                       hammer_adjust_volume_mode, NULL);
                kprintf("HAMMER(%s): Forcing read-only mode\n",
                        hmp->mp->mnt_stat.f_mntfromname);
        }
index 323c31a..97d32d1 100644 (file)
@@ -775,9 +775,9 @@ hammer_setup_device(struct vnode **devvpp, const char *dev_path, int ronly)
 static void
 hammer_close_device(struct vnode **devvpp, int ronly)
 {
-       VOP_CLOSE(*devvpp, (ronly ? FREAD : FREAD|FWRITE));
        if (*devvpp) {
                vinvalbuf(*devvpp, ronly ? 0 : V_SAVE, 0, 0);
+               VOP_CLOSE(*devvpp, (ronly ? FREAD : FREAD|FWRITE));
                vrele(*devvpp);
                *devvpp = NULL;
        }