vdev_disk.c revision a84224b356ed1e9d5336da9639b65f69263caf62
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/zfs_context.h>
#include <sys/vdev_disk.h>
#include <sys/vdev_impl.h>
/*
* Virtual device vector for disks.
*/
extern ldi_ident_t zfs_li;
typedef struct vdev_disk_buf {
static int
{
int error;
int otyp;
/*
* We must have a pathname, and it must be absolute.
*/
return (EINVAL);
}
/*
* 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 save 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.
*/
}
}
/*
* 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);
}
/*
* 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.
*/
int wce = 1;
}
/*
* Determine the device's minimum transfer size.
* If the ioctl isn't supported, assume DEV_BSIZE.
*/
/*
* Clear the nowritecache bit, so that on a vdev_reopen() we will
* try again.
*/
return (0);
}
static void
{
return;
}
static void
{
}
static void
{
}
static void
{
/* XXPOLICY */
if (vdev_is_dead(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;
/*
* 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;
}
return;
return;
flags |= B_FAILFAST;
/* XXPOLICY */
if (error) {
return;
}
/* ldi_strategy() will return non-zero only on programming errors */
}
static void
{
int state;
/*
* 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.
*/
state != DKIO_INSERTED) {
}
}
}
NULL,
VDEV_TYPE_DISK, /* name of this vdev type */
B_TRUE /* leaf vdev */
};