ZIL: Call brt_pending_add() replaying TX_CLONE_RANGE
commita8c256046b0433861d6c5dafce54d750059b7c1b
authorAlexander Motin <mav@FreeBSD.org>
Wed, 29 Nov 2023 18:51:34 +0000 (29 13:51 -0500)
committerTony Hutter <hutter2@llnl.gov>
Wed, 29 Nov 2023 21:08:25 +0000 (29 13:08 -0800)
treef084b526c9964c383d3947612989d718ebf45e94
parenteb34de04d78bcc9caf77198dd4491d8e6d52e27d
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 <mail@mkwg.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15603
include/sys/dmu.h
module/zfs/brt.c
module/zfs/dmu.c
module/zfs/zfs_vnops.c