MFV r271511:

Use fnvlist_* to make code more readable.

Illumos issue:
    5135 zpool_find_import_cached() can use fnvlist_*

MFC after:	2 weeks
This commit is contained in:
Xin LI 2014-09-13 16:41:39 +00:00
commit e11a25e8d0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=271527

View File

@ -20,7 +20,7 @@
*/ */
/* /*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright 2014 Nexenta Systems, Inc. All rights reserved. * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/ */
@ -1426,21 +1426,15 @@ zpool_find_import_cached(libzfs_handle_t *hdl, const char *cachefile,
elem = NULL; elem = NULL;
while ((elem = nvlist_next_nvpair(raw, elem)) != NULL) { while ((elem = nvlist_next_nvpair(raw, elem)) != NULL) {
verify(nvpair_value_nvlist(elem, &src) == 0); src = fnvpair_value_nvlist(elem);
verify(nvlist_lookup_string(src, ZPOOL_CONFIG_POOL_NAME, name = fnvlist_lookup_string(src, ZPOOL_CONFIG_POOL_NAME);
&name) == 0);
if (poolname != NULL && strcmp(poolname, name) != 0) if (poolname != NULL && strcmp(poolname, name) != 0)
continue; continue;
verify(nvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID, this_guid = fnvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID);
&this_guid) == 0); if (guid != 0 && guid != this_guid)
if (guid != 0) { continue;
verify(nvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID,
&this_guid) == 0);
if (guid != this_guid)
continue;
}
if (pool_active(hdl, name, this_guid, &active) != 0) { if (pool_active(hdl, name, this_guid, &active) != 0) {
nvlist_free(raw); nvlist_free(raw);