Skip to content

Commit

Permalink
Multi-thread 'zpool import' for blkid
Browse files Browse the repository at this point in the history
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 openzfs#4794
  • Loading branch information
behlendorf committed Jul 27, 2016
1 parent a64f903 commit 8a39aba
Show file tree
Hide file tree
Showing 2 changed files with 336 additions and 433 deletions.
29 changes: 10 additions & 19 deletions cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down
Loading

0 comments on commit 8a39aba

Please sign in to comment.