]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Use abd_zero_off() where applicable
authorAlexander Motin <mav@FreeBSD.org>
Fri, 17 Nov 2023 21:28:32 +0000 (16:28 -0500)
committerGitHub <noreply@github.com>
Fri, 17 Nov 2023 21:28:32 +0000 (13:28 -0800)
In several places abd_zero() cleaned ABD filled at the next line.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15514

module/os/freebsd/zfs/vdev_label_os.c
module/zfs/mmp.c
module/zfs/vdev_label.c

index 338982ff68733f94d33a1386f3b05732a7e1265c..79732d9173e86c66bab2974a0d05acf15d0e906e 100644 (file)
@@ -55,8 +55,8 @@ vdev_label_write_pad2(vdev_t *vd, const char *buf, size_t size)
        ASSERT3U(spa_config_held(spa, SCL_ALL, RW_WRITER), ==, SCL_ALL);
 
        pad2 = abd_alloc_for_io(VDEV_PAD_SIZE, B_TRUE);
-       abd_zero(pad2, VDEV_PAD_SIZE);
        abd_copy_from_buf(pad2, buf, size);
+       abd_zero_off(pad2, size, VDEV_PAD_SIZE - size);
 
 retry:
        zio = zio_root(spa, NULL, NULL, flags);
index 25eea0752941449f17eef1a94f60f9a184451da2..66bc0ae60b1033335a0758c7d2b93f85fa2d8780 100644 (file)
@@ -517,8 +517,9 @@ mmp_write_uberblock(spa_t *spa)
 
        zio_t *zio  = zio_null(mmp->mmp_zio_root, spa, NULL, NULL, NULL, flags);
        abd_t *ub_abd = abd_alloc_for_io(VDEV_UBERBLOCK_SIZE(vd), B_TRUE);
-       abd_zero(ub_abd, VDEV_UBERBLOCK_SIZE(vd));
        abd_copy_from_buf(ub_abd, ub, sizeof (uberblock_t));
+       abd_zero_off(ub_abd, sizeof (uberblock_t),
+           VDEV_UBERBLOCK_SIZE(vd) - sizeof (uberblock_t));
 
        mmp->mmp_seq++;
        mmp->mmp_kstat_id++;
index e8f562a1a6a202882fd69bcffbb39c80e4e0e32a..4c6501cc9a0916bbe444adde540d990fec28fa24 100644 (file)
@@ -1187,8 +1187,9 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
         * Initialize uberblock template.
         */
        ub_abd = abd_alloc_linear(VDEV_UBERBLOCK_RING, B_TRUE);
-       abd_zero(ub_abd, VDEV_UBERBLOCK_RING);
        abd_copy_from_buf(ub_abd, &spa->spa_uberblock, sizeof (uberblock_t));
+       abd_zero_off(ub_abd, sizeof (uberblock_t),
+           VDEV_UBERBLOCK_RING - sizeof (uberblock_t));
        ub = abd_to_buf(ub_abd);
        ub->ub_txg = 0;
 
@@ -1767,8 +1768,9 @@ vdev_uberblock_sync(zio_t *zio, uint64_t *good_writes,
 
        /* Copy the uberblock_t into the ABD */
        abd_t *ub_abd = abd_alloc_for_io(VDEV_UBERBLOCK_SIZE(vd), B_TRUE);
-       abd_zero(ub_abd, VDEV_UBERBLOCK_SIZE(vd));
        abd_copy_from_buf(ub_abd, ub, sizeof (uberblock_t));
+       abd_zero_off(ub_abd, sizeof (uberblock_t),
+           VDEV_UBERBLOCK_SIZE(vd) - sizeof (uberblock_t));
 
        for (int l = 0; l < VDEV_LABELS; l++)
                vdev_label_write(zio, vd, l, ub_abd,