summaryrefslogtreecommitdiffstats
path: root/cmd/zpool
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2016-06-23 15:25:17 -0700
committerBrian Behlendorf <[email protected]>2016-07-27 13:38:46 -0700
commit8a39abaafad51861daf197b0e9809dfcf77fd3cf (patch)
treec5964b86e1e9bf16c339bd6ffbc97db1750ddd4c /cmd/zpool
parenta64f903b06e9135c07f20bc6f8196e2879d2cf57 (diff)
Multi-thread 'zpool import' for blkid
Commit 519129f added support to multi-thread 'zpool import' for the case where block devices are scanned for under /dev/. This commit generalizes that logic and applies it to the case where device names are acquired from libblkid. The zpool_find_import_scan() and zpool_find_import_blkid() functions create an AVL tree containing each device name. Each entry in this tree is dispatched to a taskq where the function zpool_open_func() validates the device by opening it and reading the label. This may result in additional entries being added to the tree and those device paths being verified. This is largely how the upstream OpenZFS code behaves but due to significant differences the non-Linux code has been dropped for readability. Additionally, this code makes use of taskqs and kmutexs which are normally not available to the command line tools. Special care has been taken to allow their use in the import functions. Signed-off-by: Brian Behlendorf <[email protected]> Signed-off-by: Olaf Faaland <[email protected]> Closes #4794
Diffstat (limited to 'cmd/zpool')
-rw-r--r--cmd/zpool/zpool_vdev.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c
index 3f419079c..7ad44a948 100644
--- a/cmd/zpool/zpool_vdev.c
+++ b/cmd/zpool/zpool_vdev.c
@@ -486,28 +486,19 @@ static int
check_device(const char *path, boolean_t force,
boolean_t isspare, boolean_t iswholedisk)
{
- static blkid_cache cache = NULL;
-
- /*
- * There is no easy way to add a correct blkid_put_cache() call,
- * memory will be reclaimed when the command exits.
- */
- if (cache == NULL) {
- int err;
-
- if ((err = blkid_get_cache(&cache, NULL)) != 0) {
- check_error(err);
- return (-1);
- }
+ blkid_cache cache;
+ int error;
- if ((err = blkid_probe_all(cache)) != 0) {
- blkid_put_cache(cache);
- check_error(err);
- return (-1);
- }
+ error = blkid_get_cache(&cache, NULL);
+ if (error != 0) {
+ check_error(error);
+ return (-1);
}
- return (check_disk(path, cache, force, isspare, iswholedisk));
+ error = check_disk(path, cache, force, isspare, iswholedisk);
+ blkid_put_cache(cache);
+
+ return (error);
}
/*