Skip to content

Commit 3400127

Browse files
authored
Fix ZIL clone records for legacy holes
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 #16165
1 parent af5dbed commit 3400127

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

module/zfs/zfs_log.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ zfs_log_clone_range(zilog_t *zilog, dmu_tx_t *tx, int txtype, znode_t *zp,
895895
itx_t *itx;
896896
lr_clone_range_t *lr;
897897
uint64_t partlen, max_log_data;
898-
size_t i, partnbps;
898+
size_t partnbps;
899899

900900
if (zil_replaying(zilog, tx) || zp->z_unlinked)
901901
return;
@@ -904,10 +904,8 @@ zfs_log_clone_range(zilog_t *zilog, dmu_tx_t *tx, int txtype, znode_t *zp,
904904

905905
while (nbps > 0) {
906906
partnbps = MIN(nbps, max_log_data / sizeof (bps[0]));
907-
partlen = 0;
908-
for (i = 0; i < partnbps; i++) {
909-
partlen += BP_GET_LSIZE(&bps[i]);
910-
}
907+
partlen = partnbps * blksz;
908+
ASSERT3U(partlen, <, len + blksz);
911909
partlen = MIN(partlen, len);
912910

913911
itx = zil_itx_create(txtype,

0 commit comments

Comments
 (0)