vdev_file.c revision 1f7ad2e1275fff503991bf4b43bc5cf1d815669f
/*
* 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_file.h>
#include <sys/vdev_impl.h>
/*
* Virtual device vector for files.
*/
static int
{
int error;
/*
* We must have a pathname, and it must be absolute.
*/
return (EINVAL);
}
/*
* We always open the files from the root of the global zone, even if
* we're in a local zone. If the user has gotten to this point, the
* administrator has already decided that the pool should be available
* to local zone users, so the underlying devices should be as well.
*/
if (error) {
return (error);
}
#ifdef _KERNEL
/*
* Make sure it's a regular file.
*/
return (ENODEV);
}
#endif
return (0);
}
static int
{
int error;
return (error);
/*
* Determine the physical size of the file.
*/
if (error) {
return (error);
}
return (0);
}
static void
{
return;
}
}
static int
{
int error = 0;
return (EINVAL);
return (EIO);
return (0);
}
/*
* Determine if the underlying device is accessible by reading and writing
* to a known location. We must be able to do this during syncing context
* and thus we cannot set the vdev state directly.
*/
static int
{
char *vl_boot;
return (EINVAL);
/* Hijack the current vdev */
/*
* Pick a random label to rewrite.
*/
l = spa_get_random(VDEV_LABELS);
ASSERT(l < VDEV_LABELS);
/*
* If we failed with the vdev that was passed in then
* try allocating a new one and try again.
*/
retries++;
if (error)
break;
}
}
if (retries) {
}
if (!error)
return (error);
}
static void
{
int error;
/* XXPOLICY */
if (!vdev_readable(vd)) {
return;
}
case DKIOCFLUSHWRITECACHE:
break;
default:
}
return;
}
/*
* In the kernel, don't bother double-caching, but in userland,
* we want to test the vdev_cache code.
*/
#ifndef _KERNEL
return;
#endif
return;
/* XXPOLICY */
else
if (error) {
return;
}
}
static void
{
/*
* If an error has been encountered then attempt to probe the device
* to determine if it's still accessible.
*/
if (vdev_probe(vd) != 0)
}
#ifndef _KERNEL
#endif
}
NULL,
VDEV_TYPE_FILE, /* name of this vdev type */
B_TRUE /* leaf vdev */
};
/*
* From userland we access disks just like files.
*/
#ifndef _KERNEL
NULL,
VDEV_TYPE_DISK, /* name of this vdev type */
B_TRUE /* leaf vdev */
};
#endif