]> git.proxmox.com Git - mirror_zfs-debian.git/commitdiff
Illumos #1680: zfs vdev_file_io_start: validate vdev before using vdev_tsd
authorAndriy Gapon <avg@FreeBSD.org>
Mon, 9 Apr 2012 17:01:46 +0000 (13:01 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 11 Apr 2012 18:23:18 +0000 (11:23 -0700)
vdev_tsd can be NULL for certain vdev states.
At least in userland testing with ztest.

References to Illumos issue:
  https://www.illumos.org/issues/1680

Ported-by: Richard Yao <ryao@cs.stonybrook.edu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #655

module/zfs/vdev_file.c

index bbc85e733011a9c07b06def549d2e8992dd36de7..ce49fe08fb7126c134e9802e5965d6c060861985 100644 (file)
@@ -141,16 +141,17 @@ static int
 vdev_file_io_start(zio_t *zio)
 {
        vdev_t *vd = zio->io_vd;
-       vdev_file_t *vf = vd->vdev_tsd;
+       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,