Skip to content

Commit

Permalink
zfs vdev_file_io_start: validate vdev before using vdev_tsd
Browse files Browse the repository at this point in the history
vdev_tsd can be NULL for certain vdev states.
At least in userland testing with ztest.

Submitted by:	avg
MFC after:	3 days
  • Loading branch information
Pawel Jakub Dawidek authored and Pawel Jakub Dawidek committed Oct 21, 2011
1 parent 2128d22 commit b39ba07
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c
Expand Up @@ -153,17 +153,19 @@ static int
vdev_file_io_start(zio_t *zio)
{
vdev_t *vd = zio->io_vd;
vdev_file_t *vf = vd->vdev_tsd;
vnode_t *vp = vf->vf_vnode;
vdev_file_t *vf;
vnode_t *vp;
ssize_t resid;

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;
vp = vf->vf_vnode;

if (zio->io_type == ZIO_TYPE_IOCTL) {
switch (zio->io_cmd) {
case DKIOCFLUSHWRITECACHE:
zio->io_error = VOP_FSYNC(vp, FSYNC | FDSYNC,
Expand Down

0 comments on commit b39ba07

Please sign in to comment.