Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/lib/libzutil/os/freebsd/zutil_import_os.c
Show All 36 Lines | |||||
* | * | ||||
* Duplicate entries matching this same tuple will be discarded. Once we have | * Duplicate entries matching this same tuple will be discarded. Once we have | ||||
* examined every device, we pick the best label txg config for each toplevel | * examined every device, we pick the best label txg config for each toplevel | ||||
* vdev. We then arrange these toplevel vdevs into a complete pool config, and | * vdev. We then arrange these toplevel vdevs into a complete pool config, and | ||||
* update any paths that have changed. Finally, we attempt to import the pool | * update any paths that have changed. Finally, we attempt to import the pool | ||||
* using our derived config, and record the results. | * using our derived config, and record the results. | ||||
*/ | */ | ||||
#include <sys/types.h> | |||||
#include <sys/disk.h> | |||||
#include <sys/ioctl.h> | |||||
#include <sys/stat.h> | |||||
#include <sys/sysctl.h> | |||||
#include <aio.h> | #include <aio.h> | ||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <dirent.h> | #include <dirent.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <libintl.h> | #include <libintl.h> | ||||
#include <libgen.h> | #include <libgen.h> | ||||
#include <stddef.h> | #include <stddef.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <sys/disk.h> | |||||
#include <sys/ioctl.h> | |||||
#include <sys/stat.h> | |||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <sys/efi_partition.h> | #include <sys/efi_partition.h> | ||||
#include <thread_pool.h> | #include <thread_pool.h> | ||||
#include <libgeom.h> | #include <libgeom.h> | ||||
#include <sys/vdev_impl.h> | #include <sys/vdev_impl.h> | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | zpool_default_search_paths(size_t *count) | ||||
*count = nitems(zpool_default_import_path); | *count = nitems(zpool_default_import_path); | ||||
return (zpool_default_import_path); | return (zpool_default_import_path); | ||||
} | } | ||||
int | int | ||||
zpool_find_import_blkid(libpc_handle_t *hdl, pthread_mutex_t *lock, | zpool_find_import_blkid(libpc_handle_t *hdl, pthread_mutex_t *lock, | ||||
avl_tree_t **slice_cache) | avl_tree_t **slice_cache) | ||||
{ | { | ||||
const char *oid = "vfs.zfs.vol.recursive"; | |||||
char *end, path[MAXPATHLEN]; | char *end, path[MAXPATHLEN]; | ||||
rdsk_node_t *slice; | rdsk_node_t *slice; | ||||
struct gmesh mesh; | struct gmesh mesh; | ||||
struct gclass *mp; | struct gclass *mp; | ||||
struct ggeom *gp; | struct ggeom *gp; | ||||
struct gprovider *pp; | struct gprovider *pp; | ||||
avl_index_t where; | avl_index_t where; | ||||
size_t pathleft; | int error, value; | ||||
int error; | size_t pathleft, size = sizeof (value); | ||||
boolean_t skip_zvols = B_FALSE; | |||||
end = stpcpy(path, "/dev/"); | end = stpcpy(path, "/dev/"); | ||||
pathleft = &path[sizeof (path)] - end; | pathleft = &path[sizeof (path)] - end; | ||||
error = geom_gettree(&mesh); | error = geom_gettree(&mesh); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
if (sysctlbyname(oid, &value, &size, NULL, 0) == 0 && value == 0) | |||||
skip_zvols = B_TRUE; | |||||
*slice_cache = zutil_alloc(hdl, sizeof (avl_tree_t)); | *slice_cache = zutil_alloc(hdl, sizeof (avl_tree_t)); | ||||
avl_create(*slice_cache, slice_cache_compare, sizeof (rdsk_node_t), | avl_create(*slice_cache, slice_cache_compare, sizeof (rdsk_node_t), | ||||
offsetof(rdsk_node_t, rn_node)); | offsetof(rdsk_node_t, rn_node)); | ||||
LIST_FOREACH(mp, &mesh.lg_class, lg_class) { | LIST_FOREACH(mp, &mesh.lg_class, lg_class) { | ||||
if (skip_zvols && strcmp(mp->lg_name, "ZFS::ZVOL") == 0) | |||||
continue; | |||||
LIST_FOREACH(gp, &mp->lg_geom, lg_geom) { | LIST_FOREACH(gp, &mp->lg_geom, lg_geom) { | ||||
LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { | LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { | ||||
strlcpy(end, pp->lg_name, pathleft); | strlcpy(end, pp->lg_name, pathleft); | ||||
slice = zutil_alloc(hdl, sizeof (rdsk_node_t)); | slice = zutil_alloc(hdl, sizeof (rdsk_node_t)); | ||||
slice->rn_name = zutil_strdup(hdl, path); | slice->rn_name = zutil_strdup(hdl, path); | ||||
slice->rn_vdev_guid = 0; | slice->rn_vdev_guid = 0; | ||||
slice->rn_lock = lock; | slice->rn_lock = lock; | ||||
slice->rn_avl = *slice_cache; | slice->rn_avl = *slice_cache; | ||||
Show All 26 Lines |