vdev_disk.c revision 1724dc7b89ff9c4d1006fdb79d20a4102d226def
/*
* 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
* 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) 2012 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
#include <sys/spa_impl.h>
#include <sys/refcount.h>
#include <sys/vdev_disk.h>
#include <sys/vdev_impl.h>
#include <sys/efi_partition.h>
/*
* Virtual device vector for disks.
*/
extern ldi_ident_t zfs_li;
typedef struct vdev_disk_buf {
static void
{
char *minor;
/*
* We must have a pathname, and it must be absolute.
*/
return;
/*
* Only prefetch path and devid info if the device has
* never been opened.
*/
return;
}
}
}
static void
{
if (vd->vdev_name_vp) {
}
if (vd->vdev_devid_vp) {
}
}
static uint64_t
{
uint64_t avail_space = 0;
zfs_dbgmsg("vdev %s, capacity %llu, altern lba %llu",
if (capacity > efi_altern_lba)
}
return (avail_space);
}
static int
{
struct dk_minfo_ext dkmext;
int error;
int otyp;
/*
* We must have a pathname, and it must be absolute.
*/
return (EINVAL);
}
/*
* Reopen the device if it's not currently open. Otherwise,
* just update the physical size of the device.
*/
goto skip_open;
}
/*
* When opening a disk device, we want to preserve the user's original
* intent. We always want to open the device by the path the user gave
* us, even if it is one of multiple paths to the same device. But we
* Therefore the sequence of opening devices is:
*
* 1. Try opening the device by path. For legacy pools without the
* 'whole_disk' property, attempt to fix the path by appending 's0'.
*
* 2. If the devid of the device matches the stored value, return
* success.
*
* 3. Otherwise, the device may have moved. Try opening the device
* by the devid instead.
*/
return (EINVAL);
}
}
} else {
}
}
/*
* Compare the devid to the stored value.
*/
kcred);
}
}
/*
* If we succeeded in opening the device, but 'vdev_wholedisk'
* is not yet set, then this must be a slice.
*/
vd->vdev_wholedisk = 0;
}
/*
* If we were unable to open by path, or the devid check fails, open by
* devid instead.
*/
/*
* If all else fails, then try opening by physical path (if available)
* or the logical path (if we failed due to the devid check). While not
* as reliable as the devid, this will give us something, and the higher
* level vdev validation will prevent us from opening the wrong device.
*/
if (error) {
/*
* Note that we don't support the legacy auto-wholedisk support
* as above. This hasn't been used in a very long time and we
* don't need to propagate its oddities to this edge condition.
*/
}
if (error) {
return (error);
}
/*
* Once a device is opened, verify that the physical device path (if
* available) is up to date.
*/
if (vd->vdev_physpath)
}
if (minorname)
}
/*
* Determine the actual size of the device.
*/
return (EINVAL);
}
/*
* Determine the device's minimum transfer size.
* If the ioctl isn't supported, assume DEV_BSIZE.
*/
int wce = 1;
/*
* If we own the whole disk, try to enable disk write caching.
* We ignore errors because it's OK if we can't do it.
*/
zfs_dbgmsg("capacity change: vdev %s, psize %llu, "
} else {
}
/*
* Clear the nowritecache bit, so that on a vdev_reopen() we will
* try again.
*/
return (0);
}
static void
{
return;
}
int
{
int error = 0;
return (EINVAL);
return (error);
}
static void
{
/*
* The rest of the zio stack only deals with EIO, ECKSUM, and ENXIO.
* Rather than teach the rest of the stack about other error
* possibilities (EFAULT, etc), we normalize the error value here.
*/
}
static void
{
}
static const zio_vsd_ops_t vdev_disk_vsd_ops = {
};
static void
{
}
static int
{
struct dk_callback *dkc;
int error;
/* XXPOLICY */
if (!vdev_readable(vd)) {
return (ZIO_PIPELINE_CONTINUE);
}
case DKIOCFLUSHWRITECACHE:
if (zfs_nocacheflush)
break;
if (vd->vdev_nowritecache) {
break;
}
if (error == 0) {
/*
* The ioctl will be done asychronously,
* and will call vdev_disk_ioctl_done()
* upon completion.
*/
return (ZIO_PIPELINE_STOP);
}
/*
* If we get ENOTSUP or ENOTTY, we know that
* no future attempts will ever succeed.
* In this case we set a persistent bit so
* that we don't bother with the ioctl in the
* future.
*/
}
break;
default:
}
return (ZIO_PIPELINE_CONTINUE);
}
/* ldi_strategy() will return non-zero only on programming errors */
return (ZIO_PIPELINE_STOP);
}
static void
{
/*
* If the device returned EIO, then attempt a DKIOCSTATE ioctl to see if
* the device has been removed. If this is the case, then we trigger an
* asynchronous removal of the device. Otherwise, probe the device and
* make sure it's still accessible.
*/
/*
* We post the resource as soon as possible, instead of
* when the async removal actually happens, because the
* DE is using this information to discard previous I/O
* errors.
*/
} else if (!vd->vdev_delayed_close) {
}
}
}
NULL,
VDEV_TYPE_DISK, /* name of this vdev type */
B_TRUE /* leaf vdev */
};
/*
* Given the root disk device devid or pathname, read the label from
* the device, and construct a configuration nvlist.
*/
int
{
int l;
int error = -1;
char *minor_name;
/*
* Read the device label and build the nvlist.
*/
&minor_name) == 0) {
}
zfs_li)))
return (error);
if (ldi_get_size(vd_lh, &s)) {
return (EIO);
}
for (l = 0; l < VDEV_LABELS; l++) {
/* read vdev label */
continue;
continue;
}
continue;
}
continue;
}
break;
}
return (error);
}