diff options
author | Alexander Motin <[email protected]> | 2023-11-29 13:51:34 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2023-11-29 10:51:34 -0800 |
commit | a03ebd9beec6243682557fa692c12b1061fc58bd (patch) | |
tree | 28f124a6a52ab49c30c351c7ec26f7b7552631aa /module/zfs/brt.c | |
parent | 8adf2e30665c412d8045f7c20d5426e954280357 (diff) |
ZIL: Call brt_pending_add() replaying TX_CLONE_RANGE
zil_claim_clone_range() takes references on cloned blocks before ZIL
replay. Later zil_free_clone_range() drops them after replay or on
dataset destroy. The total balance is neutral. It means on actual
replay we must take additional references, which would stay in BRT.
Without this blocks could be freed prematurely when either original
file or its clone are destroyed. I've observed BRT being emptied
and the feature being deactivated after ZIL replay completion, which
should not have happened. With the patch I see expected stats.
Reviewed-by: Kay Pedersen <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Signed-off-by: Alexander Motin <[email protected]>
Sponsored by: iXsystems, Inc.
Closes #15603
Diffstat (limited to 'module/zfs/brt.c')
-rw-r--r-- | module/zfs/brt.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/module/zfs/brt.c b/module/zfs/brt.c index b0529521e..759bc8d2e 100644 --- a/module/zfs/brt.c +++ b/module/zfs/brt.c @@ -235,13 +235,13 @@ * destination dataset is mounted and its ZIL replayed. * To address this situation we leverage zil_claim() mechanism where ZFS will * parse all the ZILs on pool import. When we come across TX_CLONE_RANGE - * entries, we will bump reference counters for their BPs in the BRT and then - * on mount and ZIL replay we will just attach BPs to the file without - * bumping reference counters. - * Note it is still possible that after zil_claim() we never mount the - * destination, so we never replay its ZIL and we destroy it. This way we would - * end up with leaked references in BRT. We address that too as ZFS gives us - * a chance to clean this up on dataset destroy (see zil_free_clone_range()). + * entries, we will bump reference counters for their BPs in the BRT. Then + * on mount and ZIL replay we bump the reference counters once more, while the + * first references are dropped during ZIL destroy by zil_free_clone_range(). + * It is possible that after zil_claim() we never mount the destination, so + * we never replay its ZIL and just destroy it. In this case the only taken + * references will be dropped by zil_free_clone_range(), since the cloning is + * not going to ever take place. */ static kmem_cache_t *brt_entry_cache; |