Project

General

Profile

Bug #1680

zfs vdev_file_io_start: validate vdev before using vdev_tsd

Added by Martin Matuška almost 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
zfs - Zettabyte File System
Start date:
2011-10-23
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

zfs vdev_file_io_start: validate vdev before using vdev_tsd

vdev_tsd can be NULL for certain vdev states.
At least in userland testing with ztest.

Author: Andriy Gapon <>

diff -r 86d96517d461 usr/src/uts/common/fs/zfs/vdev_file.c
--- a/usr/src/uts/common/fs/zfs/vdev_file.c    Fri Oct 21 11:44:31 2011 -0400
+++ b/usr/src/uts/common/fs/zfs/vdev_file.c    Sun Oct 23 11:37:43 2011 +0200
@@ -142,16 +142,17 @@
 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;

+    if (!vdev_readable(vd)) {
+        zio->io_error = ENXIO;
+        return (ZIO_PIPELINE_CONTINUE);
+    }
+
+    vf = vd->vdev_tsd;
+
     if (zio->io_type == ZIO_TYPE_IOCTL) {
-        /* XXPOLICY */
-        if (!vdev_readable(vd)) {
-            zio->io_error = ENXIO;
-            return (ZIO_PIPELINE_CONTINUE);
-        }
-
         switch (zio->io_cmd) {
         case DKIOCFLUSHWRITECACHE:
             zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,

Also available in: Atom PDF