/*
* 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, 2015 by Delphix. All rights reserved.
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013 Joyent, Inc. 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;
static void vdev_disk_close(vdev_t *);
typedef struct vdev_disk_ldi_cb {
static void
{
/*
* Create the LDI event callback list.
*/
}
static void
{
return;
/*
* We have already closed the LDI handle. Clean up the LDI event
* callbacks and free vd->vdev_tsd.
*/
}
}
/* ARGSUSED */
static int
void *ev_data)
{
/*
* Ignore events other than offline.
*/
return (LDI_EV_SUCCESS);
/*
* All LDI handles must be closed for the state change to succeed, so
* call on vdev_disk_close() to do this.
*
* We inform vdev_disk_close that it is being called from offline
* notify context so it will defer cleanup of LDI event callbacks and
* freeing of vd->vdev_tsd to the offline finalize or a reopen.
*/
/*
* Now that the device is closed, request that the spa_async_thread
* mark the device as REMOVED and notify FMA of the removal.
*/
return (LDI_EV_SUCCESS);
}
/* ARGSUSED */
static void
{
/*
* Ignore events other than offline.
*/
return;
/*
* We have already closed the LDI handle in notify.
* Clean up the LDI event callbacks and free vd->vdev_tsd.
*/
/*
* Request that the vdev be reopened if the offline state change was
* unsuccessful.
*/
if (ldi_result != LDI_EV_SUCCESS) {
}
}
};
/* ARGSUSED */
static void
{
/*
* Ignore events other than degrade.
*/
return;
/*
* Degrade events always succeed. Mark the vdev as degraded.
* This status is purely informative for the user.
*/
}
};
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) {
}
}
/*
* We want to be loud in DEBUG kernels when DKIOCGMEDIAINFOEXT fails, or when
* even a fallback to DKIOCGMEDIAINFO fails.
*/
#ifdef DEBUG
#else
#endif
static int
{
union {
} dks;
int error;
int otyp;
/*
* We must have a pathname, and it must be absolute.
*/
}
/*
* Reopen the device if it's not currently open. Otherwise,
* just update the physical size of the device.
*/
/*
* If we are opening a device in its offline notify
* context, the LDI handle was just closed. Clean
* up the LDI event callbacks and free vd->vdev_tsd.
*/
} else {
goto skip_open;
}
}
/*
* Create vd->vdev_tsd.
*/
/*
* 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.
*/
}
}
if (error == 0) {
} else {
}
}
/*
* If we have not yet opened the device, try to open it by the
* specified path.
*/
if (error != 0) {
}
/*
* 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);
}
/*
* Now that the device has been successfully opened, update the devid
* if necessary.
*/
char *vd_devid;
zfs_dbgmsg("vdev %s: update devid from %s, "
}
}
/*
* Once a device is opened, verify that the physical device path (if
* available) is up to date.
*/
if (vd->vdev_physpath)
}
if (minorname)
}
/*
* Register callbacks for the LDI offline event.
*/
}
/*
* Register callbacks for the LDI degrade event.
*/
}
/*
* Determine the actual size of the device.
*/
}
/*
* Determine the device's minimum transfer size.
* If the ioctl isn't supported, assume DEV_BSIZE.
*/
"vdev_disk_open(\"%s\"): fallback to DKIOCGMEDIAINFO\n",
} else {
VDEV_DEBUG("vdev_disk_open(\"%s\"): "
"both DKIOCGMEDIAINFO{,EXT} calls failed, %d\n",
}
if (error == 0) {
/*
* If we have the capability to expand, we'd have
* found out via success from DKIOCGMEDIAINFO{,EXT}.
* Adjust max_psize upward accordingly since we know
* we own the whole disk now.
*/
}
/*
* Since we own the whole disk, try to enable disk write
* caching. We ignore errors because it's OK if we can't do it.
*/
}
/*
* Clear the nowritecache bit, so that on a vdev_reopen() we will
* try again.
*/
return (0);
}
static void
{
return;
}
}
}
/*
* If we closed the LDI handle due to an offline notify from LDI,
* don't free vd->vdev_tsd or unregister the callbacks here;
* the offline finalize callback or a reopen will take care of it.
*/
if (dvd->vd_ldi_offline)
return;
}
int
{
/*
* If the vdev is closed, it's likely in the REMOVED or FAULTED state.
* Nothing to be done here but return failure.
*/
return (EIO);
/*
* If in the context of an active crash dump, use the ldi_dump(9F)
* call instead of ldi_strategy(9F) as usual.
*/
if (isdump) {
}
}
int
{
int error = 0;
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 void
{
}
static void
{
int error;
/*
* If the vdev is closed, it's likely in the REMOVED or FAULTED state.
* Nothing to be done here but return failure.
*/
return;
}
/* XXPOLICY */
if (!vdev_readable(vd)) {
return;
}
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;
}
break;
default:
}
return;
}
/* ldi_strategy() will return non-zero only on programming errors */
}
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;
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)) {
}
for (l = 0; l < VDEV_LABELS; l++) {
/* read vdev label */
continue;
continue;
}
continue;
}
continue;
}
break;
}
return (error);
}