Skip to content

Commit

Permalink
Fix ZIL clone records for legacy holes
Browse files Browse the repository at this point in the history
Previous code overengineered cloned range calculation by using
BP_GET_LSIZE(). The problem is that legacy holes don't have the
logical size, so result will be wrong.  But we also don't need
to look on every block size, since they all must be identical.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Brian Atkinson <[email protected]>
Signed-off-by: Alexander Motin <[email protected]>
Sponsored by:	iXsystems, Inc.
Closes openzfs#16165
  • Loading branch information
amotin authored and lundman committed Sep 4, 2024
1 parent 660d9f7 commit 1c920aa
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions module/zfs/zfs_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ zfs_log_clone_range(zilog_t *zilog, dmu_tx_t *tx, int txtype, znode_t *zp,
itx_t *itx;
lr_clone_range_t *lr;
uint64_t partlen, max_log_data;
size_t i, partnbps;
size_t partnbps;

if (zil_replaying(zilog, tx) || zp->z_unlinked)
return;
Expand All @@ -927,10 +927,8 @@ zfs_log_clone_range(zilog_t *zilog, dmu_tx_t *tx, int txtype, znode_t *zp,

while (nbps > 0) {
partnbps = MIN(nbps, max_log_data / sizeof (bps[0]));
partlen = 0;
for (i = 0; i < partnbps; i++) {
partlen += BP_GET_LSIZE(&bps[i]);
}
partlen = partnbps * blksz;
ASSERT3U(partlen, <, len + blksz);
partlen = MIN(partlen, len);

itx = zil_itx_create(txtype,
Expand Down

0 comments on commit 1c920aa

Please sign in to comment.