Skip to content

Commit 457e62d

Browse files
amotinbehlendorf
authored andcommitted
BRT: Relax brt_pending_apply() locking
Since brt_pending_apply() is running in syncing context, no other brt_pending_tree accesses are possible for the TXG. We don't need to acquire brt_pending_lock here. Reviewed-by: Pawel Jakub Dawidek <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Reviewed-by: Rob Norris <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #15955
1 parent 19bf54b commit 457e62d

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

module/zfs/brt.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,26 +1473,23 @@ brt_pending_remove(spa_t *spa, const blkptr_t *bp, dmu_tx_t *tx)
14731473
void
14741474
brt_pending_apply(spa_t *spa, uint64_t txg)
14751475
{
1476-
brt_t *brt;
1476+
brt_t *brt = spa->spa_brt;
14771477
brt_pending_entry_t *bpe;
14781478
avl_tree_t *pending_tree;
1479-
kmutex_t *pending_lock;
14801479
void *c;
14811480

14821481
ASSERT3U(txg, !=, 0);
14831482

1484-
brt = spa->spa_brt;
1483+
/*
1484+
* We are in syncing context, so no other brt_pending_tree accesses
1485+
* are possible for the TXG. Don't need to acquire brt_pending_lock.
1486+
*/
14851487
pending_tree = &brt->brt_pending_tree[txg & TXG_MASK];
1486-
pending_lock = &brt->brt_pending_lock[txg & TXG_MASK];
1487-
1488-
mutex_enter(pending_lock);
14891488

14901489
c = NULL;
14911490
while ((bpe = avl_destroy_nodes(pending_tree, &c)) != NULL) {
14921491
boolean_t added_to_ddt;
14931492

1494-
mutex_exit(pending_lock);
1495-
14961493
for (int i = 0; i < bpe->bpe_count; i++) {
14971494
/*
14981495
* If the block has DEDUP bit set, it means that it
@@ -1510,10 +1507,7 @@ brt_pending_apply(spa_t *spa, uint64_t txg)
15101507
}
15111508

15121509
kmem_cache_free(brt_pending_entry_cache, bpe);
1513-
mutex_enter(pending_lock);
15141510
}
1515-
1516-
mutex_exit(pending_lock);
15171511
}
15181512

15191513
static void

0 commit comments

Comments
 (0)