Skip to content

Commit 48431b7

Browse files
smhsmh
authored andcommitted
Prevent ZFS leaking pool free space
When processing async destroys ZFS would leak space every txg timeout (5 seconds by default), if no writes occurred, until the pool is totally full. At this point it would be unfixable without a pool recreation. In addition if the machine was rebooted with the pool in this situation would fail to import on boot, hanging indefinitely, as the import process requires the ability to write data to the pool. Any attempts to query the pool status during the hung import would not return as the import holds the pool lock. The only way to import such a pool would be to specify -o readonly=on to the zpool import. zdb -bb <pool> can be used to check for "deferred free" size which is where this lost space will be counted. MFC after: 3 days Sponsored by: Multiplay
1 parent 27e88fc commit 48431b7

File tree

1 file changed

+8
-7
lines changed
  • sys/cddl/contrib/opensolaris/uts/common/fs/zfs

1 file changed

+8
-7
lines changed

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,13 +1459,6 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
14591459
"traverse_dataset_destroyed()", err);
14601460
}
14611461

1462-
/*
1463-
* If we didn't make progress, mark the async destroy as
1464-
* stalled, so that we will not initiate a spa_sync() on
1465-
* its behalf.
1466-
*/
1467-
scn->scn_async_stalled = (scn->scn_visited_this_txg == 0);
1468-
14691462
if (bptree_is_empty(dp->dp_meta_objset, dp->dp_bptree_obj)) {
14701463
/* finished; deactivate async destroy feature */
14711464
spa_feature_decr(spa, SPA_FEATURE_ASYNC_DESTROY, tx);
@@ -1478,6 +1471,14 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
14781471
dp->dp_bptree_obj, tx));
14791472
dp->dp_bptree_obj = 0;
14801473
scn->scn_async_destroying = B_FALSE;
1474+
} else {
1475+
/*
1476+
* If we didn't make progress, mark the async destroy as
1477+
* stalled, so that we will not initiate a spa_sync() on
1478+
* its behalf.
1479+
*/
1480+
scn->scn_async_stalled =
1481+
(scn->scn_visited_this_txg == 0);
14811482
}
14821483
}
14831484
if (scn->scn_visited_this_txg) {

0 commit comments

Comments
 (0)