]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/vdev_file.c
Illumos #1948: zpool list should show more detailed pool info
[mirror_zfs.git] / module / zfs / vdev_file.c
index 8c22aa5316a1178b4f402ea22978622cb8803b80..3c0ce53cdf80b1c344bca9d309159aba3422b6c3 100644 (file)
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
  */
 
 #include <sys/zfs_context.h>
@@ -47,7 +48,8 @@ vdev_file_rele(vdev_t *vd)
 }
 
 static int
-vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift)
+vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
+    uint64_t *ashift)
 {
        vdev_file_t *vf;
        vnode_t *vp;
@@ -72,7 +74,7 @@ vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift)
                goto skip_open;
        }
 
-       vf = vd->vdev_tsd = kmem_zalloc(sizeof (vdev_file_t), KM_SLEEP);
+       vf = vd->vdev_tsd = kmem_zalloc(sizeof (vdev_file_t), KM_PUSHPAGE);
 
        /*
         * We always open the files from the root of the global zone, even if
@@ -112,7 +114,7 @@ skip_open:
                return (error);
        }
 
-       *psize = vattr.va_size;
+       *max_psize = *psize = vattr.va_size;
        *ashift = SPA_MINBLOCKSHIFT;
 
        return (0);
@@ -130,7 +132,6 @@ vdev_file_close(vdev_t *vd)
                (void) VOP_PUTPAGE(vf->vf_vnode, 0, 0, B_INVAL, kcred, NULL);
                (void) VOP_CLOSE(vf->vf_vnode, spa_mode(vd->vdev_spa), 1, 0,
                    kcred, NULL);
-               VN_RELE(vf->vf_vnode);
        }
 
        vd->vdev_delayed_close = B_FALSE;
@@ -142,16 +143,17 @@ static int
 vdev_file_io_start(zio_t *zio)
 {
        vdev_t *vd = zio->io_vd;
-       vdev_file_t *vf = vd->vdev_tsd;
-       ssize_t resid;
+       vdev_file_t *vf;
+       ssize_t resid = 0;
 
-       if (zio->io_type == ZIO_TYPE_IOCTL) {
-               /* XXPOLICY */
-               if (!vdev_readable(vd)) {
-                       zio->io_error = ENXIO;
-                       return (ZIO_PIPELINE_CONTINUE);
-               }
+       if (!vdev_readable(vd)) {
+               zio->io_error = ENXIO;
+               return (ZIO_PIPELINE_CONTINUE);
+       }
 
+       vf = vd->vdev_tsd;
+
+       if (zio->io_type == ZIO_TYPE_IOCTL) {
                switch (zio->io_cmd) {
                case DKIOCFLUSHWRITECACHE:
                        zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,