]> granicus.if.org Git - zfs/commitdiff
Set default zvol elevator to noop
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 5 Oct 2012 17:39:35 +0000 (10:39 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 5 Oct 2012 19:39:59 +0000 (12:39 -0700)
It doesn't make sense for a zvol to use the default system I/O
scheduler because it is a virtual device.  Therefore, we change
the default scheduler to 'noop' for zvols provided that the
elevator_change() function is available.  This interface has
been available since Linux 2.6.36 and appears in the RHEL 6.x
kernels.

We deliberately do not implement the method for older kernels
because it was racy and could result in system crashes.  It's
better to simply manually tune the scheduler for these kernels.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1017

module/zfs/zvol.c

index b07476c4208507cbb9849a0317f51a4a6f1b7d71..c3bd25c3b610be4ea1a63f7ade350fa51bbedc12 100644 (file)
@@ -1159,6 +1159,7 @@ static zvol_state_t *
 zvol_alloc(dev_t dev, const char *name)
 {
        zvol_state_t *zv;
+       int error = 0;
 
        zv = kmem_zalloc(sizeof (zvol_state_t), KM_SLEEP);
        if (zv == NULL)
@@ -1168,6 +1169,15 @@ zvol_alloc(dev_t dev, const char *name)
        if (zv->zv_queue == NULL)
                goto out_kmem;
 
+#ifdef HAVE_ELEVATOR_CHANGE
+       error = elevator_change(zv->zv_queue, "noop");
+#endif /* HAVE_ELEVATOR_CHANGE */
+       if (error) {
+               printk("ZFS: Unable to set \"%s\" scheduler for zvol %s: %d\n",
+                   "noop", name, error);
+               goto out_queue;
+       }
+
 #ifdef HAVE_BLK_QUEUE_FLUSH
        blk_queue_flush(zv->zv_queue, VDEV_REQ_FLUSH | VDEV_REQ_FUA);
 #else