From 97fd1ea42a59b85ca29c91056ceef56c12cfae0b Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Thu, 21 Jul 2022 02:01:32 +0200 Subject: [PATCH 1/7] Fix memory allocation for the checksum benchmark Allocation via kmem_cache_alloc() is limited to less then 4m for some architectures. This commit limits the benchmarks with the linear abd cache to 1m on all architectures and adds 4m + 16m benchmarks via non-linear abd_alloc(). Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Co-authored-by: Sebastian Gottschall Signed-off-by: Tino Reichardt Closes #13669 Closes #13670 --- module/zfs/zfs_chksum.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/module/zfs/zfs_chksum.c b/module/zfs/zfs_chksum.c index a96505ab5fd2..f890b1103934 100644 --- a/module/zfs/zfs_chksum.c +++ b/module/zfs/zfs_chksum.c @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2021 Tino Reichardt + * Copyright (c) 2021-2022 Tino Reichardt */ #include @@ -43,6 +43,7 @@ typedef struct { uint64_t bs256k; uint64_t bs1m; uint64_t bs4m; + uint64_t bs16m; zio_cksum_salt_t salt; zio_checksum_t *(func); zio_checksum_tmpl_init_t *(init); @@ -85,7 +86,8 @@ chksum_stat_kstat_headers(char *buf, size_t size) off += snprintf(buf + off, size - off, "%8s", "64k"); off += snprintf(buf + off, size - off, "%8s", "256k"); off += snprintf(buf + off, size - off, "%8s", "1m"); - (void) snprintf(buf + off, size - off, "%8s\n", "4m"); + off += snprintf(buf + off, size - off, "%8s", "4m"); + (void) snprintf(buf + off, size - off, "%8s\n", "16m"); return (0); } @@ -112,8 +114,10 @@ chksum_stat_kstat_data(char *buf, size_t size, void *data) (u_longlong_t)cs->bs256k); off += snprintf(buf + off, size - off, "%8llu", (u_longlong_t)cs->bs1m); - (void) snprintf(buf + off, size - off, "%8llu\n", + off += snprintf(buf + off, size - off, "%8llu", (u_longlong_t)cs->bs4m); + (void) snprintf(buf + off, size - off, "%8llu\n", + (u_longlong_t)cs->bs16m); return (0); } @@ -153,6 +157,8 @@ chksum_run(chksum_stat_t *cs, abd_t *abd, void *ctx, int round, size = 1<<20; loops = 4; break; case 7: /* 4m */ size = 1<<22; loops = 1; break; + case 8: /* 16m */ + size = 1<<24; loops = 1; break; } kpreempt_disable(); @@ -177,26 +183,31 @@ chksum_benchit(chksum_stat_t *cs) void *ctx = 0; void *salt = &cs->salt.zcs_bytes; - /* allocate test memory via default abd interface */ - abd = abd_alloc_linear(1<<22, B_FALSE); memset(salt, 0, sizeof (cs->salt.zcs_bytes)); if (cs->init) { ctx = cs->init(&cs->salt); } + /* allocate test memory via abd linear interface */ + abd = abd_alloc_linear(1<<20, B_FALSE); chksum_run(cs, abd, ctx, 1, &cs->bs1k); chksum_run(cs, abd, ctx, 2, &cs->bs4k); chksum_run(cs, abd, ctx, 3, &cs->bs16k); chksum_run(cs, abd, ctx, 4, &cs->bs64k); chksum_run(cs, abd, ctx, 5, &cs->bs256k); chksum_run(cs, abd, ctx, 6, &cs->bs1m); + abd_free(abd); + + /* allocate test memory via abd non linear interface */ + abd = abd_alloc(1<<24, B_FALSE); chksum_run(cs, abd, ctx, 7, &cs->bs4m); + chksum_run(cs, abd, ctx, 8, &cs->bs16m); + abd_free(abd); /* free up temp memory */ if (cs->free) { cs->free(ctx); } - abd_free(abd); } /* From 33dba8c79224ce33dc661d545ab1d17fc3d84a0c Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 20 Jul 2022 20:02:36 -0400 Subject: [PATCH 2/7] Fix scrub resume from newly created hole It may happen that scan bookmark points to a block that was turned into a part of a big hole. In such case dsl_scan_visitbp() may skip it and dsl_scan_check_resume() will not be called for it. As result new scan suspend won't be possible until the end of the object, that may take hours if the object is a multi-terabyte ZVOL on a slow HDD pool, stretching TXG to all that time, creating all sorts of problems. This patch changes the resume condition to any greater or equal block, so even if we miss the bookmarked block, the next one we find will delete the bookmark, allowing new suspend. Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: Alexander Motin Sponsored-By: iXsystems, Inc. Closes #13643 --- include/sys/zio.h | 2 ++ module/zfs/dsl_scan.c | 10 ++++------ module/zfs/zio.c | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/include/sys/zio.h b/include/sys/zio.h index 9ddf46889d6c..b6f8da760465 100644 --- a/include/sys/zio.h +++ b/include/sys/zio.h @@ -696,6 +696,8 @@ extern void spa_handle_ignored_writes(spa_t *spa); /* zbookmark_phys functions */ boolean_t zbookmark_subtree_completed(const struct dnode_phys *dnp, const zbookmark_phys_t *subtree_root, const zbookmark_phys_t *last_block); +boolean_t zbookmark_subtree_tbd(const struct dnode_phys *dnp, + const zbookmark_phys_t *subtree_root, const zbookmark_phys_t *last_block); int zbookmark_compare(uint16_t dbss1, uint8_t ibs1, uint16_t dbss2, uint8_t ibs2, const zbookmark_phys_t *zb1, const zbookmark_phys_t *zb2); diff --git a/module/zfs/dsl_scan.c b/module/zfs/dsl_scan.c index 529d3da59bf8..2b76bed1b69b 100644 --- a/module/zfs/dsl_scan.c +++ b/module/zfs/dsl_scan.c @@ -1802,13 +1802,11 @@ dsl_scan_check_resume(dsl_scan_t *scn, const dnode_phys_t *dnp, /* * If we found the block we're trying to resume from, or - * we went past it to a different object, zero it out to - * indicate that it's OK to start checking for suspending - * again. + * we went past it, zero it out to indicate that it's OK + * to start checking for suspending again. */ - if (memcmp(zb, &scn->scn_phys.scn_bookmark, - sizeof (*zb)) == 0 || - zb->zb_object > scn->scn_phys.scn_bookmark.zb_object) { + if (zbookmark_subtree_tbd(dnp, zb, + &scn->scn_phys.scn_bookmark)) { dprintf("resuming at %llx/%llx/%llx/%llx\n", (longlong_t)zb->zb_objset, (longlong_t)zb->zb_object, diff --git a/module/zfs/zio.c b/module/zfs/zio.c index 6018ce6ca24f..3d1ac36d96da 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -4997,7 +4997,7 @@ zbookmark_subtree_completed(const dnode_phys_t *dnp, { zbookmark_phys_t mod_zb = *subtree_root; mod_zb.zb_blkid++; - ASSERT(last_block->zb_level == 0); + ASSERT0(last_block->zb_level); /* The objset_phys_t isn't before anything. */ if (dnp == NULL) @@ -5023,6 +5023,22 @@ zbookmark_subtree_completed(const dnode_phys_t *dnp, last_block) <= 0); } +/* + * This function is similar to zbookmark_subtree_completed(), but returns true + * if subtree_root is equal or ahead of last_block, i.e. still to be done. + */ +boolean_t +zbookmark_subtree_tbd(const dnode_phys_t *dnp, + const zbookmark_phys_t *subtree_root, const zbookmark_phys_t *last_block) +{ + ASSERT0(last_block->zb_level); + if (dnp == NULL) + return (B_FALSE); + return (zbookmark_compare(dnp->dn_datablkszsec, dnp->dn_indblkshift, + 1ULL << (DNODE_BLOCK_SHIFT - SPA_MINBLOCKSHIFT), 0, subtree_root, + last_block) >= 0); +} + EXPORT_SYMBOL(zio_type_name); EXPORT_SYMBOL(zio_buf_alloc); EXPORT_SYMBOL(zio_data_buf_alloc); From fb087146de0118108e3b44222d2052415dcb1f7f Mon Sep 17 00:00:00 2001 From: ixhamza <106930537+ixhamza@users.noreply.github.com> Date: Thu, 21 Jul 2022 05:14:06 +0500 Subject: [PATCH 3/7] Add support for per dataset zil stats and use wmsum counters ZIL kstats are reported in an inclusive way, i.e., same counters are shared to capture all the activities happening in zil. Added support to report zil stats for every datset individually by combining them with already exposed dataset kstats. Wmsum uses per cpu counters and provide less overhead as compared to atomic operations. Updated zil kstats to replace wmsum counters to avoid atomic operations. Reviewed-by: Christian Schwarz Reviewed-by: Ryan Moeller Reviewed-by: Alexander Motin Signed-off-by: Ameer Hamza Closes #13636 --- cmd/ztest.c | 6 +- include/sys/dataset_kstats.h | 8 +- include/sys/zil.h | 43 +++++++-- include/sys/zil_impl.h | 3 + module/os/freebsd/zfs/zfs_vfsops.c | 12 ++- module/os/freebsd/zfs/zvol_os.c | 10 +- module/os/linux/zfs/zfs_vfsops.c | 12 ++- module/os/linux/zfs/zvol_os.c | 10 +- module/zfs/dataset_kstats.c | 47 +++++++--- module/zfs/zil.c | 143 ++++++++++++++++++++++++----- 10 files changed, 232 insertions(+), 62 deletions(-) diff --git a/cmd/ztest.c b/cmd/ztest.c index 0e468e746786..31b9990a1fcf 100644 --- a/cmd/ztest.c +++ b/cmd/ztest.c @@ -2908,7 +2908,7 @@ ztest_zil_remount(ztest_ds_t *zd, uint64_t id) zil_close(zd->zd_zilog); /* zfsvfs_setup() */ - VERIFY3P(zil_open(os, ztest_get_data), ==, zd->zd_zilog); + VERIFY3P(zil_open(os, ztest_get_data, NULL), ==, zd->zd_zilog); zil_replay(os, zd, ztest_replay_vector); (void) pthread_rwlock_unlock(&zd->zd_zilog_lock); @@ -4378,7 +4378,7 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id) /* * Open the intent log for it. */ - zilog = zil_open(os, ztest_get_data); + zilog = zil_open(os, ztest_get_data, NULL); /* * Put some objects in there, do a little I/O to them, @@ -7304,7 +7304,7 @@ ztest_dataset_open(int d) zilog->zl_parse_lr_count, zilog->zl_replaying_seq); - zilog = zil_open(os, ztest_get_data); + zilog = zil_open(os, ztest_get_data, NULL); if (zilog->zl_replaying_seq != 0 && zilog->zl_replaying_seq < committed_seq) diff --git a/include/sys/dataset_kstats.h b/include/sys/dataset_kstats.h index d6e14572f79f..40cf5258a2e7 100644 --- a/include/sys/dataset_kstats.h +++ b/include/sys/dataset_kstats.h @@ -30,6 +30,7 @@ #include #include #include +#include typedef struct dataset_sum_stats_t { wmsum_t dss_writes; @@ -56,14 +57,19 @@ typedef struct dataset_kstat_values { * entry is removed from the unlinked set */ kstat_named_t dkv_nunlinked; + /* + * Per dataset zil kstats + */ + zil_kstat_values_t dkv_zil_stats; } dataset_kstat_values_t; typedef struct dataset_kstats { dataset_sum_stats_t dk_sums; + zil_sums_t dk_zil_sums; kstat_t *dk_kstats; } dataset_kstats_t; -void dataset_kstats_create(dataset_kstats_t *, objset_t *); +int dataset_kstats_create(dataset_kstats_t *, objset_t *); void dataset_kstats_destroy(dataset_kstats_t *); void dataset_kstats_update_write_kstats(dataset_kstats_t *, int64_t); diff --git a/include/sys/zil.h b/include/sys/zil.h index 3f1c38220298..cec04f120ce3 100644 --- a/include/sys/zil.h +++ b/include/sys/zil.h @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -472,12 +473,34 @@ typedef struct zil_stats { */ kstat_named_t zil_itx_metaslab_slog_count; kstat_named_t zil_itx_metaslab_slog_bytes; -} zil_stats_t; - -#define ZIL_STAT_INCR(stat, val) \ - atomic_add_64(&zil_stats.stat.value.ui64, (val)); -#define ZIL_STAT_BUMP(stat) \ - ZIL_STAT_INCR(stat, 1); +} zil_kstat_values_t; + +typedef struct zil_sums { + wmsum_t zil_commit_count; + wmsum_t zil_commit_writer_count; + wmsum_t zil_itx_count; + wmsum_t zil_itx_indirect_count; + wmsum_t zil_itx_indirect_bytes; + wmsum_t zil_itx_copied_count; + wmsum_t zil_itx_copied_bytes; + wmsum_t zil_itx_needcopy_count; + wmsum_t zil_itx_needcopy_bytes; + wmsum_t zil_itx_metaslab_normal_count; + wmsum_t zil_itx_metaslab_normal_bytes; + wmsum_t zil_itx_metaslab_slog_count; + wmsum_t zil_itx_metaslab_slog_bytes; +} zil_sums_t; + +#define ZIL_STAT_INCR(zil, stat, val) \ + do { \ + int64_t tmpval = (val); \ + wmsum_add(&(zil_sums_global.stat), tmpval); \ + if ((zil)->zl_sums) \ + wmsum_add(&((zil)->zl_sums->stat), tmpval); \ + } while (0) + +#define ZIL_STAT_BUMP(zil, stat) \ + ZIL_STAT_INCR(zil, stat, 1); typedef int zil_parse_blk_func_t(zilog_t *zilog, const blkptr_t *bp, void *arg, uint64_t txg); @@ -497,7 +520,8 @@ extern void zil_fini(void); extern zilog_t *zil_alloc(objset_t *os, zil_header_t *zh_phys); extern void zil_free(zilog_t *zilog); -extern zilog_t *zil_open(objset_t *os, zil_get_data_t *get_data); +extern zilog_t *zil_open(objset_t *os, zil_get_data_t *get_data, + zil_sums_t *zil_sums); extern void zil_close(zilog_t *zilog); extern void zil_replay(objset_t *os, void *arg, @@ -537,6 +561,11 @@ extern void zil_set_logbias(zilog_t *zilog, uint64_t slogval); extern uint64_t zil_max_copied_data(zilog_t *zilog); extern uint64_t zil_max_log_data(zilog_t *zilog); +extern void zil_sums_init(zil_sums_t *zs); +extern void zil_sums_fini(zil_sums_t *zs); +extern void zil_kstat_values_update(zil_kstat_values_t *zs, + zil_sums_t *zil_sums); + extern int zil_replay_disable; #ifdef __cplusplus diff --git a/include/sys/zil_impl.h b/include/sys/zil_impl.h index f670c3671be9..bb85bf6d1eb1 100644 --- a/include/sys/zil_impl.h +++ b/include/sys/zil_impl.h @@ -222,6 +222,9 @@ struct zilog { * (see zil_max_copied_data()). */ uint64_t zl_max_block_size; + + /* Pointer for per dataset zil sums */ + zil_sums_t *zl_sums; }; typedef struct zil_bp_node { diff --git a/module/os/freebsd/zfs/zfs_vfsops.c b/module/os/freebsd/zfs/zfs_vfsops.c index 0a9461e232dd..24e06b1a8809 100644 --- a/module/os/freebsd/zfs/zfs_vfsops.c +++ b/module/os/freebsd/zfs/zfs_vfsops.c @@ -1027,8 +1027,6 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting) if (error) return (error); - zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data); - /* * If we are not mounting (ie: online recv), then we don't * have to worry about replaying the log as we blocked all @@ -1038,7 +1036,11 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting) boolean_t readonly; ASSERT3P(zfsvfs->z_kstat.dk_kstats, ==, NULL); - dataset_kstats_create(&zfsvfs->z_kstat, zfsvfs->z_os); + error = dataset_kstats_create(&zfsvfs->z_kstat, zfsvfs->z_os); + if (error) + return (error); + zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data, + &zfsvfs->z_kstat.dk_zil_sums); /* * During replay we remove the read only flag to @@ -1109,6 +1111,10 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting) /* restore readonly bit */ if (readonly != 0) zfsvfs->z_vfs->vfs_flag |= VFS_RDONLY; + } else { + ASSERT3P(zfsvfs->z_kstat.dk_kstats, !=, NULL); + zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data, + &zfsvfs->z_kstat.dk_zil_sums); } /* diff --git a/module/os/freebsd/zfs/zvol_os.c b/module/os/freebsd/zfs/zvol_os.c index f6f26157f855..ac030f75323e 100644 --- a/module/os/freebsd/zfs/zvol_os.c +++ b/module/os/freebsd/zfs/zvol_os.c @@ -1189,7 +1189,7 @@ zvol_ensure_zilog(zvol_state_t *zv) } if (zv->zv_zilog == NULL) { zv->zv_zilog = zil_open(zv->zv_objset, - zvol_get_data); + zvol_get_data, &zv->zv_kstat.dk_zil_sums); zv->zv_flags |= ZVOL_WRITTEN_TO; /* replay / destroy done in zvol_os_create_minor() */ VERIFY0(zv->zv_zilog->zl_header->zh_flags & @@ -1422,8 +1422,12 @@ zvol_os_create_minor(const char *name) zv->zv_volsize = volsize; zv->zv_objset = os; + ASSERT3P(zv->zv_kstat.dk_kstats, ==, NULL); + error = dataset_kstats_create(&zv->zv_kstat, zv->zv_objset); + if (error) + goto out_dmu_objset_disown; ASSERT3P(zv->zv_zilog, ==, NULL); - zv->zv_zilog = zil_open(os, zvol_get_data); + zv->zv_zilog = zil_open(os, zvol_get_data, &zv->zv_kstat.dk_zil_sums); if (spa_writeable(dmu_objset_spa(os))) { if (zil_replay_disable) zil_destroy(zv->zv_zilog, B_FALSE); @@ -1432,8 +1436,6 @@ zvol_os_create_minor(const char *name) } zil_close(zv->zv_zilog); zv->zv_zilog = NULL; - ASSERT3P(zv->zv_kstat.dk_kstats, ==, NULL); - dataset_kstats_create(&zv->zv_kstat, zv->zv_objset); /* TODO: prefetch for geom tasting */ diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index 4fcda78818d1..eac3dcb6a55c 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -848,8 +848,6 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting) if (error) return (error); - zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data); - /* * If we are not mounting (ie: online recv), then we don't * have to worry about replaying the log as we blocked all @@ -857,7 +855,11 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting) */ if (mounting) { ASSERT3P(zfsvfs->z_kstat.dk_kstats, ==, NULL); - dataset_kstats_create(&zfsvfs->z_kstat, zfsvfs->z_os); + error = dataset_kstats_create(&zfsvfs->z_kstat, zfsvfs->z_os); + if (error) + return (error); + zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data, + &zfsvfs->z_kstat.dk_zil_sums); /* * During replay we remove the read only flag to @@ -921,6 +923,10 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting) /* restore readonly bit */ if (readonly != 0) readonly_changed_cb(zfsvfs, B_TRUE); + } else { + ASSERT3P(zfsvfs->z_kstat.dk_kstats, !=, NULL); + zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data, + &zfsvfs->z_kstat.dk_zil_sums); } /* diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index 68aeb14580b1..18b9fbd0ea55 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -558,7 +558,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq, rw_enter(&zv->zv_suspend_lock, RW_WRITER); if (zv->zv_zilog == NULL) { zv->zv_zilog = zil_open(zv->zv_objset, - zvol_get_data); + zvol_get_data, &zv->zv_kstat.dk_zil_sums); zv->zv_flags |= ZVOL_WRITTEN_TO; /* replay / destroy done in zvol_create_minor */ VERIFY0((zv->zv_zilog->zl_header->zh_flags & @@ -1408,8 +1408,12 @@ zvol_os_create_minor(const char *name) blk_queue_flag_set(QUEUE_FLAG_SCSI_PASSTHROUGH, zv->zv_zso->zvo_queue); #endif + ASSERT3P(zv->zv_kstat.dk_kstats, ==, NULL); + error = dataset_kstats_create(&zv->zv_kstat, zv->zv_objset); + if (error) + goto out_dmu_objset_disown; ASSERT3P(zv->zv_zilog, ==, NULL); - zv->zv_zilog = zil_open(os, zvol_get_data); + zv->zv_zilog = zil_open(os, zvol_get_data, &zv->zv_kstat.dk_zil_sums); if (spa_writeable(dmu_objset_spa(os))) { if (zil_replay_disable) zil_destroy(zv->zv_zilog, B_FALSE); @@ -1418,8 +1422,6 @@ zvol_os_create_minor(const char *name) } zil_close(zv->zv_zilog); zv->zv_zilog = NULL; - ASSERT3P(zv->zv_kstat.dk_kstats, ==, NULL); - dataset_kstats_create(&zv->zv_kstat, zv->zv_objset); /* * When udev detects the addition of the device it will immediately diff --git a/module/zfs/dataset_kstats.c b/module/zfs/dataset_kstats.c index 9130574c575d..b63f42a21e44 100644 --- a/module/zfs/dataset_kstats.c +++ b/module/zfs/dataset_kstats.c @@ -37,18 +37,33 @@ static dataset_kstat_values_t empty_dataset_kstats = { { "nread", KSTAT_DATA_UINT64 }, { "nunlinks", KSTAT_DATA_UINT64 }, { "nunlinked", KSTAT_DATA_UINT64 }, + { + { "zil_commit_count", KSTAT_DATA_UINT64 }, + { "zil_commit_writer_count", KSTAT_DATA_UINT64 }, + { "zil_itx_count", KSTAT_DATA_UINT64 }, + { "zil_itx_indirect_count", KSTAT_DATA_UINT64 }, + { "zil_itx_indirect_bytes", KSTAT_DATA_UINT64 }, + { "zil_itx_copied_count", KSTAT_DATA_UINT64 }, + { "zil_itx_copied_bytes", KSTAT_DATA_UINT64 }, + { "zil_itx_needcopy_count", KSTAT_DATA_UINT64 }, + { "zil_itx_needcopy_bytes", KSTAT_DATA_UINT64 }, + { "zil_itx_metaslab_normal_count", KSTAT_DATA_UINT64 }, + { "zil_itx_metaslab_normal_bytes", KSTAT_DATA_UINT64 }, + { "zil_itx_metaslab_slog_count", KSTAT_DATA_UINT64 }, + { "zil_itx_metaslab_slog_bytes", KSTAT_DATA_UINT64 } + } }; static int dataset_kstats_update(kstat_t *ksp, int rw) { dataset_kstats_t *dk = ksp->ks_private; - ASSERT3P(dk->dk_kstats->ks_data, ==, ksp->ks_data); + dataset_kstat_values_t *dkv = ksp->ks_data; + ASSERT3P(dk->dk_kstats->ks_data, ==, dkv); if (rw == KSTAT_WRITE) return (EACCES); - dataset_kstat_values_t *dkv = dk->dk_kstats->ks_data; dkv->dkv_writes.value.ui64 = wmsum_value(&dk->dk_sums.dss_writes); dkv->dkv_nwritten.value.ui64 = @@ -62,10 +77,12 @@ dataset_kstats_update(kstat_t *ksp, int rw) dkv->dkv_nunlinked.value.ui64 = wmsum_value(&dk->dk_sums.dss_nunlinked); + zil_kstat_values_update(&dkv->dkv_zil_stats, &dk->dk_zil_sums); + return (0); } -void +int dataset_kstats_create(dataset_kstats_t *dk, objset_t *objset) { /* @@ -75,7 +92,7 @@ dataset_kstats_create(dataset_kstats_t *dk, objset_t *objset) * a filesystem with many snapshots, we skip them for now. */ if (dmu_objset_is_snapshot(objset)) - return; + return (0); /* * At the time of this writing, KSTAT_STRLEN is 255 in Linux, @@ -94,13 +111,13 @@ dataset_kstats_create(dataset_kstats_t *dk, objset_t *objset) zfs_dbgmsg("failed to create dataset kstat for objset %lld: " " snprintf() for kstat module name returned %d", (unsigned long long)dmu_objset_id(objset), n); - return; + return (SET_ERROR(EINVAL)); } else if (n >= KSTAT_STRLEN) { zfs_dbgmsg("failed to create dataset kstat for objset %lld: " "kstat module name length (%d) exceeds limit (%d)", (unsigned long long)dmu_objset_id(objset), n, KSTAT_STRLEN); - return; + return (SET_ERROR(ENAMETOOLONG)); } char kstat_name[KSTAT_STRLEN]; @@ -110,7 +127,7 @@ dataset_kstats_create(dataset_kstats_t *dk, objset_t *objset) zfs_dbgmsg("failed to create dataset kstat for objset %lld: " " snprintf() for kstat name returned %d", (unsigned long long)dmu_objset_id(objset), n); - return; + return (SET_ERROR(EINVAL)); } ASSERT3U(n, <, KSTAT_STRLEN); @@ -119,7 +136,7 @@ dataset_kstats_create(dataset_kstats_t *dk, objset_t *objset) sizeof (empty_dataset_kstats) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL); if (kstat == NULL) - return; + return (SET_ERROR(ENOMEM)); dataset_kstat_values_t *dk_kstats = kmem_alloc(sizeof (empty_dataset_kstats), KM_SLEEP); @@ -137,15 +154,17 @@ dataset_kstats_create(dataset_kstats_t *dk, objset_t *objset) kstat->ks_private = dk; kstat->ks_data_size += ZFS_MAX_DATASET_NAME_LEN; - kstat_install(kstat); - dk->dk_kstats = kstat; - wmsum_init(&dk->dk_sums.dss_writes, 0); wmsum_init(&dk->dk_sums.dss_nwritten, 0); wmsum_init(&dk->dk_sums.dss_reads, 0); wmsum_init(&dk->dk_sums.dss_nread, 0); wmsum_init(&dk->dk_sums.dss_nunlinks, 0); wmsum_init(&dk->dk_sums.dss_nunlinked, 0); + zil_sums_init(&dk->dk_zil_sums); + + dk->dk_kstats = kstat; + kstat_install(kstat); + return (0); } void @@ -155,19 +174,19 @@ dataset_kstats_destroy(dataset_kstats_t *dk) return; dataset_kstat_values_t *dkv = dk->dk_kstats->ks_data; + kstat_delete(dk->dk_kstats); + dk->dk_kstats = NULL; kmem_free(KSTAT_NAMED_STR_PTR(&dkv->dkv_ds_name), KSTAT_NAMED_STR_BUFLEN(&dkv->dkv_ds_name)); kmem_free(dkv, sizeof (empty_dataset_kstats)); - kstat_delete(dk->dk_kstats); - dk->dk_kstats = NULL; - wmsum_fini(&dk->dk_sums.dss_writes); wmsum_fini(&dk->dk_sums.dss_nwritten); wmsum_fini(&dk->dk_sums.dss_reads); wmsum_fini(&dk->dk_sums.dss_nread); wmsum_fini(&dk->dk_sums.dss_nunlinks); wmsum_fini(&dk->dk_sums.dss_nunlinked); + zil_sums_fini(&dk->dk_zil_sums); } void diff --git a/module/zfs/zil.c b/module/zfs/zil.c index bffae6dfd732..4864e0ccad53 100644 --- a/module/zfs/zil.c +++ b/module/zfs/zil.c @@ -43,6 +43,7 @@ #include #include #include +#include /* * The ZFS Intent Log (ZIL) saves "transaction records" (itxs) of system @@ -94,7 +95,7 @@ static int zfs_commit_timeout_pct = 5; /* * See zil.h for more information about these fields. */ -static zil_stats_t zil_stats = { +static zil_kstat_values_t zil_stats = { { "zil_commit_count", KSTAT_DATA_UINT64 }, { "zil_commit_writer_count", KSTAT_DATA_UINT64 }, { "zil_itx_count", KSTAT_DATA_UINT64 }, @@ -110,7 +111,8 @@ static zil_stats_t zil_stats = { { "zil_itx_metaslab_slog_bytes", KSTAT_DATA_UINT64 }, }; -static kstat_t *zil_ksp; +static zil_sums_t zil_sums_global; +static kstat_t *zil_kstats_global; /* * Disable intent logging replay. This global ZIL switch affects all pools. @@ -213,6 +215,21 @@ zil_init_log_chain(zilog_t *zilog, blkptr_t *bp) zc->zc_word[ZIL_ZC_SEQ] = 1ULL; } +static int +zil_kstats_global_update(kstat_t *ksp, int rw) +{ + zil_kstat_values_t *zs = ksp->ks_data; + ASSERT3P(&zil_stats, ==, zs); + + if (rw == KSTAT_WRITE) { + return (SET_ERROR(EACCES)); + } + + zil_kstat_values_update(zs, &zil_sums_global); + + return (0); +} + /* * Read a log block and make sure it's valid. */ @@ -337,6 +354,73 @@ zil_read_log_data(zilog_t *zilog, const lr_write_t *lr, void *wbuf) return (error); } +void +zil_sums_init(zil_sums_t *zs) +{ + wmsum_init(&zs->zil_commit_count, 0); + wmsum_init(&zs->zil_commit_writer_count, 0); + wmsum_init(&zs->zil_itx_count, 0); + wmsum_init(&zs->zil_itx_indirect_count, 0); + wmsum_init(&zs->zil_itx_indirect_bytes, 0); + wmsum_init(&zs->zil_itx_copied_count, 0); + wmsum_init(&zs->zil_itx_copied_bytes, 0); + wmsum_init(&zs->zil_itx_needcopy_count, 0); + wmsum_init(&zs->zil_itx_needcopy_bytes, 0); + wmsum_init(&zs->zil_itx_metaslab_normal_count, 0); + wmsum_init(&zs->zil_itx_metaslab_normal_bytes, 0); + wmsum_init(&zs->zil_itx_metaslab_slog_count, 0); + wmsum_init(&zs->zil_itx_metaslab_slog_bytes, 0); +} + +void +zil_sums_fini(zil_sums_t *zs) +{ + wmsum_fini(&zs->zil_commit_count); + wmsum_fini(&zs->zil_commit_writer_count); + wmsum_fini(&zs->zil_itx_count); + wmsum_fini(&zs->zil_itx_indirect_count); + wmsum_fini(&zs->zil_itx_indirect_bytes); + wmsum_fini(&zs->zil_itx_copied_count); + wmsum_fini(&zs->zil_itx_copied_bytes); + wmsum_fini(&zs->zil_itx_needcopy_count); + wmsum_fini(&zs->zil_itx_needcopy_bytes); + wmsum_fini(&zs->zil_itx_metaslab_normal_count); + wmsum_fini(&zs->zil_itx_metaslab_normal_bytes); + wmsum_fini(&zs->zil_itx_metaslab_slog_count); + wmsum_fini(&zs->zil_itx_metaslab_slog_bytes); +} + +void +zil_kstat_values_update(zil_kstat_values_t *zs, zil_sums_t *zil_sums) +{ + zs->zil_commit_count.value.ui64 = + wmsum_value(&zil_sums->zil_commit_count); + zs->zil_commit_writer_count.value.ui64 = + wmsum_value(&zil_sums->zil_commit_writer_count); + zs->zil_itx_count.value.ui64 = + wmsum_value(&zil_sums->zil_itx_count); + zs->zil_itx_indirect_count.value.ui64 = + wmsum_value(&zil_sums->zil_itx_indirect_count); + zs->zil_itx_indirect_bytes.value.ui64 = + wmsum_value(&zil_sums->zil_itx_indirect_bytes); + zs->zil_itx_copied_count.value.ui64 = + wmsum_value(&zil_sums->zil_itx_copied_count); + zs->zil_itx_copied_bytes.value.ui64 = + wmsum_value(&zil_sums->zil_itx_copied_bytes); + zs->zil_itx_needcopy_count.value.ui64 = + wmsum_value(&zil_sums->zil_itx_needcopy_count); + zs->zil_itx_needcopy_bytes.value.ui64 = + wmsum_value(&zil_sums->zil_itx_needcopy_bytes); + zs->zil_itx_metaslab_normal_count.value.ui64 = + wmsum_value(&zil_sums->zil_itx_metaslab_normal_count); + zs->zil_itx_metaslab_normal_bytes.value.ui64 = + wmsum_value(&zil_sums->zil_itx_metaslab_normal_bytes); + zs->zil_itx_metaslab_slog_count.value.ui64 = + wmsum_value(&zil_sums->zil_itx_metaslab_slog_count); + zs->zil_itx_metaslab_slog_bytes.value.ui64 = + wmsum_value(&zil_sums->zil_itx_metaslab_slog_bytes); +} + /* * Parse the intent log, and call parse_func for each valid record within. */ @@ -1644,11 +1728,13 @@ zil_lwb_write_issue(zilog_t *zilog, lwb_t *lwb) BP_ZERO(bp); error = zio_alloc_zil(spa, zilog->zl_os, txg, bp, zil_blksz, &slog); if (slog) { - ZIL_STAT_BUMP(zil_itx_metaslab_slog_count); - ZIL_STAT_INCR(zil_itx_metaslab_slog_bytes, lwb->lwb_nused); + ZIL_STAT_BUMP(zilog, zil_itx_metaslab_slog_count); + ZIL_STAT_INCR(zilog, zil_itx_metaslab_slog_bytes, + lwb->lwb_nused); } else { - ZIL_STAT_BUMP(zil_itx_metaslab_normal_count); - ZIL_STAT_INCR(zil_itx_metaslab_normal_bytes, lwb->lwb_nused); + ZIL_STAT_BUMP(zilog, zil_itx_metaslab_normal_count); + ZIL_STAT_INCR(zilog, zil_itx_metaslab_normal_bytes, + lwb->lwb_nused); } if (error == 0) { ASSERT3U(bp->blk_birth, ==, txg); @@ -1818,7 +1904,7 @@ zil_lwb_commit(zilog_t *zilog, itx_t *itx, lwb_t *lwb) lrcb = (lr_t *)lr_buf; /* Like lrc, but inside lwb. */ lrwb = (lr_write_t *)lrcb; /* Like lrw, but inside lwb. */ - ZIL_STAT_BUMP(zil_itx_count); + ZIL_STAT_BUMP(zilog, zil_itx_count); /* * If it's a write, fetch the data or get its blkptr as appropriate. @@ -1827,8 +1913,9 @@ zil_lwb_commit(zilog_t *zilog, itx_t *itx, lwb_t *lwb) if (txg > spa_freeze_txg(zilog->zl_spa)) txg_wait_synced(zilog->zl_dmu_pool, txg); if (itx->itx_wr_state == WR_COPIED) { - ZIL_STAT_BUMP(zil_itx_copied_count); - ZIL_STAT_INCR(zil_itx_copied_bytes, lrw->lr_length); + ZIL_STAT_BUMP(zilog, zil_itx_copied_count); + ZIL_STAT_INCR(zilog, zil_itx_copied_bytes, + lrw->lr_length); } else { char *dbuf; int error; @@ -1840,13 +1927,14 @@ zil_lwb_commit(zilog_t *zilog, itx_t *itx, lwb_t *lwb) lrwb->lr_length = dnow; lrw->lr_offset += dnow; lrw->lr_length -= dnow; - ZIL_STAT_BUMP(zil_itx_needcopy_count); - ZIL_STAT_INCR(zil_itx_needcopy_bytes, dnow); + ZIL_STAT_BUMP(zilog, zil_itx_needcopy_count); + ZIL_STAT_INCR(zilog, zil_itx_needcopy_bytes, + dnow); } else { ASSERT3S(itx->itx_wr_state, ==, WR_INDIRECT); dbuf = NULL; - ZIL_STAT_BUMP(zil_itx_indirect_count); - ZIL_STAT_INCR(zil_itx_indirect_bytes, + ZIL_STAT_BUMP(zilog, zil_itx_indirect_count); + ZIL_STAT_INCR(zilog, zil_itx_indirect_bytes, lrw->lr_length); } @@ -2611,7 +2699,7 @@ zil_commit_writer(zilog_t *zilog, zil_commit_waiter_t *zcw) goto out; } - ZIL_STAT_BUMP(zil_commit_writer_count); + ZIL_STAT_BUMP(zilog, zil_commit_writer_count); zil_get_commit_list(zilog); zil_prune_commit_list(zilog); @@ -3088,7 +3176,7 @@ zil_commit(zilog_t *zilog, uint64_t foid) void zil_commit_impl(zilog_t *zilog, uint64_t foid) { - ZIL_STAT_BUMP(zil_commit_count); + ZIL_STAT_BUMP(zilog, zil_commit_count); /* * Move the "async" itxs for the specified foid to the "sync" @@ -3271,13 +3359,16 @@ zil_init(void) zil_zcw_cache = kmem_cache_create("zil_zcw_cache", sizeof (zil_commit_waiter_t), 0, NULL, NULL, NULL, NULL, NULL, 0); - zil_ksp = kstat_create("zfs", 0, "zil", "misc", + zil_sums_init(&zil_sums_global); + zil_kstats_global = kstat_create("zfs", 0, "zil", "misc", KSTAT_TYPE_NAMED, sizeof (zil_stats) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL); - if (zil_ksp != NULL) { - zil_ksp->ks_data = &zil_stats; - kstat_install(zil_ksp); + if (zil_kstats_global != NULL) { + zil_kstats_global->ks_data = &zil_stats; + zil_kstats_global->ks_update = zil_kstats_global_update; + zil_kstats_global->ks_private = NULL; + kstat_install(zil_kstats_global); } } @@ -3287,10 +3378,12 @@ zil_fini(void) kmem_cache_destroy(zil_zcw_cache); kmem_cache_destroy(zil_lwb_cache); - if (zil_ksp != NULL) { - kstat_delete(zil_ksp); - zil_ksp = NULL; + if (zil_kstats_global != NULL) { + kstat_delete(zil_kstats_global); + zil_kstats_global = NULL; } + + zil_sums_fini(&zil_sums_global); } void @@ -3388,7 +3481,7 @@ zil_free(zilog_t *zilog) * Open an intent log. */ zilog_t * -zil_open(objset_t *os, zil_get_data_t *get_data) +zil_open(objset_t *os, zil_get_data_t *get_data, zil_sums_t *zil_sums) { zilog_t *zilog = dmu_objset_zil(os); @@ -3397,6 +3490,7 @@ zil_open(objset_t *os, zil_get_data_t *get_data) ASSERT(list_is_empty(&zilog->zl_lwb_list)); zilog->zl_get_data = get_data; + zilog->zl_sums = zil_sums; return (zilog); } @@ -3838,6 +3932,9 @@ EXPORT_SYMBOL(zil_lwb_add_block); EXPORT_SYMBOL(zil_bp_tree_add); EXPORT_SYMBOL(zil_set_sync); EXPORT_SYMBOL(zil_set_logbias); +EXPORT_SYMBOL(zil_sums_init); +EXPORT_SYMBOL(zil_sums_fini); +EXPORT_SYMBOL(zil_kstat_values_update); ZFS_MODULE_PARAM(zfs, zfs_, commit_timeout_pct, INT, ZMOD_RW, "ZIL block open timeout percentage"); From bf61a507a276866d691a2b56866302bc42145af3 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Thu, 21 Jul 2022 02:16:29 +0200 Subject: [PATCH 4/7] zdb: dump spill block pointer if present Output will look like so: $ sudo zdb -dddd -vv testpool/fs 2 Dataset testpool/fs [ZPL], ID 260, cr_txg 8, 25K, 7 objects, rootbp DVA[0]=<0:1800be00:200> DVA[1]=<0:1c00be00:200> [L0 DMU objset] fletcher4 lz4 unencrypted LE contiguous unique double size=1000L/200P birth=16L/16P fill=7 cksum=d03b396cd:489ca835517:d4b04a4d0a62:1b413aac454d53 Object lvl iblk dblk dsize dnsize lsize %full type 2 1 128K 512 1K 512 512 0.00 ZFS plain file (K=inherit) (Z=inherit=lz4) 192 bonus System attributes dnode flags: USED_BYTES USERUSED_ACCOUNTED USEROBJUSED_ACCOUNTED SPILL_BLKPTR dnode maxblkid: 0 path /testfile uid 0 gid 0 atime Fri Jul 15 12:36:35 2022 mtime Fri Jul 15 12:36:35 2022 ctime Fri Jul 15 12:36:51 2022 crtime Fri Jul 15 12:36:35 2022 gen 10 mode 100600 size 0 parent 34 links 1 pflags 840800000004 SA xattrs: 248 bytes, 2 entries security.selinux = nutanix_u:object_r:unlabeled_t:s0\000 user.foo = xbLQJjyVvEVPGGuRHV/gjkFFO1MdehKnLjjd36ZaoMVaUqtqFoMMYT5Ya9yywHApJNoK/1hNJfO3\012XCJWv9/QUTKamoWW9xVDE7yi8zn166RNw5QUhf84cZ3JNLnw6oN Spill block: 0:10005c00:200 0:14005c00:200 200L/200P F=1 B=16/16 cksum=1cdfac47a4:910c5caa557:195d0493dfe5a:332b6fde6ad547 Indirect blocks: Reviewed-by: Brian Behlendorf Reviewed-by: Allan Jude Signed-off-by: Christian Schwarz Closes #13640 --- cmd/zdb/zdb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index fff00a64ac81..fdf569691cb2 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -3565,8 +3565,15 @@ dump_object(objset_t *os, uint64_t object, int verbosity, *print_header = B_TRUE; } - if (verbosity >= 5) + if (verbosity >= 5) { + if (dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR) { + char blkbuf[BP_SPRINTF_LEN]; + snprintf_blkptr_compact(blkbuf, sizeof (blkbuf), + DN_SPILL_BLKPTR(dn->dn_phys), B_FALSE); + (void) printf("\nSpill block: %s\n", blkbuf); + } dump_indirect(dn); + } if (verbosity >= 5) { /* From 74348f2a81a0793e23cb8299fadee8b3f6ea39a4 Mon Sep 17 00:00:00 2001 From: Ankur Srivastava Date: Mon, 25 Jul 2022 08:56:49 +0530 Subject: [PATCH 5/7] QA-35139 zcache and slog device sharing azure (#519) Use zdb lib function to be compatible with object store for all supported tests. * pool checkpoint tests * zdb --- tests/zfs-tests/include/object_store.shlib | 29 ++++++++++++++----- .../functional/cli_root/zdb/zdb_006_pos.ksh | 8 ++--- .../functional/cli_root/zdb/zdb_args_neg.ksh | 2 +- .../functional/cli_root/zdb/zdb_args_pos.ksh | 4 +-- .../functional/cli_root/zdb/zdb_checksum.ksh | 4 +-- .../cli_root/zdb/zdb_decompress.ksh | 10 +++---- .../cli_root/zdb/zdb_decompress_zstd.ksh | 4 +-- .../cli_root/zdb/zdb_display_block.ksh | 16 +++++----- .../cli_root/zdb/zdb_object_range_neg.ksh | 10 +++---- .../functional/cli_root/zdb/zdb_objset_id.ksh | 6 ++-- .../pool_checkpoint/checkpoint_big_rewind.ksh | 2 +- .../pool_checkpoint/checkpoint_capacity.ksh | 4 +-- .../checkpoint_discard_busy.ksh | 4 +-- .../pool_checkpoint/checkpoint_zdb.ksh | 12 ++++---- .../zcache_slog_sharing/cleanup.ksh | 6 +++- .../functional/zcache_slog_sharing/setup.ksh | 2 +- ...g_sharing_import_pool_slog_missing_neg.ksh | 6 ++-- ...zcache_slog_sharing_multiple_pools_pos.ksh | 1 - ...he_slog_sharing_slog_same_as_cache_neg.ksh | 1 - ...e_slog_sharing_without_cache_inuse_pos.ksh | 5 ++-- ...g_sharing_zoa_invalid_cache_device_neg.ksh | 8 +++-- .../zcache_slog_sharing_zpool_add_pos.ksh | 1 - .../zcache_slog_sharing_zpool_create_pos.ksh | 1 - .../zcache_slog_sharing_zpool_import_pos.ksh | 1 - 24 files changed, 81 insertions(+), 66 deletions(-) diff --git a/tests/zfs-tests/include/object_store.shlib b/tests/zfs-tests/include/object_store.shlib index b0d278292aec..e8007f6a2ba9 100644 --- a/tests/zfs-tests/include/object_store.shlib +++ b/tests/zfs-tests/include/object_store.shlib @@ -243,16 +243,29 @@ function get_zoa_debug_log # Takes a list of devices and configures it to be # used a zettacache # -function configure_zettacache +function zcache_add_devices { - typeset zcache_devices=$(echo $@ | tr ' ' ',') - stop_zfs_object_agent - # Truncate the zoa log to verify cache information + typeset zcache_devices="$@" sudo truncate -s 0 $(get_zoa_debug_log) - for cache_dev in ${ZETTACACHE_DEVICES}; do - invalidate_zcache_dev $cache_dev + for cache_dev in $zcache_devices; do + zcache add $cache_dev done - start_zfs_object_agent +} + +# +# Helper function to invalidate a list +# of cache devices. +# The invalidation is done by removing the +# associated label. +# +function zcache_remove_devices +{ + typeset cache_devices="$@" + sudo systemctl stop zfs-object-agent + for cache_dev in $cache_devices; do + zcache labelclear -f "$cache_dev" + done + sudo systemctl start zfs-object-agent } # @@ -269,7 +282,7 @@ function verify_zcache_added_from_logfile # So we retry for 10 time sleeping for 1 seconds # after each retry while [ $retry_count -lt $max_retries ]; do - grep -q "opening cache file ${cache_device}:" $(get_zoa_debug_log) + grep -q "opening cache file \"${cache_device}\":" $(get_zoa_debug_log) [ $? -eq 0 ] && return 0 sleep 1 retry_count=$((retry_count+1)) diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_006_pos.ksh index 53be72635459..04da646ad7d7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_006_pos.ksh @@ -46,10 +46,10 @@ verify_runnable "global" default_setup_noexit "$DISKS" log_must zfs snap $TESTPOOL/$TESTFS@snap -log_must zdb -d $TESTPOOL -log_must zdb -d $TESTPOOL/ -log_must zdb -d $TESTPOOL/$TESTFS -log_must zdb -d $TESTPOOL/$TESTFS@snap +log_must run_zdb -e "-d" -p $TESTPOOL +log_must run_zdb -e "-d" -p $TESTPOOL/ +log_must run_zdb -e "-d" -p $TESTPOOL/$TESTFS +log_must run_zdb -e "-d" -p $TESTPOOL/$TESTFS@snap log_must zpool export $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh index 336476137b66..b6e549a955ec 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh @@ -58,7 +58,7 @@ set -A args "create" "add" "destroy" "import fakepool" \ "setvprop" "blah blah" "-%" "--?" "-*" "-=" \ "-j" "-n" "-o" "-p" "-p /tmp" \ "-t" "-w" "-E" "-H" "-I" "-J" "-K" \ - "-Q" "-R" "-T" "-W" + "-Q" "-R" "-d -T" "-W" log_assert "Execute zdb using invalid parameters." diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh index 77b999dfd259..1070cb2f01fc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh @@ -59,7 +59,7 @@ function test_imported_pool { typeset -a args=("-A" "-b" "-C" "-c" "-d" "-D" "-G" "-h" "-i" "-L" \ "-M" "-P" "-s" "-v" "-Y" "-y") - for i in ${args[@]}; do + for i in ${args[@]}; do log_must eval "run_zdb -e '$i' -p $TESTPOOL >/dev/null" done } @@ -69,7 +69,7 @@ function test_exported_pool log_must zpool export $TESTPOOL typeset -a args=("-A" "-b" "-C" "-c" "-d" "-D" "-F" "-G" "-h" "-i" "-L" "-M" \ "-P" "-s" "-v" "-X" "-Y" "-y") - for i in ${args[@]}; do + for i in ${args[@]}; do log_must eval "run_zdb -e '-e $i' -p $TESTPOOL >/dev/null" done log_must import_pool -p $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh index 813a4aa5cb7c..65e372a50079 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh @@ -51,13 +51,13 @@ obj=${array[0]} log_note "file $init_data has object number $obj" sync_pool $TESTPOOL -output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ +output=$(run_zdb -e "-ddddddbbbbbb" -p "$TESTPOOL/$TESTFS $obj" 2> /dev/null \ | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of $init_data has a DVA of $dva" cksum_expected=$(sed -Ene 's/^.+ cksum=([a-z0-9:]+)$/\1/p' <<< "$output") log_note "expecting cksum $cksum_expected" -output=$(zdb -R $TESTPOOL $dva:c 2> /dev/null) +output=$(run_zdb -e "-R" -p "$TESTPOOL $dva:c" 2> /dev/null) grep -q $cksum_expected <<<"$output" || log_fail "zdb -R failed to print the correct checksum" diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh index ef0849238a66..4f5c8b060dd2 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh @@ -71,7 +71,7 @@ set -A array $listing obj=${array[0]} log_note "file $init_data has object number $obj" -output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ +output=$(run_zdb -e "-ddddddbbbbbb" -p "$TESTPOOL/$TESTFS $obj" 2> /dev/null \ |grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of $init_data has a DVA of $dva" @@ -81,20 +81,20 @@ size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output") log_note "block size $size_str" IFS=: read -r vdev offset _ <<< "$dva" -output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:d) +output=$(zdb -e "-R" -p "$TESTPOOL $vdev:$offset:$size_str:d") echo $output | grep -q $pattern || log_fail "zdb -R :d failed to decompress the data properly" -output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr) +output=$(run_zdb -e "-R" -p "$TESTPOOL $vdev:$offset:$size_str:dr") echo $output | grep -q $four_k || log_fail "zdb -R :dr failed to decompress the data properly" -output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr) +output=$(run_zdb -e "-R" -p "$TESTPOOL $vdev:$offset:$size_str:dr") result=${#output} (( $result != $blksize)) && log_fail \ "zdb -R failed to decompress the data to the length (${#output} != $size_str)" # decompress using lsize IFS=/ read -r lsize psize _ <<< "$size_str" -output=$(zdb -R $TESTPOOL $vdev:$offset:$lsize:dr) +output=$(run_zdb -e "-R" -p "$TESTPOOL $vdev:$offset:$lsize:dr") result=${#output} (( $result != $blksize)) && log_fail \ "zdb -R failed to decompress the data (length ${#output} != $blksize)" diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh index 52e60719f835..b768d8c8ad76 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh @@ -65,7 +65,7 @@ sync_pool $TESTPOOL true read -r obj _ < <(ls -i $init_data) log_note "file $init_data has object number $obj" -output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ +output=$(run_zdb -e "-Zddddddbbbbbb" -p "$TESTPOOL/$TESTFS $obj" 2> /dev/null \ | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of $init_data has a DVA of $dva" @@ -96,7 +96,7 @@ log_note "ZSTD level $zstd_level" IFS=':' read -r vdev offset _ <<<"$dva" # Check the first 1024 bytes -output=$(ZDB_NO_ZLE="true" zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) +output=$(ZDB_NO_ZLE="true" run_zdb -e "-R" -p "$TESTPOOL $vdev:$offset:$size_str:dr" 2> /dev/null) (( ${#output} + 1 != $blksize )) && log_fail \ "zdb -Z failed to decompress the data to the expected length (${#output} != $lsize_bytes)" cmp $init_data - <<< "$output" || diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh index 35d5c3a9dbba..1948f50eaaef 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh @@ -72,21 +72,21 @@ set -A array $listing obj=${array[0]} log_note "file $init_data has object number $obj" -output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ +output=$(run_zdb -e "-ddddddbbbbbb" -p "$TESTPOOL/$TESTFS $obj" 2> /dev/null \ |grep -m 1 "L1 DVA" ) dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*/\1/p' <<< "$output") log_note "first L1 block $init_data has a DVA of $dva" -output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ +output=$(run_zdb -e "-ddddddbbbbbb" -p "$TESTPOOL/$TESTFS $obj" 2> /dev/null \ |grep -m 1 "L0 DVA" ) blk_out0=${output##*>} blk_out0=${blk_out0##+([[:space:]])} -output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ +output=$(run_zdb -e "-ddddddbbbbbb" -p "$TESTPOOL/$TESTFS $obj" 2> /dev/null \ |grep -m 1 "1000 L0 DVA" ) blk_out1=${output##*>} blk_out1=${blk_out1##+([[:space:]])} -output=$(export ZDB_NO_ZLE=\"true\"; zdb -R $TESTPOOL $dva:bd\ +output=$(export ZDB_NO_ZLE=\"true\"; run_zdb -e "-R" -p "$TESTPOOL $dva:bd"\ 2> /dev/null) output=${output##*>} output=${output##+([[:space:]])} @@ -94,7 +94,7 @@ if [ "$output" != "$blk_out0" ]; then log_fail "zdb -R :bd (block 0 display/decompress) failed" fi -output=$(export ZDB_NO_ZLE=\"true\"; zdb -R $TESTPOOL $dva:db80\ +output=$(export ZDB_NO_ZLE=\"true\"; run_zdb -e "-R" -p "$TESTPOOL $dva:db80"\ 2> /dev/null) output=${output##*>} output=${output##+([[:space:]])} @@ -102,7 +102,7 @@ if [ "$output" != "$blk_out1" ]; then log_fail "zdb -R :db80 (block 1 display/decompress) failed" fi -output=$(export ZDB_NO_ZLE=\"true\"; zdb -R $TESTPOOL $dva:b80d\ +output=$(export ZDB_NO_ZLE=\"true\"; run_zdb -e "-R" -p "$TESTPOOL $dva:b80d"\ 2> /dev/null) output=${output##*>} output=${output##+([[:space:]])} @@ -113,7 +113,7 @@ fi vdev=$(echo "$dva" | cut -d: -f1) offset=$(echo "$dva" | cut -d: -f2) output=$(export ZDB_NO_ZLE=\"true\";\ - zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null) + run_zdb -e "-R" -p "$TESTPOOL $vdev:$offset:$l1_read_size:id" 2> /dev/null) block_cnt=$(echo "$output" | grep -c 'L0') if [ $block_cnt -ne $write_count ]; then log_fail "zdb -R :id (indirect block display) failed" @@ -124,7 +124,7 @@ if ! use_object_store; then vdev="$vdev.0" log_note "Reading from DVA $vdev:$offset:$l1_read_size" output=$(export ZDB_NO_ZLE=\"true\";\ - zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null) + run_zdb -e "-R" -p "$TESTPOOL $vdev:$offset:$l1_read_size:id" 2> /dev/null) block_cnt=$(echo "$output" | grep -c 'L0') if [ $block_cnt -ne $write_count ]; then log_fail "zdb -R 0.0:offset:length:id (indirect block display) failed" diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh index bedf7b9d2cea..0e9e42314a39 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh @@ -47,8 +47,8 @@ set -A bad_flags a b c e g h i j k l n o p q r s t u v w x y \ typeset -i i=0 while [[ $i -lt ${#bad_flags[*]} ]]; do - log_mustnot zdb -dd $TESTPOOL 0:1:${bad_flags[i]} - log_mustnot zdb -dd $TESTPOOL 0:1:A-${bad_flags[i]} + log_mustnot run_zdb -e "-dd" -p "$TESTPOOL 0:1:${bad_flags[i]}" + log_mustnot run_zdb -e "-dd" -p "$TESTPOOL 0:1:A-${bad_flags[i]}" ((i = i + 1)) done @@ -58,14 +58,14 @@ set -A bad_ranges ":" "::" ":::" ":0" "0:" "0:1:" "0:1::" "0::f" "0a:1" \ i=0 while [[ $i -lt ${#bad_ranges[*]} ]]; do - log_mustnot zdb -dd $TESTPOOL ${bad_ranges[i]} + log_mustnot run_zdb -e "-dd" -p "$TESTPOOL ${bad_ranges[i]}" ((i = i + 1)) done # Specifying a non-existent object identifier returns an error -obj_id_highest=$(zdb -P -dd $TESTPOOL/$TESTFS 2>/dev/null | +obj_id_highest=$(run_zdb -e "-P -dd" -p "$TESTPOOL/$TESTFS" 2>/dev/null | grep -E "^ +-?([0-9]+ +){7}" | sort -n | awk 'END {print $1}') obj_id_invalid=$(( $obj_id_highest + 1 )) -log_mustnot zdb -dd $TESTPOOL/$TESTFS $obj_id_invalid +log_mustnot run_zdb -e "-dd" -p "$TESTPOOL/$TESTFS $obj_id_invalid" log_pass "Badly formed zdb object range parameters fail as expected." diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh index 6bf28618ed4b..da0fb0bc76c1 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh @@ -81,7 +81,7 @@ do obj=$(printf "0x%X" $obj) log_note "zdb -NNNNNN $TESTPOOL/$id $obj" - output=$(zdb -NNNNNN $TESTPOOL/$id $obj) + output=$(run_zdb -e "-NNNNNN" -p "$TESTPOOL/$id $obj") echo $output | grep -q "$TESTPOOL/$TESTFS" || log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" echo $output | grep -q "file1" || @@ -98,8 +98,8 @@ fi log_must zfs create $hex_ds log_must zfs create $num_ds -log_must eval "zdb -d $hex_ds | grep -q \"$hex_ds\"" -log_must eval "zdb -d $num_ds | grep -q \"$num_ds\"" +log_must eval "run_zdb -e \"-d\" -p \"$hex_ds\" | grep -q \"$hex_ds\"" +log_must eval "run_zdb -e \"-d\" -p \"$num_ds\" | grep -q \"$num_ds\"" # force numeric interpretation, expect fail log_mustnot zdb -N $hex_ds diff --git a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_big_rewind.ksh b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_big_rewind.ksh index 7e523ef90873..9e108fba85b2 100755 --- a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_big_rewind.ksh +++ b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_big_rewind.ksh @@ -53,6 +53,6 @@ log_must zpool export $NESTEDPOOL log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL log_must zpool export $NESTEDPOOL -log_must zdb -e -p $FILEDISKDIR $NESTEDPOOL +log_must run_zdb -e "-e -p" -p "$FILEDISKDIR $NESTEDPOOL" log_pass "Rewind to checkpoint on a stressed pool." diff --git a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_capacity.ksh b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_capacity.ksh index b6d34307b3f2..5143432f2e63 100755 --- a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_capacity.ksh +++ b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_capacity.ksh @@ -81,13 +81,13 @@ log_mustnot dd if=/dev/urandom of=$NESTEDFS0FILE bs=1M count=300 log_must zpool list $NESTEDPOOL log_must zpool export $NESTEDPOOL -log_must zdb -e -p $FILEDISKDIR -kc $NESTEDPOOL +log_must run_zdb -e "-e -p" -p "$FILEDISKDIR -kc $NESTEDPOOL" log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL log_must [ "$(head -c 100 $NESTEDFS0FILE)" = "$FILE0INTRO" ] log_must zpool export $NESTEDPOOL -log_must zdb -e -p $FILEDISKDIR $NESTEDPOOL +log_must run_zdb -e "-e -p" -p "$FILEDISKDIR $NESTEDPOOL" log_pass "Do not reuse checkpointed space at low capacity." diff --git a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_discard_busy.ksh b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_discard_busy.ksh index f970935f5bd0..a8ad9a29a18b 100755 --- a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_discard_busy.ksh +++ b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_discard_busy.ksh @@ -80,7 +80,7 @@ log_must zpool export $NESTEDPOOL # # Verify on-disk state while pool is exported # -log_must zdb -e -p $FILEDISKDIR $NESTEDPOOL +log_must run_zdb -e "-e -p" -p "$FILEDISKDIR $NESTEDPOOL" # # Attempt to rewind on a pool that is discarding @@ -105,7 +105,7 @@ set_tunable64 SPA_DISCARD_MEMORY_LIMIT 16777216 nested_wait_discard_finish log_must zpool export $NESTEDPOOL -log_must zdb -e -p $FILEDISKDIR $NESTEDPOOL +log_must run_zdb "-e -p" -p "$FILEDISKDIR $NESTEDPOOL" log_pass "Can export/import but not rewind/checkpoint/discard or " \ "change pool's config while discarding." diff --git a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh index 7cfe7baedc40..236f4e702655 100755 --- a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh +++ b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh @@ -58,10 +58,10 @@ log_must zpool checkpoint $TESTPOOL test_change_state_after_checkpoint -log_must eval "zdb $TESTPOOL | grep -q \"Checkpointed uberblock found\"" -log_mustnot eval "zdb -k $TESTPOOL | grep -q \"Checkpointed uberblock found\"" -log_mustnot eval "zdb $TESTPOOL | grep \"Dataset $FS1\"" -log_must eval "zdb -k $TESTPOOL | grep \"Dataset $CHECKPOINTED_FS1\"" +log_must eval "run_zdb -p $TESTPOOL | grep -q \"Checkpointed uberblock found\"" +log_mustnot eval "run_zdb -e \"-k\" -p $TESTPOOL | grep -q \"Checkpointed uberblock found\"" +log_mustnot eval "run_zdb -p $TESTPOOL | grep \"Dataset $FS1\"" +log_must eval "run_zdb -e \"-k\" -p $TESTPOOL | grep \"Dataset $CHECKPOINTED_FS1\"" log_must zpool export $TESTPOOL @@ -74,7 +74,7 @@ log_must import_pool -p $TESTPOOL log_must zpool checkpoint -d $TESTPOOL -log_mustnot eval "zdb $TESTPOOL | grep \"Checkpointed uberblock found\"" -log_mustnot eval "zdb -k $TESTPOOL" +log_mustnot eval "run_zdb -p $TESTPOOL | grep \"Checkpointed uberblock found\"" +log_mustnot eval "run_zdb -e \"-k\" -p $TESTPOOL" log_pass "zdb can analyze checkpointed pools." diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/cleanup.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/cleanup.ksh index 4761b189d0d6..02ea401015d9 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/cleanup.ksh @@ -39,7 +39,11 @@ function destroy_all_partitions done } -invalidate_zcache +# +# Remove all devices from the zoa and destroy the +# partitions +# +zcache_remove_devices $CACHE_DEVICES destroy_all_partitions log_pass diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/setup.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/setup.ksh index 1223b9f55076..9832436957a0 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/setup.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/setup.ksh @@ -60,7 +60,7 @@ for device in $AVAILABLE_DEVICES; do done -log_must configure_zettacache $CACHE_DEVICES +log_must zcache_add_devices $CACHE_DEVICES verify_zcache_devices_were_added $CACHE_DEVICES log_note "Available devices [$AVAILABLE_DEVICES]" diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_import_pool_slog_missing_neg.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_import_pool_slog_missing_neg.ksh index 6b567170a521..dc73d96fdd75 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_import_pool_slog_missing_neg.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_import_pool_slog_missing_neg.ksh @@ -60,7 +60,7 @@ fi function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL - invalidate_zcache + zcache_add_devices $CACHE_DEVICES } log_assert "Verify that the shared device(s) are partitioned into two parts." \ @@ -84,8 +84,8 @@ verify_slog_devices_are_online $TESTPOOL $SLOG_DEVICES log_must zpool export $TESTPOOL -invalidate_zcache - +# Clear the labels so that the partition can be destroyed +zcache_remove_devices $CACHE_DEVICES for dev in ${AVAILABLE_DEVICES}; do # Partition 1 is the slog part destroy_partition $dev 1 diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_multiple_pools_pos.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_multiple_pools_pos.ksh index 463a6bb8a0df..554674835b9e 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_multiple_pools_pos.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_multiple_pools_pos.ksh @@ -59,7 +59,6 @@ function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1 - invalidate_zcache } log_assert "Verify that the shared device(s) are partitioned into two parts." \ diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_slog_same_as_cache_neg.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_slog_same_as_cache_neg.ksh index 5fe1e6d26fb6..27290188db9c 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_slog_same_as_cache_neg.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_slog_same_as_cache_neg.ksh @@ -56,7 +56,6 @@ fi function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL - invalidate_zcache } log_assert "Verify that the shared device(s) are partitioned into two parts." \ diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_without_cache_inuse_pos.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_without_cache_inuse_pos.ksh index 0edeef43efb8..881582b04bd6 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_without_cache_inuse_pos.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_without_cache_inuse_pos.ksh @@ -55,7 +55,8 @@ fi function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL - invalidate_zcache + # Add the cache devices back + zcache_add_devices $CACHE_DEVICES } log_assert "Verify that the shared device(s) are partitioned into two parts." \ @@ -68,7 +69,7 @@ log_onexit cleanup # # Reset the zcache configuration for this test # -invalidate_zcache +zcache_remove_devices $CACHE_DEVICES # Create the pool log_must create_pool -p $TESTPOOL -l "log $SLOG_DEVICES" diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zoa_invalid_cache_device_neg.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zoa_invalid_cache_device_neg.ksh index d0267d37ca08..392dccf454a0 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zoa_invalid_cache_device_neg.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zoa_invalid_cache_device_neg.ksh @@ -54,7 +54,8 @@ fi function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL - invalidate_zcache + # Reset back the cache devices + zcache_add_devices $CACHE_DEVICES } log_onexit cleanup @@ -69,8 +70,9 @@ for device in $AVAILABLE_DEVICES; do done log_note "Configuring zfs-object-agent with invalid devices [$invalid_devices]" -invalidate_zcache && configure_zettacache $invalid_devices +zcache_remove_devices $CACHE_DEVICES +zcache_add_devices $invalid_devices -log_must eval "sudo systemctl status zfs-object-agent | grep -q 'Waiting for'" +log_must awk '/[ERROR].*sending failure: opening disk/' $(get_zoa_debug_log) log_pass "zfs object failed to start with invalid zettacache devices" diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_add_pos.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_add_pos.ksh index 8cf746384f32..f32226d99ab5 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_add_pos.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_add_pos.ksh @@ -58,7 +58,6 @@ fi function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL - invalidate_zcache } log_assert "Verify that the shared device(s) are partitioned into two parts." \ diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_create_pos.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_create_pos.ksh index e6815dc2907b..a1adca500977 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_create_pos.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_create_pos.ksh @@ -58,7 +58,6 @@ fi function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL - invalidate_zcache } log_assert "Verify that the shared device(s) are partitioned into two parts." \ diff --git a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_import_pos.ksh b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_import_pos.ksh index 88cac43af4a6..27eb478e4a97 100755 --- a/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_import_pos.ksh +++ b/tests/zfs-tests/tests/functional/zcache_slog_sharing/zcache_slog_sharing_zpool_import_pos.ksh @@ -60,7 +60,6 @@ fi function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL - invalidate_zcache } log_assert "Verify that the shared device(s) are partitioned into two parts." \ From 8792dd24cd9599cf506d45bcaed3af78c8cd888d Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 25 Jul 2022 09:52:42 -0700 Subject: [PATCH 6/7] ZTS: Fix occasional inherit_001_pos.ksh failure The mountpoint may still be busy when the `zfs unmount -a` command is run causing an unexpected failure. Retry the unmount a couple of times since it should not remain busy for long. 19:10:50.29 NOTE: Reading state from .../inheritance/state021.cfg 19:10:50.32 cannot unmount '/TESTPOOL': pool or dataset is busy 19:10:50.32 ERROR: zfs unmount -a exited 1 Reviewed-by: George Melikov Signed-off-by: Brian Behlendorf Closes #13686 --- .../zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh b/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh index 1e11f65d9cac..e525c51344ad 100755 --- a/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh @@ -332,7 +332,7 @@ function scan_state { #state-file log_note "No operation specified" else export __ZFS_POOL_RESTRICT="TESTPOOL" - log_must zfs unmount -a + log_must_busy zfs unmount -a unset __ZFS_POOL_RESTRICT for p in ${prop[i]} ${prop[((i+1))]}; do From 6bbb5de0d0b8b7bcfdc6dc2f44ecd010acec6e80 Mon Sep 17 00:00:00 2001 From: Manoj Joseph Date: Tue, 26 Jul 2022 12:37:31 +0530 Subject: [PATCH 7/7] DLPX-82068 zfs_object_agent test-connectivity should not expect test folder to be empty (#532) --- cmd/zfs_object_agent/zettaobject/src/test_connectivity.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zfs_object_agent/zettaobject/src/test_connectivity.rs b/cmd/zfs_object_agent/zettaobject/src/test_connectivity.rs index 026eca7d3501..ced2f0665758 100644 --- a/cmd/zfs_object_agent/zettaobject/src/test_connectivity.rs +++ b/cmd/zfs_object_agent/zettaobject/src/test_connectivity.rs @@ -99,7 +99,7 @@ async fn do_test_connectivity(object_access: &ObjectAccess) -> Result<(), String } }; - if objects != vec![file.clone()] { + if !objects.contains(&file) { return Err(format!( "object listing mismatch, expected {}, got {:?}", file, objects