Merge commit 'refs/top-bases/linux-zfs-branch' into linux-zfs-branch

This commit is contained in:
Brian Behlendorf 2008-12-05 12:48:40 -08:00
commit 99c31e6742
6 changed files with 43 additions and 15 deletions

View File

@ -400,7 +400,11 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
* for its size. So -- gag -- we open the block device to get * for its size. So -- gag -- we open the block device to get
* its size, and remember it for subsequent VOP_GETATTR(). * its size, and remember it for subsequent VOP_GETATTR().
*/ */
#if defined(__sun__) || defined(__sun)
if (strncmp(path, "/dev/", 5) == 0) { if (strncmp(path, "/dev/", 5) == 0) {
#else
if (0) {
#endif
char *dsk; char *dsk;
fd = open64(path, O_RDONLY); fd = open64(path, O_RDONLY);
if (fd == -1) if (fd == -1)
@ -421,6 +425,14 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
return (errno); return (errno);
} }
#ifdef __linux__
if (!(flags & FCREAT) && S_ISBLK(st.st_mode)) {
flags |= O_DIRECT;
if (flags & FWRITE)
flags |= O_EXCL;
}
#endif
if (flags & FCREAT) if (flags & FCREAT)
old_umask = umask(0); old_umask = umask(0);

View File

@ -48,6 +48,20 @@ extern "C" {
#define ZFS_MAXPROPLEN MAXPATHLEN #define ZFS_MAXPROPLEN MAXPATHLEN
#define ZPOOL_MAXPROPLEN MAXPATHLEN #define ZPOOL_MAXPROPLEN MAXPATHLEN
/*
* Default device paths
*/
#if defined(__sun__) || defined(__sun)
#define DISK_ROOT "/dev/dsk"
#define RDISK_ROOT "/dev/rdsk"
#define BACKUP_SLICE "s2"
#endif
#ifdef __linux__
#define DISK_ROOT "/dev"
#endif
/* /*
* libzfs errors * libzfs errors
*/ */

View File

@ -796,7 +796,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, int argc, char **argv,
size_t pathleft; size_t pathleft;
struct stat64 statbuf; struct stat64 statbuf;
nvlist_t *ret = NULL, *config; nvlist_t *ret = NULL, *config;
static char *default_dir = "/dev/dsk"; static char *default_dir = DISK_ROOT;
int fd; int fd;
pool_list_t pools = { 0 }; pool_list_t pools = { 0 };
pool_entry_t *pe, *penext; pool_entry_t *pe, *penext;

View File

@ -1435,7 +1435,7 @@ zpool_find_vdev(zpool_handle_t *zhp, const char *path, boolean_t *avail_spare,
if (guid != 0 && *end == '\0') { if (guid != 0 && *end == '\0') {
search = NULL; search = NULL;
} else if (path[0] != '/') { } else if (path[0] != '/') {
(void) snprintf(buf, sizeof (buf), "%s%s", "/dev/dsk/", path); (void) snprintf(buf, sizeof (buf), "%s/%s", DISK_ROOT, path);
search = buf; search = buf;
} else { } else {
search = path; search = path;
@ -2348,6 +2348,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv)
char buf[64]; char buf[64];
vdev_stat_t *vs; vdev_stat_t *vs;
uint_t vsc; uint_t vsc;
size_t droot_len = strlen(DISK_ROOT) + 1;
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT, if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT,
&value) == 0) { &value) == 0) {
@ -2396,9 +2397,14 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv)
devid_str_free(newdevid); devid_str_free(newdevid);
} }
if (strncmp(path, "/dev/dsk/", 9) == 0) if (strncmp(path, DISK_ROOT "/", droot_len) == 0)
path += 9; path += droot_len;
#if defined(__sun__) || defined(__sun)
/*
* The following code strips the slice from the device path.
* This is only meaningful in Solaris.
*/
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK, if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK,
&value) == 0 && value) { &value) == 0 && value) {
char *tmp = zfs_strdup(hdl, path); char *tmp = zfs_strdup(hdl, path);
@ -2407,6 +2413,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv)
tmp[strlen(path) - 2] = '\0'; tmp[strlen(path) - 2] = '\0';
return (tmp); return (tmp);
} }
#endif
} else { } else {
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0); verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0);
@ -2767,8 +2774,6 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
free(mntpnt); free(mntpnt);
} }
#define RDISK_ROOT "/dev/rdsk"
#define BACKUP_SLICE "s2"
/* /*
* Don't start the slice at the default block of 34; many storage * Don't start the slice at the default block of 34; many storage
* devices will use a stripe width of 128k, so start there instead. * devices will use a stripe width of 128k, so start there instead.

View File

@ -1469,7 +1469,7 @@ zpool_do_import(int argc, char **argv)
if (searchdirs == NULL) { if (searchdirs == NULL) {
searchdirs = safe_malloc(sizeof (char *)); searchdirs = safe_malloc(sizeof (char *));
searchdirs[0] = "/dev/dsk"; searchdirs[0] = DISK_ROOT;
nsearch = 1; nsearch = 1;
} }
@ -2223,14 +2223,15 @@ zpool_get_vdev_by_name(nvlist_t *nv, char *name)
uint_t c, children; uint_t c, children;
nvlist_t *match; nvlist_t *match;
char *path; char *path;
size_t droot_len = strlen(DISK_ROOT) + 1;
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
&child, &children) != 0) { &child, &children) != 0) {
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0); verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0);
if (strncmp(name, "/dev/dsk/", 9) == 0) if (strncmp(name, DISK_ROOT "/", droot_len) == 0)
name += 9; name += droot_len;
if (strncmp(path, "/dev/dsk/", 9) == 0) if (strncmp(path, DISK_ROOT "/", droot_len) == 0)
path += 9; path += droot_len;
if (strcmp(name, path) == 0) if (strcmp(name, path) == 0)
return (nv); return (nv);
return (NULL); return (NULL);

View File

@ -77,10 +77,6 @@
#include "zpool_util.h" #include "zpool_util.h"
#define DISK_ROOT "/dev/dsk"
#define RDISK_ROOT "/dev/rdsk"
#define BACKUP_SLICE "s2"
/* /*
* For any given vdev specification, we can have multiple errors. The * For any given vdev specification, we can have multiple errors. The
* vdev_error() function keeps track of whether we have seen an error yet, and * vdev_error() function keeps track of whether we have seen an error yet, and