Set elevator for DM devices despite vdev_wholedisk
authorPrakash Surya <surya1@llnl.gov>
Sat, 15 Dec 2012 00:16:35 +0000 (16:16 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 18 Dec 2012 23:12:40 +0000 (15:12 -0800)
The current state of udev and devicer-mapper devices makes it difficult
to construct a mapping of DM partitions and their underlying DM device.
For example, with a /dev directory with the following contents:

    $ ls -d /dev/dm-*
    /dev/dm-0
    /dev/dm-1
    /dev/dm-2
    /dev/dm-3

it is not immediately apparent if these are completely separate devices,
or partitions and real devices intermixed. In contrast, SCSI devices
would appear as so:

    $ ls -d /dev/sd*
    /dev/sda
    /dev/sda1
    /dev/sdb
    /dev/sdb1

Here, one can immediately determine that there are two devices (sda and
sdb), each containing a single partition. The lack of a predictable and
consistent mapping from DM devices to DM device partitions makes it
difficult for user space to process these devices the same way it does
SCSI devices.

As a result, the ZFS utilities do not partition DM devices, and instead
set the "vdev_wholedisk" label to 0 and treat them as partitions. This
has the side effect that, even if ZFS has sole ownership of the device,
the IO scheduler will not be modified because it is treated as a
partition.

This change adds an exception for DM devices in vdev_elevator_switch,
allowing the elevator to be modified even though the "vdev_wholedisk"
property is not set.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1149

module/zfs/vdev_disk.c

index 8df43d1..3f9b624 100644 (file)
@@ -121,8 +121,15 @@ vdev_elevator_switch(vdev_t *v, char *elevator)
        char *device = bdev->bd_disk->disk_name;
        int error;
 
-       /* Skip devices which are not whole disks (partitions) */
-       if (!v->vdev_wholedisk)
+       /*
+        * Skip devices which are not whole disks (partitions).
+        * Device-mapper devices are excepted since they may be whole
+        * disks despite the vdev_wholedisk flag, in which case we can
+        * and should switch the elevator. If the device-mapper device
+        * does not have an elevator (i.e. dm-raid, dm-crypt, etc.) the
+        * "Skip devices without schedulers" check below will fail.
+        */
+       if (!v->vdev_wholedisk && strncmp(device, "dm-", 3) != 0)
                return (0);
 
        /* Skip devices without schedulers (loop, ram, dm, etc) */