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 <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #4794
This commit is contained in:
Brian Behlendorf
2016-06-23 15:25:17 -07:00
parent a64f903b06
commit 8a39abaafa
2 changed files with 333 additions and 430 deletions
+10 -19
View File
@@ -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;
blkid_cache cache;
int error;
/*
* 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);
}
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);
}
/*