Skip to content

Commit 9743d09

Browse files
authored
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #15625
1 parent 2aa3a48 commit 9743d09

File tree

1 file changed

+33
-47
lines changed

1 file changed

+33
-47
lines changed

module/zfs/brt.c

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ brt_vdev_entcount_get(const brt_vdev_t *brtvd, uint64_t idx)
342342

343343
ASSERT3U(idx, <, brtvd->bv_size);
344344

345-
if (brtvd->bv_need_byteswap) {
345+
if (unlikely(brtvd->bv_need_byteswap)) {
346346
return (BSWAP_16(brtvd->bv_entcount[idx]));
347347
} else {
348348
return (brtvd->bv_entcount[idx]);
@@ -355,7 +355,7 @@ brt_vdev_entcount_set(brt_vdev_t *brtvd, uint64_t idx, uint16_t entcnt)
355355

356356
ASSERT3U(idx, <, brtvd->bv_size);
357357

358-
if (brtvd->bv_need_byteswap) {
358+
if (unlikely(brtvd->bv_need_byteswap)) {
359359
brtvd->bv_entcount[idx] = BSWAP_16(entcnt);
360360
} else {
361361
brtvd->bv_entcount[idx] = entcnt;
@@ -390,55 +390,39 @@ brt_vdev_entcount_dec(brt_vdev_t *brtvd, uint64_t idx)
390390

391391
#ifdef ZFS_DEBUG
392392
static void
393-
brt_vdev_dump(brt_t *brt)
393+
brt_vdev_dump(brt_vdev_t *brtvd)
394394
{
395-
brt_vdev_t *brtvd;
396-
uint64_t vdevid;
397-
398-
if ((zfs_flags & ZFS_DEBUG_BRT) == 0) {
399-
return;
400-
}
401-
402-
if (brt->brt_nvdevs == 0) {
403-
zfs_dbgmsg("BRT empty");
404-
return;
405-
}
406-
407-
zfs_dbgmsg("BRT vdev dump:");
408-
for (vdevid = 0; vdevid < brt->brt_nvdevs; vdevid++) {
409-
uint64_t idx;
395+
uint64_t idx;
410396

411-
brtvd = &brt->brt_vdevs[vdevid];
412-
zfs_dbgmsg(" vdevid=%llu/%llu meta_dirty=%d entcount_dirty=%d "
413-
"size=%llu totalcount=%llu nblocks=%llu bitmapsize=%zu\n",
414-
(u_longlong_t)vdevid, (u_longlong_t)brtvd->bv_vdevid,
415-
brtvd->bv_meta_dirty, brtvd->bv_entcount_dirty,
416-
(u_longlong_t)brtvd->bv_size,
417-
(u_longlong_t)brtvd->bv_totalcount,
418-
(u_longlong_t)brtvd->bv_nblocks,
419-
(size_t)BT_SIZEOFMAP(brtvd->bv_nblocks));
420-
if (brtvd->bv_totalcount > 0) {
421-
zfs_dbgmsg(" entcounts:");
422-
for (idx = 0; idx < brtvd->bv_size; idx++) {
423-
if (brt_vdev_entcount_get(brtvd, idx) > 0) {
424-
zfs_dbgmsg(" [%04llu] %hu",
425-
(u_longlong_t)idx,
426-
brt_vdev_entcount_get(brtvd, idx));
427-
}
397+
zfs_dbgmsg(" BRT vdevid=%llu meta_dirty=%d entcount_dirty=%d "
398+
"size=%llu totalcount=%llu nblocks=%llu bitmapsize=%zu\n",
399+
(u_longlong_t)brtvd->bv_vdevid,
400+
brtvd->bv_meta_dirty, brtvd->bv_entcount_dirty,
401+
(u_longlong_t)brtvd->bv_size,
402+
(u_longlong_t)brtvd->bv_totalcount,
403+
(u_longlong_t)brtvd->bv_nblocks,
404+
(size_t)BT_SIZEOFMAP(brtvd->bv_nblocks));
405+
if (brtvd->bv_totalcount > 0) {
406+
zfs_dbgmsg(" entcounts:");
407+
for (idx = 0; idx < brtvd->bv_size; idx++) {
408+
uint16_t entcnt = brt_vdev_entcount_get(brtvd, idx);
409+
if (entcnt > 0) {
410+
zfs_dbgmsg(" [%04llu] %hu",
411+
(u_longlong_t)idx, entcnt);
428412
}
429413
}
430-
if (brtvd->bv_entcount_dirty) {
431-
char *bitmap;
414+
}
415+
if (brtvd->bv_entcount_dirty) {
416+
char *bitmap;
432417

433-
bitmap = kmem_alloc(brtvd->bv_nblocks + 1, KM_SLEEP);
434-
for (idx = 0; idx < brtvd->bv_nblocks; idx++) {
435-
bitmap[idx] =
436-
BT_TEST(brtvd->bv_bitmap, idx) ? 'x' : '.';
437-
}
438-
bitmap[idx] = '\0';
439-
zfs_dbgmsg(" bitmap: %s", bitmap);
440-
kmem_free(bitmap, brtvd->bv_nblocks + 1);
418+
bitmap = kmem_alloc(brtvd->bv_nblocks + 1, KM_SLEEP);
419+
for (idx = 0; idx < brtvd->bv_nblocks; idx++) {
420+
bitmap[idx] =
421+
BT_TEST(brtvd->bv_bitmap, idx) ? 'x' : '.';
441422
}
423+
bitmap[idx] = '\0';
424+
zfs_dbgmsg(" dirty: %s", bitmap);
425+
kmem_free(bitmap, brtvd->bv_nblocks + 1);
442426
}
443427
}
444428
#endif
@@ -767,7 +751,8 @@ brt_vdev_addref(brt_t *brt, brt_vdev_t *brtvd, const brt_entry_t *bre,
767751
BT_SET(brtvd->bv_bitmap, idx);
768752

769753
#ifdef ZFS_DEBUG
770-
brt_vdev_dump(brt);
754+
if (zfs_flags & ZFS_DEBUG_BRT)
755+
brt_vdev_dump(brtvd);
771756
#endif
772757
}
773758

@@ -803,7 +788,8 @@ brt_vdev_decref(brt_t *brt, brt_vdev_t *brtvd, const brt_entry_t *bre,
803788
BT_SET(brtvd->bv_bitmap, idx);
804789

805790
#ifdef ZFS_DEBUG
806-
brt_vdev_dump(brt);
791+
if (zfs_flags & ZFS_DEBUG_BRT)
792+
brt_vdev_dump(brtvd);
807793
#endif
808794
}
809795

0 commit comments

Comments
 (0)