Print this page
4626 libzfs memleak in zpool_in_use()
Reviewed by: Tony Nguyen <tony.nguyen@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>


1551             &stateval) == 0);
1552         verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_GUID,
1553             &vdev_guid) == 0);
1554 
1555         if (stateval != POOL_STATE_SPARE && stateval != POOL_STATE_L2CACHE) {
1556                 verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME,
1557                     &name) == 0);
1558                 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID,
1559                     &guid) == 0);
1560         }
1561 
1562         switch (stateval) {
1563         case POOL_STATE_EXPORTED:
1564                 /*
1565                  * A pool with an exported state may in fact be imported
1566                  * read-only, so check the in-core state to see if it's
1567                  * active and imported read-only.  If it is, set
1568                  * its state to active.
1569                  */
1570                 if (pool_active(hdl, name, guid, &isactive) == 0 && isactive &&
1571                     (zhp = zpool_open_canfail(hdl, name)) != NULL &&
1572                     zpool_get_prop_int(zhp, ZPOOL_PROP_READONLY, NULL))
1573                         stateval = POOL_STATE_ACTIVE;
1574 



1575                 ret = B_TRUE;
1576                 break;
1577 
1578         case POOL_STATE_ACTIVE:
1579                 /*
1580                  * For an active pool, we have to determine if it's really part
1581                  * of a currently active pool (in which case the pool will exist
1582                  * and the guid will be the same), or whether it's part of an
1583                  * active pool that was disconnected without being explicitly
1584                  * exported.
1585                  */
1586                 if (pool_active(hdl, name, guid, &isactive) != 0) {
1587                         nvlist_free(config);
1588                         return (-1);
1589                 }
1590 
1591                 if (isactive) {
1592                         /*
1593                          * Because the device may have been removed while
1594                          * offlined, we only report it as active if the vdev is




1551             &stateval) == 0);
1552         verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_GUID,
1553             &vdev_guid) == 0);
1554 
1555         if (stateval != POOL_STATE_SPARE && stateval != POOL_STATE_L2CACHE) {
1556                 verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME,
1557                     &name) == 0);
1558                 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID,
1559                     &guid) == 0);
1560         }
1561 
1562         switch (stateval) {
1563         case POOL_STATE_EXPORTED:
1564                 /*
1565                  * A pool with an exported state may in fact be imported
1566                  * read-only, so check the in-core state to see if it's
1567                  * active and imported read-only.  If it is, set
1568                  * its state to active.
1569                  */
1570                 if (pool_active(hdl, name, guid, &isactive) == 0 && isactive &&
1571                     (zhp = zpool_open_canfail(hdl, name)) != NULL) {
1572                         if (zpool_get_prop_int(zhp, ZPOOL_PROP_READONLY, NULL))
1573                                 stateval = POOL_STATE_ACTIVE;
1574 
1575                         zpool_close(zhp);
1576                 }
1577 
1578                 ret = B_TRUE;
1579                 break;
1580 
1581         case POOL_STATE_ACTIVE:
1582                 /*
1583                  * For an active pool, we have to determine if it's really part
1584                  * of a currently active pool (in which case the pool will exist
1585                  * and the guid will be the same), or whether it's part of an
1586                  * active pool that was disconnected without being explicitly
1587                  * exported.
1588                  */
1589                 if (pool_active(hdl, name, guid, &isactive) != 0) {
1590                         nvlist_free(config);
1591                         return (-1);
1592                 }
1593 
1594                 if (isactive) {
1595                         /*
1596                          * Because the device may have been removed while
1597                          * offlined, we only report it as active if the vdev is