2010-08-26 18:45:02 +00:00
|
|
|
/*
|
|
|
|
* CDDL HEADER START
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the terms of the
|
|
|
|
* Common Development and Distribution License (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
*
|
|
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
|
|
* See the License for the specific language governing permissions
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
|
|
*
|
|
|
|
* CDDL HEADER END
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2008-2010 Lawrence Livermore National Security, LLC.
|
|
|
|
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
|
|
|
|
* Rewritten for Linux by Brian Behlendorf <behlendorf1@llnl.gov>.
|
|
|
|
* LLNL-CODE-403049.
|
2016-05-23 17:41:29 +00:00
|
|
|
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
|
2010-08-26 18:45:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/zfs_context.h>
|
|
|
|
#include <sys/spa.h>
|
|
|
|
#include <sys/vdev_disk.h>
|
|
|
|
#include <sys/vdev_impl.h>
|
2016-07-22 15:52:49 +00:00
|
|
|
#include <sys/abd.h>
|
2010-08-26 18:45:02 +00:00
|
|
|
#include <sys/fs/zfs.h>
|
|
|
|
#include <sys/zio.h>
|
|
|
|
#include <sys/sunldi.h>
|
|
|
|
|
2011-02-07 21:54:59 +00:00
|
|
|
char *zfs_vdev_scheduler = VDEV_SCHEDULER;
|
2013-02-27 01:02:27 +00:00
|
|
|
static void *zfs_vdev_holder = VDEV_HOLDER;
|
2011-02-07 21:54:59 +00:00
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
/*
|
|
|
|
* Virtual device vector for disks.
|
|
|
|
*/
|
|
|
|
typedef struct dio_request {
|
|
|
|
zio_t *dr_zio; /* Parent ZIO */
|
2015-10-13 21:13:52 +00:00
|
|
|
atomic_t dr_ref; /* References */
|
2010-08-26 18:45:02 +00:00
|
|
|
int dr_error; /* Bio error */
|
|
|
|
int dr_bio_count; /* Count of bio's */
|
2013-11-01 19:26:11 +00:00
|
|
|
struct bio *dr_bio[0]; /* Attached bio's */
|
2010-08-26 18:45:02 +00:00
|
|
|
} dio_request_t;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_OPEN_BDEV_EXCLUSIVE
|
|
|
|
static fmode_t
|
|
|
|
vdev_bdev_mode(int smode)
|
|
|
|
{
|
|
|
|
fmode_t mode = 0;
|
|
|
|
|
|
|
|
ASSERT3S(smode & (FREAD | FWRITE), !=, 0);
|
|
|
|
|
|
|
|
if (smode & FREAD)
|
|
|
|
mode |= FMODE_READ;
|
|
|
|
|
|
|
|
if (smode & FWRITE)
|
|
|
|
mode |= FMODE_WRITE;
|
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
return (mode);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
static int
|
|
|
|
vdev_bdev_mode(int smode)
|
|
|
|
{
|
|
|
|
int mode = 0;
|
|
|
|
|
|
|
|
ASSERT3S(smode & (FREAD | FWRITE), !=, 0);
|
|
|
|
|
|
|
|
if ((smode & FREAD) && !(smode & FWRITE))
|
|
|
|
mode = MS_RDONLY;
|
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
return (mode);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
#endif /* HAVE_OPEN_BDEV_EXCLUSIVE */
|
|
|
|
|
|
|
|
static uint64_t
|
|
|
|
bdev_capacity(struct block_device *bdev)
|
|
|
|
{
|
|
|
|
struct hd_struct *part = bdev->bd_part;
|
|
|
|
|
|
|
|
/* The partition capacity referenced by the block device */
|
|
|
|
if (part)
|
2011-05-26 23:48:16 +00:00
|
|
|
return (part->nr_sects << 9);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
|
|
|
/* Otherwise assume the full device capacity */
|
2011-05-26 23:48:16 +00:00
|
|
|
return (get_capacity(bdev->bd_disk) << 9);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
2010-09-27 22:30:14 +00:00
|
|
|
static void
|
|
|
|
vdev_disk_error(zio_t *zio)
|
|
|
|
{
|
|
|
|
#ifdef ZFS_DEBUG
|
2010-10-01 23:54:52 +00:00
|
|
|
printk("ZFS: zio error=%d type=%d offset=%llu size=%llu "
|
2016-02-29 18:05:23 +00:00
|
|
|
"flags=%x\n", zio->io_error, zio->io_type,
|
2010-09-27 22:30:14 +00:00
|
|
|
(u_longlong_t)zio->io_offset, (u_longlong_t)zio->io_size,
|
2016-02-29 18:05:23 +00:00
|
|
|
zio->io_flags);
|
2010-09-27 22:30:14 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-02-07 21:54:59 +00:00
|
|
|
/*
|
|
|
|
* Use the Linux 'noop' elevator for zfs managed block devices. This
|
|
|
|
* strikes the ideal balance by allowing the zfs elevator to do all
|
|
|
|
* request ordering and prioritization. While allowing the Linux
|
|
|
|
* elevator to do the maximum front/back merging allowed by the
|
|
|
|
* physical device. This yields the largest possible requests for
|
|
|
|
* the device with the lowest total overhead.
|
|
|
|
*/
|
|
|
|
static int
|
2011-02-25 19:26:41 +00:00
|
|
|
vdev_elevator_switch(vdev_t *v, char *elevator)
|
2011-02-07 21:54:59 +00:00
|
|
|
{
|
2011-02-25 19:26:41 +00:00
|
|
|
vdev_disk_t *vd = v->vdev_tsd;
|
|
|
|
struct block_device *bdev = vd->vd_bdev;
|
|
|
|
struct request_queue *q = bdev_get_queue(bdev);
|
|
|
|
char *device = bdev->bd_disk->disk_name;
|
2011-04-22 20:50:17 +00:00
|
|
|
int error;
|
2011-02-25 19:26:41 +00:00
|
|
|
|
Set elevator for DM devices despite vdev_wholedisk
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
2012-12-15 00:16:35 +00:00
|
|
|
/*
|
|
|
|
* 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)
|
2011-03-10 21:34:17 +00:00
|
|
|
return (0);
|
|
|
|
|
2011-02-25 19:26:41 +00:00
|
|
|
/* Skip devices without schedulers (loop, ram, dm, etc) */
|
|
|
|
if (!q->elevator || !blk_queue_stackable(q))
|
|
|
|
return (0);
|
2011-02-07 21:54:59 +00:00
|
|
|
|
2011-02-25 19:26:41 +00:00
|
|
|
/* Leave existing scheduler when set to "none" */
|
2016-04-14 07:58:09 +00:00
|
|
|
if ((strncmp(elevator, "none", 4) == 0) && (strlen(elevator) == 4))
|
2011-02-07 21:54:59 +00:00
|
|
|
return (0);
|
|
|
|
|
2012-08-26 20:38:06 +00:00
|
|
|
#ifdef HAVE_ELEVATOR_CHANGE
|
|
|
|
error = elevator_change(q, elevator);
|
|
|
|
#else
|
2013-11-01 19:26:11 +00:00
|
|
|
/*
|
|
|
|
* For pre-2.6.36 kernels elevator_change() is not available.
|
2012-08-26 20:38:06 +00:00
|
|
|
* Therefore we fall back to using a usermodehelper to echo the
|
|
|
|
* elevator into sysfs; This requires /bin/echo and sysfs to be
|
|
|
|
* mounted which may not be true early in the boot process.
|
|
|
|
*/
|
2013-11-01 19:26:11 +00:00
|
|
|
#define SET_SCHEDULER_CMD \
|
2012-08-26 20:38:06 +00:00
|
|
|
"exec 0</dev/null " \
|
|
|
|
" 1>/sys/block/%s/queue/scheduler " \
|
|
|
|
" 2>/dev/null; " \
|
|
|
|
"echo %s"
|
|
|
|
|
|
|
|
{
|
|
|
|
char *argv[] = { "/bin/sh", "-c", NULL, NULL };
|
|
|
|
char *envp[] = { NULL };
|
|
|
|
|
|
|
|
argv[2] = kmem_asprintf(SET_SCHEDULER_CMD, device, elevator);
|
2013-01-09 23:46:31 +00:00
|
|
|
error = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
|
2012-08-26 20:38:06 +00:00
|
|
|
strfree(argv[2]);
|
|
|
|
}
|
|
|
|
#endif /* HAVE_ELEVATOR_CHANGE */
|
2011-02-07 21:54:59 +00:00
|
|
|
if (error)
|
|
|
|
printk("ZFS: Unable to set \"%s\" scheduler for %s (%s): %d\n",
|
2013-11-01 19:26:11 +00:00
|
|
|
elevator, v->vdev_path, device, error);
|
2011-02-07 21:54:59 +00:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2012-07-11 13:06:32 +00:00
|
|
|
/*
|
|
|
|
* Expanding a whole disk vdev involves invoking BLKRRPART on the
|
|
|
|
* whole disk device. This poses a problem, because BLKRRPART will
|
|
|
|
* return EBUSY if one of the disk's partitions is open. That's why
|
|
|
|
* we have to do it here, just before opening the data partition.
|
|
|
|
* Unfortunately, BLKRRPART works by dropping all partitions and
|
|
|
|
* recreating them, which means that for a short time window, all
|
|
|
|
* /dev/sdxN device files disappear (until udev recreates them).
|
|
|
|
* This means two things:
|
|
|
|
* - When we open the data partition just after a BLKRRPART, we
|
|
|
|
* can't do it using the normal device file path because of the
|
|
|
|
* obvious race condition with udev. Instead, we use reliable
|
|
|
|
* kernel APIs to get a handle to the new partition device from
|
|
|
|
* the whole disk device.
|
|
|
|
* - Because vdev_disk_open() initially needs to find the device
|
|
|
|
* using its path, multiple vdev_disk_open() invocations in
|
|
|
|
* short succession on the same disk with BLKRRPARTs in the
|
|
|
|
* middle have a high probability of failure (because of the
|
|
|
|
* race condition with udev). A typical situation where this
|
|
|
|
* might happen is when the zpool userspace tool does a
|
|
|
|
* TRYIMPORT immediately followed by an IMPORT. For this
|
|
|
|
* reason, we only invoke BLKRRPART in the module when strictly
|
|
|
|
* necessary (zpool online -e case), and rely on userspace to
|
|
|
|
* do it when possible.
|
|
|
|
*/
|
|
|
|
static struct block_device *
|
|
|
|
vdev_disk_rrpart(const char *path, int mode, vdev_disk_t *vd)
|
|
|
|
{
|
|
|
|
#if defined(HAVE_3ARG_BLKDEV_GET) && defined(HAVE_GET_GENDISK)
|
|
|
|
struct block_device *bdev, *result = ERR_PTR(-ENXIO);
|
|
|
|
struct gendisk *disk;
|
|
|
|
int error, partno;
|
|
|
|
|
2013-02-27 01:02:27 +00:00
|
|
|
bdev = vdev_bdev_open(path, vdev_bdev_mode(mode), zfs_vdev_holder);
|
2012-07-11 13:06:32 +00:00
|
|
|
if (IS_ERR(bdev))
|
2013-11-01 19:26:11 +00:00
|
|
|
return (bdev);
|
2012-07-11 13:06:32 +00:00
|
|
|
|
|
|
|
disk = get_gendisk(bdev->bd_dev, &partno);
|
|
|
|
vdev_bdev_close(bdev, vdev_bdev_mode(mode));
|
|
|
|
|
|
|
|
if (disk) {
|
|
|
|
bdev = bdget(disk_devt(disk));
|
|
|
|
if (bdev) {
|
|
|
|
error = blkdev_get(bdev, vdev_bdev_mode(mode), vd);
|
|
|
|
if (error == 0)
|
|
|
|
error = ioctl_by_bdev(bdev, BLKRRPART, 0);
|
|
|
|
vdev_bdev_close(bdev, vdev_bdev_mode(mode));
|
|
|
|
}
|
|
|
|
|
|
|
|
bdev = bdget_disk(disk, partno);
|
|
|
|
if (bdev) {
|
|
|
|
error = blkdev_get(bdev,
|
|
|
|
vdev_bdev_mode(mode) | FMODE_EXCL, vd);
|
|
|
|
if (error == 0)
|
|
|
|
result = bdev;
|
|
|
|
}
|
|
|
|
put_disk(disk);
|
|
|
|
}
|
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
return (result);
|
2012-07-11 13:06:32 +00:00
|
|
|
#else
|
2013-11-01 19:26:11 +00:00
|
|
|
return (ERR_PTR(-EOPNOTSUPP));
|
2012-07-11 13:06:32 +00:00
|
|
|
#endif /* defined(HAVE_3ARG_BLKDEV_GET) && defined(HAVE_GET_GENDISK) */
|
|
|
|
}
|
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
static int
|
2012-01-24 02:43:32 +00:00
|
|
|
vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
|
|
|
|
uint64_t *ashift)
|
2010-08-26 18:45:02 +00:00
|
|
|
{
|
2012-07-11 13:06:32 +00:00
|
|
|
struct block_device *bdev = ERR_PTR(-ENXIO);
|
2010-08-26 18:45:02 +00:00
|
|
|
vdev_disk_t *vd;
|
2016-04-19 18:19:12 +00:00
|
|
|
int count = 0, mode, block_size;
|
2010-08-26 18:45:02 +00:00
|
|
|
|
|
|
|
/* Must have a pathname and it must be absolute. */
|
|
|
|
if (v->vdev_path == NULL || v->vdev_path[0] != '/') {
|
|
|
|
v->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
|
2016-04-19 18:19:12 +00:00
|
|
|
return (SET_ERROR(EINVAL));
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
2013-02-26 19:25:55 +00:00
|
|
|
/*
|
|
|
|
* Reopen the device if it's not currently open. Otherwise,
|
|
|
|
* just update the physical size of the device.
|
|
|
|
*/
|
|
|
|
if (v->vdev_tsd != NULL) {
|
|
|
|
ASSERT(v->vdev_reopening);
|
|
|
|
vd = v->vdev_tsd;
|
|
|
|
goto skip_open;
|
|
|
|
}
|
|
|
|
|
2014-11-21 00:09:39 +00:00
|
|
|
vd = kmem_zalloc(sizeof (vdev_disk_t), KM_SLEEP);
|
2010-08-26 18:45:02 +00:00
|
|
|
if (vd == NULL)
|
2016-04-19 18:19:12 +00:00
|
|
|
return (SET_ERROR(ENOMEM));
|
2010-08-26 18:45:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Devices are always opened by the path provided at configuration
|
|
|
|
* time. This means that if the provided path is a udev by-id path
|
|
|
|
* then drives may be recabled without an issue. If the provided
|
2013-03-30 02:27:50 +00:00
|
|
|
* path is a udev by-path path, then the physical location information
|
2010-08-26 18:45:02 +00:00
|
|
|
* will be preserved. This can be critical for more complicated
|
|
|
|
* configurations where drives are located in specific physical
|
|
|
|
* locations to maximize the systems tolerence to component failure.
|
2013-03-30 02:27:50 +00:00
|
|
|
* Alternatively, you can provide your own udev rule to flexibly map
|
2010-08-26 18:45:02 +00:00
|
|
|
* the drives as you see fit. It is not advised that you use the
|
2013-03-30 02:27:50 +00:00
|
|
|
* /dev/[hd]d devices which may be reordered due to probing order.
|
2010-08-26 18:45:02 +00:00
|
|
|
* Devices in the wrong locations will be detected by the higher
|
|
|
|
* level vdev validation.
|
2016-04-19 18:19:12 +00:00
|
|
|
*
|
|
|
|
* The specified paths may be briefly removed and recreated in
|
|
|
|
* response to udev events. This should be exceptionally unlikely
|
|
|
|
* because the zpool command makes every effort to verify these paths
|
|
|
|
* have already settled prior to reaching this point. Therefore,
|
|
|
|
* a ENOENT failure at this point is highly likely to be transient
|
|
|
|
* and it is reasonable to sleep and retry before giving up. In
|
|
|
|
* practice delays have been observed to be on the order of 100ms.
|
2010-08-26 18:45:02 +00:00
|
|
|
*/
|
|
|
|
mode = spa_mode(v->vdev_spa);
|
2012-07-11 13:06:32 +00:00
|
|
|
if (v->vdev_wholedisk && v->vdev_expanding)
|
|
|
|
bdev = vdev_disk_rrpart(v->vdev_path, mode, vd);
|
2016-04-19 18:19:12 +00:00
|
|
|
|
|
|
|
while (IS_ERR(bdev) && count < 50) {
|
2013-02-27 01:02:27 +00:00
|
|
|
bdev = vdev_bdev_open(v->vdev_path,
|
|
|
|
vdev_bdev_mode(mode), zfs_vdev_holder);
|
2016-04-19 18:19:12 +00:00
|
|
|
if (unlikely(PTR_ERR(bdev) == -ENOENT)) {
|
|
|
|
msleep(10);
|
|
|
|
count++;
|
|
|
|
} else if (IS_ERR(bdev)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
if (IS_ERR(bdev)) {
|
2016-04-19 18:19:12 +00:00
|
|
|
dprintf("failed open v->vdev_path=%s, error=%d count=%d\n",
|
|
|
|
v->vdev_path, -PTR_ERR(bdev), count);
|
2013-11-01 19:26:11 +00:00
|
|
|
kmem_free(vd, sizeof (vdev_disk_t));
|
2016-04-19 18:19:12 +00:00
|
|
|
return (SET_ERROR(-PTR_ERR(bdev)));
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
v->vdev_tsd = vd;
|
|
|
|
vd->vd_bdev = bdev;
|
2013-02-26 19:25:55 +00:00
|
|
|
|
|
|
|
skip_open:
|
|
|
|
/* Determine the physical block size */
|
|
|
|
block_size = vdev_bdev_block_size(vd->vd_bdev);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
|
|
|
/* Clear the nowritecache bit, causes vdev_reopen() to try again. */
|
|
|
|
v->vdev_nowritecache = B_FALSE;
|
|
|
|
|
2015-08-29 16:01:07 +00:00
|
|
|
/* Inform the ZIO pipeline that we are non-rotational */
|
|
|
|
v->vdev_nonrot = blk_queue_nonrot(bdev_get_queue(vd->vd_bdev));
|
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
/* Physical volume size in bytes */
|
2013-02-26 19:25:55 +00:00
|
|
|
*psize = bdev_capacity(vd->vd_bdev);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2012-01-24 02:43:32 +00:00
|
|
|
/* TODO: report possible expansion size */
|
|
|
|
*max_psize = *psize;
|
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
/* Based on the minimum sector size set the block size */
|
2014-04-16 03:40:22 +00:00
|
|
|
*ashift = highbit64(MAX(block_size, SPA_MINBLOCKSIZE)) - 1;
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2011-02-07 21:54:59 +00:00
|
|
|
/* Try to set the io scheduler elevator algorithm */
|
2011-02-25 19:26:41 +00:00
|
|
|
(void) vdev_elevator_switch(v, zfs_vdev_scheduler);
|
2011-02-07 21:54:59 +00:00
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
return (0);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vdev_disk_close(vdev_t *v)
|
|
|
|
{
|
|
|
|
vdev_disk_t *vd = v->vdev_tsd;
|
|
|
|
|
2013-02-26 19:25:55 +00:00
|
|
|
if (v->vdev_reopening || vd == NULL)
|
2010-08-26 18:45:02 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (vd->vd_bdev != NULL)
|
|
|
|
vdev_bdev_close(vd->vd_bdev,
|
2013-11-01 19:26:11 +00:00
|
|
|
vdev_bdev_mode(spa_mode(v->vdev_spa)));
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
kmem_free(vd, sizeof (vdev_disk_t));
|
2010-08-26 18:45:02 +00:00
|
|
|
v->vdev_tsd = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static dio_request_t *
|
|
|
|
vdev_disk_dio_alloc(int bio_count)
|
|
|
|
{
|
|
|
|
dio_request_t *dr;
|
|
|
|
int i;
|
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
dr = kmem_zalloc(sizeof (dio_request_t) +
|
2014-11-21 00:09:39 +00:00
|
|
|
sizeof (struct bio *) * bio_count, KM_SLEEP);
|
2010-08-26 18:45:02 +00:00
|
|
|
if (dr) {
|
|
|
|
atomic_set(&dr->dr_ref, 0);
|
|
|
|
dr->dr_bio_count = bio_count;
|
|
|
|
dr->dr_error = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < dr->dr_bio_count; i++)
|
|
|
|
dr->dr_bio[i] = NULL;
|
|
|
|
}
|
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
return (dr);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vdev_disk_dio_free(dio_request_t *dr)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < dr->dr_bio_count; i++)
|
|
|
|
if (dr->dr_bio[i])
|
|
|
|
bio_put(dr->dr_bio[i]);
|
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
kmem_free(dr, sizeof (dio_request_t) +
|
|
|
|
sizeof (struct bio *) * dr->dr_bio_count);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vdev_disk_dio_get(dio_request_t *dr)
|
|
|
|
{
|
|
|
|
atomic_inc(&dr->dr_ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vdev_disk_dio_put(dio_request_t *dr)
|
|
|
|
{
|
|
|
|
int rc = atomic_dec_return(&dr->dr_ref);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the dio_request when the last reference is dropped and
|
|
|
|
* ensure zio_interpret is called only once with the correct zio
|
|
|
|
*/
|
|
|
|
if (rc == 0) {
|
|
|
|
zio_t *zio = dr->dr_zio;
|
|
|
|
int error = dr->dr_error;
|
|
|
|
|
|
|
|
vdev_disk_dio_free(dr);
|
|
|
|
|
|
|
|
if (zio) {
|
|
|
|
zio->io_error = error;
|
2010-09-27 22:30:14 +00:00
|
|
|
ASSERT3S(zio->io_error, >=, 0);
|
|
|
|
if (zio->io_error)
|
|
|
|
vdev_disk_error(zio);
|
2016-07-22 15:52:49 +00:00
|
|
|
|
2016-05-23 17:41:29 +00:00
|
|
|
zio_delay_interrupt(zio);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
return (rc);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
2015-09-23 15:55:15 +00:00
|
|
|
BIO_END_IO_PROTO(vdev_disk_physio_completion, bio, error)
|
2010-08-26 18:45:02 +00:00
|
|
|
{
|
|
|
|
dio_request_t *dr = bio->bi_private;
|
|
|
|
int rc;
|
|
|
|
|
2015-09-23 15:55:15 +00:00
|
|
|
if (dr->dr_error == 0) {
|
|
|
|
#ifdef HAVE_1ARG_BIO_END_IO_T
|
2017-07-24 02:37:12 +00:00
|
|
|
dr->dr_error = BIO_END_IO_ERROR(bio);
|
2015-09-23 15:55:15 +00:00
|
|
|
#else
|
|
|
|
if (error)
|
|
|
|
dr->dr_error = -(error);
|
|
|
|
else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
|
|
|
|
dr->dr_error = EIO;
|
|
|
|
#endif
|
|
|
|
}
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2016-08-31 06:26:43 +00:00
|
|
|
/* Drop reference acquired by __vdev_disk_physio */
|
2010-08-26 18:45:02 +00:00
|
|
|
rc = vdev_disk_dio_put(dr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
bio_map(struct bio *bio, void *bio_ptr, unsigned int bio_size)
|
|
|
|
{
|
|
|
|
unsigned int offset, size, i;
|
|
|
|
struct page *page;
|
|
|
|
|
|
|
|
offset = offset_in_page(bio_ptr);
|
|
|
|
for (i = 0; i < bio->bi_max_vecs; i++) {
|
|
|
|
size = PAGE_SIZE - offset;
|
|
|
|
|
|
|
|
if (bio_size <= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (size > bio_size)
|
|
|
|
size = bio_size;
|
|
|
|
|
2014-11-03 14:42:44 +00:00
|
|
|
if (is_vmalloc_addr(bio_ptr))
|
2010-08-26 18:45:02 +00:00
|
|
|
page = vmalloc_to_page(bio_ptr);
|
|
|
|
else
|
|
|
|
page = virt_to_page(bio_ptr);
|
|
|
|
|
2014-04-24 03:11:02 +00:00
|
|
|
/*
|
|
|
|
* Some network related block device uses tcp_sendpage, which
|
|
|
|
* doesn't behave well when using 0-count page, this is a
|
|
|
|
* safety net to catch them.
|
|
|
|
*/
|
|
|
|
ASSERT3S(page_count(page), >, 0);
|
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
if (bio_add_page(bio, page, size, offset) != size)
|
|
|
|
break;
|
|
|
|
|
|
|
|
bio_ptr += size;
|
|
|
|
bio_size -= size;
|
|
|
|
offset = 0;
|
|
|
|
}
|
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
return (bio_size);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
2016-08-31 06:26:43 +00:00
|
|
|
static unsigned int
|
|
|
|
bio_map_abd_off(struct bio *bio, abd_t *abd, unsigned int size, size_t off)
|
|
|
|
{
|
|
|
|
if (abd_is_linear(abd))
|
|
|
|
return (bio_map(bio, ((char *)abd_to_buf(abd)) + off, size));
|
|
|
|
|
|
|
|
return (abd_scatter_bio_map_off(bio, abd, size, off));
|
|
|
|
}
|
|
|
|
|
2016-07-27 02:23:53 +00:00
|
|
|
static inline void
|
2016-07-27 17:55:32 +00:00
|
|
|
vdev_submit_bio_impl(struct bio *bio)
|
2016-07-27 02:23:53 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_1ARG_SUBMIT_BIO
|
|
|
|
submit_bio(bio);
|
|
|
|
#else
|
2016-07-27 17:55:32 +00:00
|
|
|
submit_bio(0, bio);
|
2016-07-27 02:23:53 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
zvol processing should use struct bio
Internally, zvols are files exposed through the block device API. This
is intended to reduce overhead when things require block devices.
However, the ZoL zvol code emulates a traditional block device in that
it has a top half and a bottom half. This is an unnecessary source of
overhead that does not exist on any other OpenZFS platform does this.
This patch removes it. Early users of this patch reported double digit
performance gains in IOPS on zvols in the range of 50% to 80%.
Comments in the code suggest that the current implementation was done to
obtain IO merging from Linux's IO elevator. However, the DMU already
does write merging while arc_read() should implicitly merge read IOs
because only 1 thread is permitted to fetch the buffer into ARC. In
addition, commercial ZFSOnLinux distributions report that regular files
are more performant than zvols under the current implementation, and the
main consumers of zvols are VMs and iSCSI targets, which have their own
elevators to merge IOs.
Some minor refactoring allows us to register zfs_request() as our
->make_request() handler in place of the generic_make_request()
function. This eliminates the layer of code that broke IO requests on
zvols into a top half and a bottom half. This has several benefits:
1. No per zvol spinlocks.
2. No redundant IO elevator processing.
3. Interrupts are disabled only when actually necessary.
4. No redispatching of IOs when all taskq threads are busy.
5. Linux's page out routines will properly block.
6. Many autotools checks become obsolete.
An unfortunate consequence of eliminating the layer that
generic_make_request() is that we no longer calls the instrumentation
hooks for block IO accounting. Those hooks are GPL-exported, so we
cannot call them ourselves and consequently, we lose the ability to do
IO monitoring via iostat. Since zvols are internally files mapped as
block devices, this should be okay. Anyone who is willing to accept the
performance penalty for the block IO layer's accounting could use the
loop device in between the zvol and its consumer. Alternatively, perf
and ftrace likely could be used. Also, tools like latencytop will still
work. Tools such as latencytop sometimes provide a better view of
performance bottlenecks than the traditional block IO accounting tools
do.
Lastly, if direct reclaim occurs during spacemap loading and swap is on
a zvol, this code will deadlock. That deadlock could already occur with
sync=always on zvols. Given that swap on zvols is not yet production
ready, this is not a blocker.
Signed-off-by: Richard Yao <ryao@gentoo.org>
2014-07-04 22:43:47 +00:00
|
|
|
static inline void
|
2016-07-27 17:55:32 +00:00
|
|
|
vdev_submit_bio(struct bio *bio)
|
zvol processing should use struct bio
Internally, zvols are files exposed through the block device API. This
is intended to reduce overhead when things require block devices.
However, the ZoL zvol code emulates a traditional block device in that
it has a top half and a bottom half. This is an unnecessary source of
overhead that does not exist on any other OpenZFS platform does this.
This patch removes it. Early users of this patch reported double digit
performance gains in IOPS on zvols in the range of 50% to 80%.
Comments in the code suggest that the current implementation was done to
obtain IO merging from Linux's IO elevator. However, the DMU already
does write merging while arc_read() should implicitly merge read IOs
because only 1 thread is permitted to fetch the buffer into ARC. In
addition, commercial ZFSOnLinux distributions report that regular files
are more performant than zvols under the current implementation, and the
main consumers of zvols are VMs and iSCSI targets, which have their own
elevators to merge IOs.
Some minor refactoring allows us to register zfs_request() as our
->make_request() handler in place of the generic_make_request()
function. This eliminates the layer of code that broke IO requests on
zvols into a top half and a bottom half. This has several benefits:
1. No per zvol spinlocks.
2. No redundant IO elevator processing.
3. Interrupts are disabled only when actually necessary.
4. No redispatching of IOs when all taskq threads are busy.
5. Linux's page out routines will properly block.
6. Many autotools checks become obsolete.
An unfortunate consequence of eliminating the layer that
generic_make_request() is that we no longer calls the instrumentation
hooks for block IO accounting. Those hooks are GPL-exported, so we
cannot call them ourselves and consequently, we lose the ability to do
IO monitoring via iostat. Since zvols are internally files mapped as
block devices, this should be okay. Anyone who is willing to accept the
performance penalty for the block IO layer's accounting could use the
loop device in between the zvol and its consumer. Alternatively, perf
and ftrace likely could be used. Also, tools like latencytop will still
work. Tools such as latencytop sometimes provide a better view of
performance bottlenecks than the traditional block IO accounting tools
do.
Lastly, if direct reclaim occurs during spacemap loading and swap is on
a zvol, this code will deadlock. That deadlock could already occur with
sync=always on zvols. Given that swap on zvols is not yet production
ready, this is not a blocker.
Signed-off-by: Richard Yao <ryao@gentoo.org>
2014-07-04 22:43:47 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_CURRENT_BIO_TAIL
|
|
|
|
struct bio **bio_tail = current->bio_tail;
|
|
|
|
current->bio_tail = NULL;
|
2016-07-27 17:55:32 +00:00
|
|
|
vdev_submit_bio_impl(bio);
|
zvol processing should use struct bio
Internally, zvols are files exposed through the block device API. This
is intended to reduce overhead when things require block devices.
However, the ZoL zvol code emulates a traditional block device in that
it has a top half and a bottom half. This is an unnecessary source of
overhead that does not exist on any other OpenZFS platform does this.
This patch removes it. Early users of this patch reported double digit
performance gains in IOPS on zvols in the range of 50% to 80%.
Comments in the code suggest that the current implementation was done to
obtain IO merging from Linux's IO elevator. However, the DMU already
does write merging while arc_read() should implicitly merge read IOs
because only 1 thread is permitted to fetch the buffer into ARC. In
addition, commercial ZFSOnLinux distributions report that regular files
are more performant than zvols under the current implementation, and the
main consumers of zvols are VMs and iSCSI targets, which have their own
elevators to merge IOs.
Some minor refactoring allows us to register zfs_request() as our
->make_request() handler in place of the generic_make_request()
function. This eliminates the layer of code that broke IO requests on
zvols into a top half and a bottom half. This has several benefits:
1. No per zvol spinlocks.
2. No redundant IO elevator processing.
3. Interrupts are disabled only when actually necessary.
4. No redispatching of IOs when all taskq threads are busy.
5. Linux's page out routines will properly block.
6. Many autotools checks become obsolete.
An unfortunate consequence of eliminating the layer that
generic_make_request() is that we no longer calls the instrumentation
hooks for block IO accounting. Those hooks are GPL-exported, so we
cannot call them ourselves and consequently, we lose the ability to do
IO monitoring via iostat. Since zvols are internally files mapped as
block devices, this should be okay. Anyone who is willing to accept the
performance penalty for the block IO layer's accounting could use the
loop device in between the zvol and its consumer. Alternatively, perf
and ftrace likely could be used. Also, tools like latencytop will still
work. Tools such as latencytop sometimes provide a better view of
performance bottlenecks than the traditional block IO accounting tools
do.
Lastly, if direct reclaim occurs during spacemap loading and swap is on
a zvol, this code will deadlock. That deadlock could already occur with
sync=always on zvols. Given that swap on zvols is not yet production
ready, this is not a blocker.
Signed-off-by: Richard Yao <ryao@gentoo.org>
2014-07-04 22:43:47 +00:00
|
|
|
current->bio_tail = bio_tail;
|
|
|
|
#else
|
|
|
|
struct bio_list *bio_list = current->bio_list;
|
|
|
|
current->bio_list = NULL;
|
2016-07-27 17:55:32 +00:00
|
|
|
vdev_submit_bio_impl(bio);
|
zvol processing should use struct bio
Internally, zvols are files exposed through the block device API. This
is intended to reduce overhead when things require block devices.
However, the ZoL zvol code emulates a traditional block device in that
it has a top half and a bottom half. This is an unnecessary source of
overhead that does not exist on any other OpenZFS platform does this.
This patch removes it. Early users of this patch reported double digit
performance gains in IOPS on zvols in the range of 50% to 80%.
Comments in the code suggest that the current implementation was done to
obtain IO merging from Linux's IO elevator. However, the DMU already
does write merging while arc_read() should implicitly merge read IOs
because only 1 thread is permitted to fetch the buffer into ARC. In
addition, commercial ZFSOnLinux distributions report that regular files
are more performant than zvols under the current implementation, and the
main consumers of zvols are VMs and iSCSI targets, which have their own
elevators to merge IOs.
Some minor refactoring allows us to register zfs_request() as our
->make_request() handler in place of the generic_make_request()
function. This eliminates the layer of code that broke IO requests on
zvols into a top half and a bottom half. This has several benefits:
1. No per zvol spinlocks.
2. No redundant IO elevator processing.
3. Interrupts are disabled only when actually necessary.
4. No redispatching of IOs when all taskq threads are busy.
5. Linux's page out routines will properly block.
6. Many autotools checks become obsolete.
An unfortunate consequence of eliminating the layer that
generic_make_request() is that we no longer calls the instrumentation
hooks for block IO accounting. Those hooks are GPL-exported, so we
cannot call them ourselves and consequently, we lose the ability to do
IO monitoring via iostat. Since zvols are internally files mapped as
block devices, this should be okay. Anyone who is willing to accept the
performance penalty for the block IO layer's accounting could use the
loop device in between the zvol and its consumer. Alternatively, perf
and ftrace likely could be used. Also, tools like latencytop will still
work. Tools such as latencytop sometimes provide a better view of
performance bottlenecks than the traditional block IO accounting tools
do.
Lastly, if direct reclaim occurs during spacemap loading and swap is on
a zvol, this code will deadlock. That deadlock could already occur with
sync=always on zvols. Given that swap on zvols is not yet production
ready, this is not a blocker.
Signed-off-by: Richard Yao <ryao@gentoo.org>
2014-07-04 22:43:47 +00:00
|
|
|
current->bio_list = bio_list;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
static int
|
2016-08-31 06:26:43 +00:00
|
|
|
__vdev_disk_physio(struct block_device *bdev, zio_t *zio,
|
|
|
|
size_t io_size, uint64_t io_offset, int rw, int flags)
|
2010-08-26 18:45:02 +00:00
|
|
|
{
|
2013-11-01 19:26:11 +00:00
|
|
|
dio_request_t *dr;
|
2016-08-31 06:26:43 +00:00
|
|
|
uint64_t abd_offset;
|
2010-08-26 18:45:02 +00:00
|
|
|
uint64_t bio_offset;
|
2016-07-27 17:55:32 +00:00
|
|
|
int bio_size, bio_count = 16;
|
2011-05-26 23:48:16 +00:00
|
|
|
int i = 0, error = 0;
|
2016-09-29 20:13:31 +00:00
|
|
|
#if defined(HAVE_BLK_QUEUE_HAVE_BLK_PLUG)
|
|
|
|
struct blk_plug plug;
|
|
|
|
#endif
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2016-08-31 06:26:43 +00:00
|
|
|
ASSERT(zio != NULL);
|
|
|
|
ASSERT3U(io_offset + io_size, <=, bdev->bd_inode->i_size);
|
2010-11-10 21:36:18 +00:00
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
retry:
|
|
|
|
dr = vdev_disk_dio_alloc(bio_count);
|
|
|
|
if (dr == NULL)
|
2013-11-01 19:26:11 +00:00
|
|
|
return (ENOMEM);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2010-10-01 17:57:56 +00:00
|
|
|
if (zio && !(zio->io_flags & (ZIO_FLAG_IO_RETRY | ZIO_FLAG_TRYHARD)))
|
2014-10-21 18:20:10 +00:00
|
|
|
bio_set_flags_failfast(bdev, &flags);
|
2010-10-01 17:57:56 +00:00
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
dr->dr_zio = zio;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When the IO size exceeds the maximum bio size for the request
|
|
|
|
* queue we are forced to break the IO in multiple bio's and wait
|
|
|
|
* for them all to complete. Ideally, all pool users will set
|
|
|
|
* their volume block size to match the maximum request size and
|
|
|
|
* the common case will be one bio per vdev IO request.
|
|
|
|
*/
|
2016-07-22 15:52:49 +00:00
|
|
|
|
2016-08-31 06:26:43 +00:00
|
|
|
abd_offset = 0;
|
|
|
|
bio_offset = io_offset;
|
|
|
|
bio_size = io_size;
|
2010-08-26 18:45:02 +00:00
|
|
|
for (i = 0; i <= dr->dr_bio_count; i++) {
|
|
|
|
|
|
|
|
/* Finished constructing bio's for given buffer */
|
|
|
|
if (bio_size <= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* By default only 'bio_count' bio's per dio are allowed.
|
|
|
|
* However, if we find ourselves in a situation where more
|
|
|
|
* are needed we allocate a larger dio and warn the user.
|
|
|
|
*/
|
|
|
|
if (dr->dr_bio_count == i) {
|
|
|
|
vdev_disk_dio_free(dr);
|
|
|
|
bio_count *= 2;
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2014-10-21 18:20:10 +00:00
|
|
|
/* bio_alloc() with __GFP_WAIT never returns NULL */
|
2014-11-03 20:15:08 +00:00
|
|
|
dr->dr_bio[i] = bio_alloc(GFP_NOIO,
|
2016-08-31 06:26:43 +00:00
|
|
|
MIN(abd_nr_pages_off(zio->io_abd, bio_size, abd_offset),
|
2016-12-12 18:46:26 +00:00
|
|
|
BIO_MAX_PAGES));
|
2014-10-21 18:20:10 +00:00
|
|
|
if (unlikely(dr->dr_bio[i] == NULL)) {
|
2010-08-26 18:45:02 +00:00
|
|
|
vdev_disk_dio_free(dr);
|
2013-11-01 19:26:11 +00:00
|
|
|
return (ENOMEM);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Matching put called by vdev_disk_physio_completion */
|
|
|
|
vdev_disk_dio_get(dr);
|
|
|
|
|
|
|
|
dr->dr_bio[i]->bi_bdev = bdev;
|
2014-03-28 07:08:21 +00:00
|
|
|
BIO_BI_SECTOR(dr->dr_bio[i]) = bio_offset >> 9;
|
2010-08-26 18:45:02 +00:00
|
|
|
dr->dr_bio[i]->bi_end_io = vdev_disk_physio_completion;
|
|
|
|
dr->dr_bio[i]->bi_private = dr;
|
2016-07-27 17:55:32 +00:00
|
|
|
bio_set_op_attrs(dr->dr_bio[i], rw, flags);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
|
|
|
/* Remaining size is returned to become the new size */
|
2016-08-31 06:26:43 +00:00
|
|
|
bio_size = bio_map_abd_off(dr->dr_bio[i], zio->io_abd,
|
2016-12-12 18:46:26 +00:00
|
|
|
bio_size, abd_offset);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
|
|
|
/* Advance in buffer and construct another bio if needed */
|
2016-08-31 06:26:43 +00:00
|
|
|
abd_offset += BIO_BI_SIZE(dr->dr_bio[i]);
|
2014-03-28 07:08:21 +00:00
|
|
|
bio_offset += BIO_BI_SIZE(dr->dr_bio[i]);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
zvol processing should use struct bio
Internally, zvols are files exposed through the block device API. This
is intended to reduce overhead when things require block devices.
However, the ZoL zvol code emulates a traditional block device in that
it has a top half and a bottom half. This is an unnecessary source of
overhead that does not exist on any other OpenZFS platform does this.
This patch removes it. Early users of this patch reported double digit
performance gains in IOPS on zvols in the range of 50% to 80%.
Comments in the code suggest that the current implementation was done to
obtain IO merging from Linux's IO elevator. However, the DMU already
does write merging while arc_read() should implicitly merge read IOs
because only 1 thread is permitted to fetch the buffer into ARC. In
addition, commercial ZFSOnLinux distributions report that regular files
are more performant than zvols under the current implementation, and the
main consumers of zvols are VMs and iSCSI targets, which have their own
elevators to merge IOs.
Some minor refactoring allows us to register zfs_request() as our
->make_request() handler in place of the generic_make_request()
function. This eliminates the layer of code that broke IO requests on
zvols into a top half and a bottom half. This has several benefits:
1. No per zvol spinlocks.
2. No redundant IO elevator processing.
3. Interrupts are disabled only when actually necessary.
4. No redispatching of IOs when all taskq threads are busy.
5. Linux's page out routines will properly block.
6. Many autotools checks become obsolete.
An unfortunate consequence of eliminating the layer that
generic_make_request() is that we no longer calls the instrumentation
hooks for block IO accounting. Those hooks are GPL-exported, so we
cannot call them ourselves and consequently, we lose the ability to do
IO monitoring via iostat. Since zvols are internally files mapped as
block devices, this should be okay. Anyone who is willing to accept the
performance penalty for the block IO layer's accounting could use the
loop device in between the zvol and its consumer. Alternatively, perf
and ftrace likely could be used. Also, tools like latencytop will still
work. Tools such as latencytop sometimes provide a better view of
performance bottlenecks than the traditional block IO accounting tools
do.
Lastly, if direct reclaim occurs during spacemap loading and swap is on
a zvol, this code will deadlock. That deadlock could already occur with
sync=always on zvols. Given that swap on zvols is not yet production
ready, this is not a blocker.
Signed-off-by: Richard Yao <ryao@gentoo.org>
2014-07-04 22:43:47 +00:00
|
|
|
/* Extra reference to protect dio_request during vdev_submit_bio */
|
2010-08-26 18:45:02 +00:00
|
|
|
vdev_disk_dio_get(dr);
|
|
|
|
|
2016-09-29 20:13:31 +00:00
|
|
|
#if defined(HAVE_BLK_QUEUE_HAVE_BLK_PLUG)
|
|
|
|
if (dr->dr_bio_count > 1)
|
|
|
|
blk_start_plug(&plug);
|
|
|
|
#endif
|
|
|
|
|
2010-08-26 18:45:02 +00:00
|
|
|
/* Submit all bio's associated with this dio */
|
|
|
|
for (i = 0; i < dr->dr_bio_count; i++)
|
|
|
|
if (dr->dr_bio[i])
|
2016-07-27 17:55:32 +00:00
|
|
|
vdev_submit_bio(dr->dr_bio[i]);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2016-09-29 20:13:31 +00:00
|
|
|
#if defined(HAVE_BLK_QUEUE_HAVE_BLK_PLUG)
|
|
|
|
if (dr->dr_bio_count > 1)
|
|
|
|
blk_finish_plug(&plug);
|
|
|
|
#endif
|
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
(void) vdev_disk_dio_put(dr);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
return (error);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
2017-07-24 02:37:12 +00:00
|
|
|
BIO_END_IO_PROTO(vdev_disk_io_flush_completion, bio, error)
|
2010-08-26 18:45:02 +00:00
|
|
|
{
|
|
|
|
zio_t *zio = bio->bi_private;
|
2015-09-23 15:55:15 +00:00
|
|
|
#ifdef HAVE_1ARG_BIO_END_IO_T
|
2017-07-24 02:37:12 +00:00
|
|
|
zio->io_error = BIO_END_IO_ERROR(bio);
|
|
|
|
#else
|
|
|
|
zio->io_error = -error;
|
2015-09-23 15:55:15 +00:00
|
|
|
#endif
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2017-07-24 02:37:12 +00:00
|
|
|
if (zio->io_error && (zio->io_error == EOPNOTSUPP))
|
2010-08-26 18:45:02 +00:00
|
|
|
zio->io_vd->vdev_nowritecache = B_TRUE;
|
|
|
|
|
|
|
|
bio_put(bio);
|
2010-09-27 22:30:14 +00:00
|
|
|
ASSERT3S(zio->io_error, >=, 0);
|
|
|
|
if (zio->io_error)
|
|
|
|
vdev_disk_error(zio);
|
2010-08-26 18:45:02 +00:00
|
|
|
zio_interrupt(zio);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vdev_disk_io_flush(struct block_device *bdev, zio_t *zio)
|
|
|
|
{
|
|
|
|
struct request_queue *q;
|
|
|
|
struct bio *bio;
|
|
|
|
|
|
|
|
q = bdev_get_queue(bdev);
|
|
|
|
if (!q)
|
2013-11-01 19:26:11 +00:00
|
|
|
return (ENXIO);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2013-07-10 21:09:08 +00:00
|
|
|
bio = bio_alloc(GFP_NOIO, 0);
|
2014-10-21 18:20:10 +00:00
|
|
|
/* bio_alloc() with __GFP_WAIT never returns NULL */
|
|
|
|
if (unlikely(bio == NULL))
|
2013-11-01 19:26:11 +00:00
|
|
|
return (ENOMEM);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
|
|
|
bio->bi_end_io = vdev_disk_io_flush_completion;
|
|
|
|
bio->bi_private = zio;
|
|
|
|
bio->bi_bdev = bdev;
|
2016-12-30 22:03:59 +00:00
|
|
|
bio_set_flush(bio);
|
2016-07-27 17:55:32 +00:00
|
|
|
vdev_submit_bio(bio);
|
Invalidate Linux buffer cache on vdevs upon each flush
Userland tools such as blkid, grub2-probe and zdb will go through the
buffer cache. However, ZFS uses on submit_bio() to bypass the buffer
cache when performing IO operations on vdevs for efficiency purposes.
This permits the on-disk state and buffer cache to fall out of
synchronization. That causes seemingly random failures when tools
reading stale metadata from the buffer cache try to access references to
data that is no longer there.
A particularly bad failure this causes involves grub2-probe, which is
used by grub2-mkconfig. Ordinarily, a rootfs might be called
rpool/ROOT/gentoo. However, when a failure occurs in grub2-probe,
grub2-mkconfig will generate a configuration file containing
/ROOT/gentoo, which omits the pool name and causes a boot failure.
This is avoidable by calling invalidate_bdev() on each flush, which is a
simple way to ensure that all non-dirty pages are wiped. Since userland
tools rarely access vdevs directly, this should be a fancy noop >99.999%
of the time and have little impact on IO. We could have tried a finer
grained approach for the rare instances in which the vdevs are accessed
frequently by userland. However, that would require consideration of
corner cases and it is not worth the effort.
Memory-wise, it would have been better to use a Linux kernel API hook to
disable the buffer cache on such devices, but it provides us no way of
doing that, so we opt for this approach instead. We should revisit that
idea in the future when higher priority issues have been tackled.
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2150
2014-02-27 19:03:39 +00:00
|
|
|
invalidate_bdev(bdev);
|
2010-08-26 18:45:02 +00:00
|
|
|
|
2013-11-01 19:26:11 +00:00
|
|
|
return (0);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
2014-10-20 22:07:45 +00:00
|
|
|
static void
|
2010-08-26 18:45:02 +00:00
|
|
|
vdev_disk_io_start(zio_t *zio)
|
|
|
|
{
|
|
|
|
vdev_t *v = zio->io_vd;
|
|
|
|
vdev_disk_t *vd = v->vdev_tsd;
|
2016-07-27 17:55:32 +00:00
|
|
|
int rw, flags, error;
|
2010-08-26 18:45:02 +00:00
|
|
|
|
|
|
|
switch (zio->io_type) {
|
|
|
|
case ZIO_TYPE_IOCTL:
|
|
|
|
|
|
|
|
if (!vdev_readable(v)) {
|
2013-03-08 18:41:28 +00:00
|
|
|
zio->io_error = SET_ERROR(ENXIO);
|
2014-10-20 22:07:45 +00:00
|
|
|
zio_interrupt(zio);
|
|
|
|
return;
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (zio->io_cmd) {
|
|
|
|
case DKIOCFLUSHWRITECACHE:
|
|
|
|
|
|
|
|
if (zfs_nocacheflush)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (v->vdev_nowritecache) {
|
2013-03-08 18:41:28 +00:00
|
|
|
zio->io_error = SET_ERROR(ENOTSUP);
|
2010-08-26 18:45:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = vdev_disk_io_flush(vd->vd_bdev, zio);
|
|
|
|
if (error == 0)
|
2014-10-20 22:07:45 +00:00
|
|
|
return;
|
2010-08-26 18:45:02 +00:00
|
|
|
|
|
|
|
zio->io_error = error;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-03-08 18:41:28 +00:00
|
|
|
zio->io_error = SET_ERROR(ENOTSUP);
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
2014-10-20 22:07:45 +00:00
|
|
|
zio_execute(zio);
|
|
|
|
return;
|
2010-08-26 18:45:02 +00:00
|
|
|
case ZIO_TYPE_WRITE:
|
2016-07-27 17:55:32 +00:00
|
|
|
rw = WRITE;
|
Fix sync behavior for disk vdevs
Prior to b39c22b, which was first generally available in the 0.6.5
release as b39c22b, ZoL never actually submitted synchronous read or write
requests to the Linux block layer. This means the vdev_disk_dio_is_sync()
function had always returned false and, therefore, the completion in
dio_request_t.dr_comp was never actually used.
In b39c22b, synchronous ZIO operations were translated to synchronous
BIO requests in vdev_disk_io_start(). The follow-on commits 5592404 and
aa159af fixed several problems introduced by b39c22b. In particular,
5592404 introduced the new flag parameter "wait" to __vdev_disk_physio()
but under ZoL, since vdev_disk_physio() is never actually used, the wait
flag was always zero so the new code had no effect other than to cause
a bug in the use of the dio_request_t.dr_comp which was fixed by aa159af.
The original rationale for introducing synchronous operations in b39c22b
was to hurry certains requests through the BIO layer which would have
otherwise been subject to its unplug timer which would increase the
latency. This behavior of the unplug timer, however, went away during the
transition of the plug/unplug system between kernels 2.6.32 and 2.6.39.
To handle the unplug timer behavior on 2.6.32-2.6.35 kernels the
BIO_RW_UNPLUG flag is used as a hint to suppress the plugging behavior.
For kernels 2.6.36-2.6.38, the REQ_UNPLUG macro will be available and
ise used for the same purpose.
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4858
2016-07-08 15:33:01 +00:00
|
|
|
#if defined(HAVE_BLK_QUEUE_HAVE_BIO_RW_UNPLUG)
|
2016-07-27 17:55:32 +00:00
|
|
|
flags = (1 << BIO_RW_UNPLUG);
|
Fix sync behavior for disk vdevs
Prior to b39c22b, which was first generally available in the 0.6.5
release as b39c22b, ZoL never actually submitted synchronous read or write
requests to the Linux block layer. This means the vdev_disk_dio_is_sync()
function had always returned false and, therefore, the completion in
dio_request_t.dr_comp was never actually used.
In b39c22b, synchronous ZIO operations were translated to synchronous
BIO requests in vdev_disk_io_start(). The follow-on commits 5592404 and
aa159af fixed several problems introduced by b39c22b. In particular,
5592404 introduced the new flag parameter "wait" to __vdev_disk_physio()
but under ZoL, since vdev_disk_physio() is never actually used, the wait
flag was always zero so the new code had no effect other than to cause
a bug in the use of the dio_request_t.dr_comp which was fixed by aa159af.
The original rationale for introducing synchronous operations in b39c22b
was to hurry certains requests through the BIO layer which would have
otherwise been subject to its unplug timer which would increase the
latency. This behavior of the unplug timer, however, went away during the
transition of the plug/unplug system between kernels 2.6.32 and 2.6.39.
To handle the unplug timer behavior on 2.6.32-2.6.35 kernels the
BIO_RW_UNPLUG flag is used as a hint to suppress the plugging behavior.
For kernels 2.6.36-2.6.38, the REQ_UNPLUG macro will be available and
ise used for the same purpose.
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4858
2016-07-08 15:33:01 +00:00
|
|
|
#elif defined(REQ_UNPLUG)
|
2016-07-27 17:55:32 +00:00
|
|
|
flags = REQ_UNPLUG;
|
Fix sync behavior for disk vdevs
Prior to b39c22b, which was first generally available in the 0.6.5
release as b39c22b, ZoL never actually submitted synchronous read or write
requests to the Linux block layer. This means the vdev_disk_dio_is_sync()
function had always returned false and, therefore, the completion in
dio_request_t.dr_comp was never actually used.
In b39c22b, synchronous ZIO operations were translated to synchronous
BIO requests in vdev_disk_io_start(). The follow-on commits 5592404 and
aa159af fixed several problems introduced by b39c22b. In particular,
5592404 introduced the new flag parameter "wait" to __vdev_disk_physio()
but under ZoL, since vdev_disk_physio() is never actually used, the wait
flag was always zero so the new code had no effect other than to cause
a bug in the use of the dio_request_t.dr_comp which was fixed by aa159af.
The original rationale for introducing synchronous operations in b39c22b
was to hurry certains requests through the BIO layer which would have
otherwise been subject to its unplug timer which would increase the
latency. This behavior of the unplug timer, however, went away during the
transition of the plug/unplug system between kernels 2.6.32 and 2.6.39.
To handle the unplug timer behavior on 2.6.32-2.6.35 kernels the
BIO_RW_UNPLUG flag is used as a hint to suppress the plugging behavior.
For kernels 2.6.36-2.6.38, the REQ_UNPLUG macro will be available and
ise used for the same purpose.
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4858
2016-07-08 15:33:01 +00:00
|
|
|
#else
|
2016-07-27 17:55:32 +00:00
|
|
|
flags = 0;
|
Fix sync behavior for disk vdevs
Prior to b39c22b, which was first generally available in the 0.6.5
release as b39c22b, ZoL never actually submitted synchronous read or write
requests to the Linux block layer. This means the vdev_disk_dio_is_sync()
function had always returned false and, therefore, the completion in
dio_request_t.dr_comp was never actually used.
In b39c22b, synchronous ZIO operations were translated to synchronous
BIO requests in vdev_disk_io_start(). The follow-on commits 5592404 and
aa159af fixed several problems introduced by b39c22b. In particular,
5592404 introduced the new flag parameter "wait" to __vdev_disk_physio()
but under ZoL, since vdev_disk_physio() is never actually used, the wait
flag was always zero so the new code had no effect other than to cause
a bug in the use of the dio_request_t.dr_comp which was fixed by aa159af.
The original rationale for introducing synchronous operations in b39c22b
was to hurry certains requests through the BIO layer which would have
otherwise been subject to its unplug timer which would increase the
latency. This behavior of the unplug timer, however, went away during the
transition of the plug/unplug system between kernels 2.6.32 and 2.6.39.
To handle the unplug timer behavior on 2.6.32-2.6.35 kernels the
BIO_RW_UNPLUG flag is used as a hint to suppress the plugging behavior.
For kernels 2.6.36-2.6.38, the REQ_UNPLUG macro will be available and
ise used for the same purpose.
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4858
2016-07-08 15:33:01 +00:00
|
|
|
#endif
|
2010-08-26 18:45:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ZIO_TYPE_READ:
|
2016-07-27 17:55:32 +00:00
|
|
|
rw = READ;
|
Fix sync behavior for disk vdevs
Prior to b39c22b, which was first generally available in the 0.6.5
release as b39c22b, ZoL never actually submitted synchronous read or write
requests to the Linux block layer. This means the vdev_disk_dio_is_sync()
function had always returned false and, therefore, the completion in
dio_request_t.dr_comp was never actually used.
In b39c22b, synchronous ZIO operations were translated to synchronous
BIO requests in vdev_disk_io_start(). The follow-on commits 5592404 and
aa159af fixed several problems introduced by b39c22b. In particular,
5592404 introduced the new flag parameter "wait" to __vdev_disk_physio()
but under ZoL, since vdev_disk_physio() is never actually used, the wait
flag was always zero so the new code had no effect other than to cause
a bug in the use of the dio_request_t.dr_comp which was fixed by aa159af.
The original rationale for introducing synchronous operations in b39c22b
was to hurry certains requests through the BIO layer which would have
otherwise been subject to its unplug timer which would increase the
latency. This behavior of the unplug timer, however, went away during the
transition of the plug/unplug system between kernels 2.6.32 and 2.6.39.
To handle the unplug timer behavior on 2.6.32-2.6.35 kernels the
BIO_RW_UNPLUG flag is used as a hint to suppress the plugging behavior.
For kernels 2.6.36-2.6.38, the REQ_UNPLUG macro will be available and
ise used for the same purpose.
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4858
2016-07-08 15:33:01 +00:00
|
|
|
#if defined(HAVE_BLK_QUEUE_HAVE_BIO_RW_UNPLUG)
|
2016-07-27 17:55:32 +00:00
|
|
|
flags = (1 << BIO_RW_UNPLUG);
|
Fix sync behavior for disk vdevs
Prior to b39c22b, which was first generally available in the 0.6.5
release as b39c22b, ZoL never actually submitted synchronous read or write
requests to the Linux block layer. This means the vdev_disk_dio_is_sync()
function had always returned false and, therefore, the completion in
dio_request_t.dr_comp was never actually used.
In b39c22b, synchronous ZIO operations were translated to synchronous
BIO requests in vdev_disk_io_start(). The follow-on commits 5592404 and
aa159af fixed several problems introduced by b39c22b. In particular,
5592404 introduced the new flag parameter "wait" to __vdev_disk_physio()
but under ZoL, since vdev_disk_physio() is never actually used, the wait
flag was always zero so the new code had no effect other than to cause
a bug in the use of the dio_request_t.dr_comp which was fixed by aa159af.
The original rationale for introducing synchronous operations in b39c22b
was to hurry certains requests through the BIO layer which would have
otherwise been subject to its unplug timer which would increase the
latency. This behavior of the unplug timer, however, went away during the
transition of the plug/unplug system between kernels 2.6.32 and 2.6.39.
To handle the unplug timer behavior on 2.6.32-2.6.35 kernels the
BIO_RW_UNPLUG flag is used as a hint to suppress the plugging behavior.
For kernels 2.6.36-2.6.38, the REQ_UNPLUG macro will be available and
ise used for the same purpose.
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4858
2016-07-08 15:33:01 +00:00
|
|
|
#elif defined(REQ_UNPLUG)
|
2016-07-27 17:55:32 +00:00
|
|
|
flags = REQ_UNPLUG;
|
Fix sync behavior for disk vdevs
Prior to b39c22b, which was first generally available in the 0.6.5
release as b39c22b, ZoL never actually submitted synchronous read or write
requests to the Linux block layer. This means the vdev_disk_dio_is_sync()
function had always returned false and, therefore, the completion in
dio_request_t.dr_comp was never actually used.
In b39c22b, synchronous ZIO operations were translated to synchronous
BIO requests in vdev_disk_io_start(). The follow-on commits 5592404 and
aa159af fixed several problems introduced by b39c22b. In particular,
5592404 introduced the new flag parameter "wait" to __vdev_disk_physio()
but under ZoL, since vdev_disk_physio() is never actually used, the wait
flag was always zero so the new code had no effect other than to cause
a bug in the use of the dio_request_t.dr_comp which was fixed by aa159af.
The original rationale for introducing synchronous operations in b39c22b
was to hurry certains requests through the BIO layer which would have
otherwise been subject to its unplug timer which would increase the
latency. This behavior of the unplug timer, however, went away during the
transition of the plug/unplug system between kernels 2.6.32 and 2.6.39.
To handle the unplug timer behavior on 2.6.32-2.6.35 kernels the
BIO_RW_UNPLUG flag is used as a hint to suppress the plugging behavior.
For kernels 2.6.36-2.6.38, the REQ_UNPLUG macro will be available and
ise used for the same purpose.
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4858
2016-07-08 15:33:01 +00:00
|
|
|
#else
|
2016-07-27 17:55:32 +00:00
|
|
|
flags = 0;
|
Fix sync behavior for disk vdevs
Prior to b39c22b, which was first generally available in the 0.6.5
release as b39c22b, ZoL never actually submitted synchronous read or write
requests to the Linux block layer. This means the vdev_disk_dio_is_sync()
function had always returned false and, therefore, the completion in
dio_request_t.dr_comp was never actually used.
In b39c22b, synchronous ZIO operations were translated to synchronous
BIO requests in vdev_disk_io_start(). The follow-on commits 5592404 and
aa159af fixed several problems introduced by b39c22b. In particular,
5592404 introduced the new flag parameter "wait" to __vdev_disk_physio()
but under ZoL, since vdev_disk_physio() is never actually used, the wait
flag was always zero so the new code had no effect other than to cause
a bug in the use of the dio_request_t.dr_comp which was fixed by aa159af.
The original rationale for introducing synchronous operations in b39c22b
was to hurry certains requests through the BIO layer which would have
otherwise been subject to its unplug timer which would increase the
latency. This behavior of the unplug timer, however, went away during the
transition of the plug/unplug system between kernels 2.6.32 and 2.6.39.
To handle the unplug timer behavior on 2.6.32-2.6.35 kernels the
BIO_RW_UNPLUG flag is used as a hint to suppress the plugging behavior.
For kernels 2.6.36-2.6.38, the REQ_UNPLUG macro will be available and
ise used for the same purpose.
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4858
2016-07-08 15:33:01 +00:00
|
|
|
#endif
|
2010-08-26 18:45:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-03-08 18:41:28 +00:00
|
|
|
zio->io_error = SET_ERROR(ENOTSUP);
|
2014-10-20 22:07:45 +00:00
|
|
|
zio_interrupt(zio);
|
|
|
|
return;
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 17:41:29 +00:00
|
|
|
zio->io_target_timestamp = zio_handle_io_delay(zio);
|
2016-08-31 06:26:43 +00:00
|
|
|
error = __vdev_disk_physio(vd->vd_bdev, zio,
|
2016-07-27 17:55:32 +00:00
|
|
|
zio->io_size, zio->io_offset, rw, flags);
|
2010-08-26 18:45:02 +00:00
|
|
|
if (error) {
|
|
|
|
zio->io_error = error;
|
2014-10-20 22:07:45 +00:00
|
|
|
zio_interrupt(zio);
|
|
|
|
return;
|
2010-08-26 18:45:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vdev_disk_io_done(zio_t *zio)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If the device returned EIO, we revalidate the media. If it is
|
|
|
|
* determined the media has changed this triggers the asynchronous
|
|
|
|
* removal of the device from the configuration.
|
|
|
|
*/
|
|
|
|
if (zio->io_error == EIO) {
|
2013-11-01 19:26:11 +00:00
|
|
|
vdev_t *v = zio->io_vd;
|
2010-08-26 18:45:02 +00:00
|
|
|
vdev_disk_t *vd = v->vdev_tsd;
|
|
|
|
|
|
|
|
if (check_disk_change(vd->vd_bdev)) {
|
|
|
|
vdev_bdev_invalidate(vd->vd_bdev);
|
|
|
|
v->vdev_remove_wanted = B_TRUE;
|
|
|
|
spa_async_request(zio->io_spa, SPA_ASYNC_REMOVE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vdev_disk_hold(vdev_t *vd)
|
|
|
|
{
|
|
|
|
ASSERT(spa_config_held(vd->vdev_spa, SCL_STATE, RW_WRITER));
|
|
|
|
|
|
|
|
/* We must have a pathname, and it must be absolute. */
|
|
|
|
if (vd->vdev_path == NULL || vd->vdev_path[0] != '/')
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only prefetch path and devid info if the device has
|
|
|
|
* never been opened.
|
|
|
|
*/
|
|
|
|
if (vd->vdev_tsd != NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* XXX: Implement me as a vnode lookup for the device */
|
|
|
|
vd->vdev_name_vp = NULL;
|
|
|
|
vd->vdev_devid_vp = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vdev_disk_rele(vdev_t *vd)
|
|
|
|
{
|
|
|
|
ASSERT(spa_config_held(vd->vdev_spa, SCL_STATE, RW_WRITER));
|
|
|
|
|
|
|
|
/* XXX: Implement me as a vnode rele for the device */
|
|
|
|
}
|
|
|
|
|
|
|
|
vdev_ops_t vdev_disk_ops = {
|
|
|
|
vdev_disk_open,
|
|
|
|
vdev_disk_close,
|
|
|
|
vdev_default_asize,
|
|
|
|
vdev_disk_io_start,
|
|
|
|
vdev_disk_io_done,
|
|
|
|
NULL,
|
2017-05-13 00:28:03 +00:00
|
|
|
NULL,
|
2010-08-26 18:45:02 +00:00
|
|
|
vdev_disk_hold,
|
|
|
|
vdev_disk_rele,
|
|
|
|
VDEV_TYPE_DISK, /* name of this vdev type */
|
|
|
|
B_TRUE /* leaf vdev */
|
|
|
|
};
|
|
|
|
|
2011-02-07 21:54:59 +00:00
|
|
|
module_param(zfs_vdev_scheduler, charp, 0644);
|
2011-05-03 22:09:28 +00:00
|
|
|
MODULE_PARM_DESC(zfs_vdev_scheduler, "I/O scheduler");
|