]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix ZIL clone records for legacy holes
authorAlexander Motin <mav@FreeBSD.org>
Thu, 9 May 2024 14:39:57 +0000 (10:39 -0400)
committerGitHub <noreply@github.com>
Thu, 9 May 2024 14:39:57 +0000 (07:39 -0700)
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 <behlendorf1@llnl.gov>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #16165

module/zfs/zfs_log.c

index 433a653e5500f321cc474a076b364cbad80747df..fa4e7093ca46b26c8d36b0c8b3e62d49a2ad97c7 100644 (file)
@@ -895,7 +895,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;
@@ -904,10 +904,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,