BRT: Limit brt_vdev_dump() to only one vdev

Without this patch on pool of 60 vdevs with ZFS_DEBUG enabled clone
takes much more time than copy, while heavily trashing dbgmsg for
no good reason, repeatedly dumping all vdevs BRTs again and again,
even unmodified ones.

I am generally not sure this dumping is not excessive, but decided
to keep it for now, just restricting its scope to more reasonable.

Reviewed-by: Kay Pedersen <mail@mkwg.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes #15625
This commit is contained in:
Alexander Motin 2023-12-06 18:37:27 -05:00 committed by GitHub
parent 2aa3a482ab
commit 9743d09635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -342,7 +342,7 @@ brt_vdev_entcount_get(const brt_vdev_t *brtvd, uint64_t idx)
ASSERT3U(idx, <, brtvd->bv_size); ASSERT3U(idx, <, brtvd->bv_size);
if (brtvd->bv_need_byteswap) { if (unlikely(brtvd->bv_need_byteswap)) {
return (BSWAP_16(brtvd->bv_entcount[idx])); return (BSWAP_16(brtvd->bv_entcount[idx]));
} else { } else {
return (brtvd->bv_entcount[idx]); return (brtvd->bv_entcount[idx]);
@ -355,7 +355,7 @@ brt_vdev_entcount_set(brt_vdev_t *brtvd, uint64_t idx, uint16_t entcnt)
ASSERT3U(idx, <, brtvd->bv_size); ASSERT3U(idx, <, brtvd->bv_size);
if (brtvd->bv_need_byteswap) { if (unlikely(brtvd->bv_need_byteswap)) {
brtvd->bv_entcount[idx] = BSWAP_16(entcnt); brtvd->bv_entcount[idx] = BSWAP_16(entcnt);
} else { } else {
brtvd->bv_entcount[idx] = entcnt; brtvd->bv_entcount[idx] = entcnt;
@ -390,55 +390,39 @@ brt_vdev_entcount_dec(brt_vdev_t *brtvd, uint64_t idx)
#ifdef ZFS_DEBUG #ifdef ZFS_DEBUG
static void static void
brt_vdev_dump(brt_t *brt) brt_vdev_dump(brt_vdev_t *brtvd)
{ {
brt_vdev_t *brtvd; uint64_t idx;
uint64_t vdevid;
if ((zfs_flags & ZFS_DEBUG_BRT) == 0) { zfs_dbgmsg(" BRT vdevid=%llu meta_dirty=%d entcount_dirty=%d "
return; "size=%llu totalcount=%llu nblocks=%llu bitmapsize=%zu\n",
} (u_longlong_t)brtvd->bv_vdevid,
brtvd->bv_meta_dirty, brtvd->bv_entcount_dirty,
if (brt->brt_nvdevs == 0) { (u_longlong_t)brtvd->bv_size,
zfs_dbgmsg("BRT empty"); (u_longlong_t)brtvd->bv_totalcount,
return; (u_longlong_t)brtvd->bv_nblocks,
} (size_t)BT_SIZEOFMAP(brtvd->bv_nblocks));
if (brtvd->bv_totalcount > 0) {
zfs_dbgmsg("BRT vdev dump:"); zfs_dbgmsg(" entcounts:");
for (vdevid = 0; vdevid < brt->brt_nvdevs; vdevid++) { for (idx = 0; idx < brtvd->bv_size; idx++) {
uint64_t idx; uint16_t entcnt = brt_vdev_entcount_get(brtvd, idx);
if (entcnt > 0) {
brtvd = &brt->brt_vdevs[vdevid]; zfs_dbgmsg(" [%04llu] %hu",
zfs_dbgmsg(" vdevid=%llu/%llu meta_dirty=%d entcount_dirty=%d " (u_longlong_t)idx, entcnt);
"size=%llu totalcount=%llu nblocks=%llu bitmapsize=%zu\n",
(u_longlong_t)vdevid, (u_longlong_t)brtvd->bv_vdevid,
brtvd->bv_meta_dirty, brtvd->bv_entcount_dirty,
(u_longlong_t)brtvd->bv_size,
(u_longlong_t)brtvd->bv_totalcount,
(u_longlong_t)brtvd->bv_nblocks,
(size_t)BT_SIZEOFMAP(brtvd->bv_nblocks));
if (brtvd->bv_totalcount > 0) {
zfs_dbgmsg(" entcounts:");
for (idx = 0; idx < brtvd->bv_size; idx++) {
if (brt_vdev_entcount_get(brtvd, idx) > 0) {
zfs_dbgmsg(" [%04llu] %hu",
(u_longlong_t)idx,
brt_vdev_entcount_get(brtvd, idx));
}
} }
} }
if (brtvd->bv_entcount_dirty) { }
char *bitmap; if (brtvd->bv_entcount_dirty) {
char *bitmap;
bitmap = kmem_alloc(brtvd->bv_nblocks + 1, KM_SLEEP); bitmap = kmem_alloc(brtvd->bv_nblocks + 1, KM_SLEEP);
for (idx = 0; idx < brtvd->bv_nblocks; idx++) { for (idx = 0; idx < brtvd->bv_nblocks; idx++) {
bitmap[idx] = bitmap[idx] =
BT_TEST(brtvd->bv_bitmap, idx) ? 'x' : '.'; BT_TEST(brtvd->bv_bitmap, idx) ? 'x' : '.';
}
bitmap[idx] = '\0';
zfs_dbgmsg(" bitmap: %s", bitmap);
kmem_free(bitmap, brtvd->bv_nblocks + 1);
} }
bitmap[idx] = '\0';
zfs_dbgmsg(" dirty: %s", bitmap);
kmem_free(bitmap, brtvd->bv_nblocks + 1);
} }
} }
#endif #endif
@ -767,7 +751,8 @@ brt_vdev_addref(brt_t *brt, brt_vdev_t *brtvd, const brt_entry_t *bre,
BT_SET(brtvd->bv_bitmap, idx); BT_SET(brtvd->bv_bitmap, idx);
#ifdef ZFS_DEBUG #ifdef ZFS_DEBUG
brt_vdev_dump(brt); if (zfs_flags & ZFS_DEBUG_BRT)
brt_vdev_dump(brtvd);
#endif #endif
} }
@ -803,7 +788,8 @@ brt_vdev_decref(brt_t *brt, brt_vdev_t *brtvd, const brt_entry_t *bre,
BT_SET(brtvd->bv_bitmap, idx); BT_SET(brtvd->bv_bitmap, idx);
#ifdef ZFS_DEBUG #ifdef ZFS_DEBUG
brt_vdev_dump(brt); if (zfs_flags & ZFS_DEBUG_BRT)
brt_vdev_dump(brtvd);
#endif #endif
} }