diff options
author | Martin Matuska <mm@FreeBSD.org> | 2021-06-26 00:21:11 +0000 |
---|---|---|
committer | Martin Matuska <mm@FreeBSD.org> | 2021-06-26 00:21:11 +0000 |
commit | 33b8c039a960bcff3471baf5929558c4d1500727 (patch) | |
tree | 9627538080dac1f018cb190aa9a245cabce277ed /sys/contrib | |
parent | ec8004dd419d8c8acfc9025dd050f141c949d53a (diff) | |
parent | 5e2c8338bf17d31b44eb1dbbb3c9b6a0f64e96ee (diff) | |
download | src-33b8c039a960bcff3471baf5929558c4d1500727.tar.gz src-33b8c039a960bcff3471baf5929558c4d1500727.zip |
zfs: merge openzfs/zfs@5e2c8338b (master) into main
Notable upstream pull request merges:
#12183 Optimize small random numbers generation
#12227 Revert Consolidate arc_buf allocation checks
#12266 Fix flag copying in resume case
#12273 zfs_metaslab_mem_limit should be 25 instead of 75
#12276 Update cache file when setting compatibility property
#12280 Help compiller optimize out abd_verify()
#12282 FreeBSD: fix compilation of FreeBSD world after 29274c9f6
Obtained from: OpenZFS
OpenZFS commit: 5e2c8338bf17d31b44eb1dbbb3c9b6a0f64e96ee
Diffstat (limited to 'sys/contrib')
61 files changed, 582 insertions, 300 deletions
diff --git a/sys/contrib/openzfs/.github/ISSUE_TEMPLATE/config.yml b/sys/contrib/openzfs/.github/ISSUE_TEMPLATE/config.yml index 952414f66ace..ecaaa182103c 100644 --- a/sys/contrib/openzfs/.github/ISSUE_TEMPLATE/config.yml +++ b/sys/contrib/openzfs/.github/ISSUE_TEMPLATE/config.yml @@ -10,5 +10,5 @@ contact_links: url: https://lists.freebsd.org/mailman/listinfo/freebsd-fs about: Get community support for OpenZFS on FreeBSD - name: OpenZFS on IRC - url: https://kiwiirc.com/nextclient/irc.libera.chat/openzfs + url: https://web.libera.chat/#openzfs about: Use IRC to get community support for OpenZFS diff --git a/sys/contrib/openzfs/META b/sys/contrib/openzfs/META index b97858eedd96..2ea3a7300f23 100644 --- a/sys/contrib/openzfs/META +++ b/sys/contrib/openzfs/META @@ -6,5 +6,5 @@ Release: 1 Release-Tags: relext License: CDDL Author: OpenZFS -Linux-Maximum: 5.11 +Linux-Maximum: 5.12 Linux-Minimum: 3.10 diff --git a/sys/contrib/openzfs/cmd/ztest/ztest.c b/sys/contrib/openzfs/cmd/ztest/ztest.c index 73694b0b352b..a580396ebd8a 100644 --- a/sys/contrib/openzfs/cmd/ztest/ztest.c +++ b/sys/contrib/openzfs/cmd/ztest/ztest.c @@ -6669,7 +6669,7 @@ ztest_initialize(ztest_ds_t *zd, uint64_t id) char *path = strdup(rand_vd->vdev_path); boolean_t active = rand_vd->vdev_initialize_thread != NULL; - zfs_dbgmsg("vd %px, guid %llu", rand_vd, guid); + zfs_dbgmsg("vd %px, guid %llu", rand_vd, (u_longlong_t)guid); spa_config_exit(spa, SCL_VDEV, FTAG); uint64_t cmd = ztest_random(POOL_INITIALIZE_FUNCS); @@ -6741,7 +6741,7 @@ ztest_trim(ztest_ds_t *zd, uint64_t id) char *path = strdup(rand_vd->vdev_path); boolean_t active = rand_vd->vdev_trim_thread != NULL; - zfs_dbgmsg("vd %p, guid %llu", rand_vd, guid); + zfs_dbgmsg("vd %p, guid %llu", rand_vd, (u_longlong_t)guid); spa_config_exit(spa, SCL_VDEV, FTAG); uint64_t cmd = ztest_random(POOL_TRIM_FUNCS); diff --git a/sys/contrib/openzfs/contrib/pam_zfs_key/pam_zfs_key.c b/sys/contrib/openzfs/contrib/pam_zfs_key/pam_zfs_key.c index 4cafc37b9b47..0856c7534f0d 100644 --- a/sys/contrib/openzfs/contrib/pam_zfs_key/pam_zfs_key.c +++ b/sys/contrib/openzfs/contrib/pam_zfs_key/pam_zfs_key.c @@ -82,7 +82,11 @@ alloc_pw_size(size_t len) return (NULL); } pw->len = len; - pw->value = malloc(len); + /* + * The use of malloc() triggers a spurious gcc 11 -Wmaybe-uninitialized + * warning in the mlock() function call below, so use calloc(). + */ + pw->value = calloc(len, 1); if (!pw->value) { free(pw); return (NULL); @@ -99,7 +103,11 @@ alloc_pw_string(const char *source) return (NULL); } pw->len = strlen(source) + 1; - pw->value = malloc(pw->len); + /* + * The use of malloc() triggers a spurious gcc 11 -Wmaybe-uninitialized + * warning in the mlock() function call below, so use calloc(). + */ + pw->value = calloc(pw->len, 1); if (!pw->value) { free(pw); return (NULL); diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/random.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/random.h index b3c9115f5305..7583166e727b 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/random.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/random.h @@ -30,6 +30,9 @@ #define _OPENSOLARIS_SYS_RANDOM_H_ #include_next <sys/random.h> +#if __FreeBSD_version >= 1300108 +#include <sys/prng.h> +#endif static inline int random_get_bytes(uint8_t *p, size_t s) @@ -45,4 +48,23 @@ random_get_pseudo_bytes(uint8_t *p, size_t s) return (0); } +static inline uint32_t +random_in_range(uint32_t range) +{ +#if defined(_KERNEL) && __FreeBSD_version >= 1300108 + return (prng32_bounded(range)); +#else + uint32_t r; + + ASSERT(range != 0); + + if (range == 1) + return (0); + + (void) random_get_pseudo_bytes((uint8_t *)&r, sizeof (r)); + + return (r % range); +#endif +} + #endif /* !_OPENSOLARIS_SYS_RANDOM_H_ */ diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/random.h b/sys/contrib/openzfs/include/os/linux/spl/sys/random.h index 1b8cb60d094f..52e97e1ce068 100644 --- a/sys/contrib/openzfs/include/os/linux/spl/sys/random.h +++ b/sys/contrib/openzfs/include/os/linux/spl/sys/random.h @@ -36,4 +36,19 @@ random_get_bytes(uint8_t *ptr, size_t len) extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len); +static __inline__ uint32_t +random_in_range(uint32_t range) +{ + uint32_t r; + + ASSERT(range != 0); + + if (range == 1) + return (0); + + (void) random_get_pseudo_bytes((uint8_t *)&r, sizeof (r)); + + return (r % range); +} + #endif /* _SPL_RANDOM_H */ diff --git a/sys/contrib/openzfs/include/sys/crypto/api.h b/sys/contrib/openzfs/include/sys/crypto/api.h index 7c3c465513de..8aecfeaff0f4 100644 --- a/sys/contrib/openzfs/include/sys/crypto/api.h +++ b/sys/contrib/openzfs/include/sys/crypto/api.h @@ -58,7 +58,7 @@ typedef struct { */ #define CRYPTO_MECH_INVALID ((uint64_t)-1) -extern crypto_mech_type_t crypto_mech2id(crypto_mech_name_t name); +extern crypto_mech_type_t crypto_mech2id(char *name); /* * Create and destroy context templates. diff --git a/sys/contrib/openzfs/include/sys/dnode.h b/sys/contrib/openzfs/include/sys/dnode.h index 3208b60f0e7b..de6492bb7618 100644 --- a/sys/contrib/openzfs/include/sys/dnode.h +++ b/sys/contrib/openzfs/include/sys/dnode.h @@ -171,7 +171,7 @@ enum dnode_dirtycontext { * example, reading 32 dnodes from a 16k dnode block and all of the spill * blocks could issue 33 separate reads. Now suppose those dnodes have size * 1024 and therefore don't need spill blocks. Then the worst case number - * of blocks read is reduced to from 33 to two--one per dnode block. + * of blocks read is reduced from 33 to two--one per dnode block. * * ZFS-on-Linux systems that make heavy use of extended attributes benefit * from this feature. In particular, ZFS-on-Linux supports the xattr=sa @@ -232,8 +232,8 @@ typedef struct dnode_phys { * Both dn_pad2 and dn_pad3 are protected by the block's MAC. This * allows us to protect any fields that might be added here in the * future. In either case, developers will want to check - * zio_crypt_init_uios_dnode() to ensure the new field is being - * protected properly. + * zio_crypt_init_uios_dnode() and zio_crypt_do_dnode_hmac_updates() + * to ensure the new field is being protected and updated properly. */ uint64_t dn_pad3[4]; diff --git a/sys/contrib/openzfs/include/sys/spa.h b/sys/contrib/openzfs/include/sys/spa.h index d37c6c923d8c..08eba250d3a3 100644 --- a/sys/contrib/openzfs/include/sys/spa.h +++ b/sys/contrib/openzfs/include/sys/spa.h @@ -1065,7 +1065,6 @@ extern spa_t *spa_by_guid(uint64_t pool_guid, uint64_t device_guid); extern boolean_t spa_guid_exists(uint64_t pool_guid, uint64_t device_guid); extern char *spa_strdup(const char *); extern void spa_strfree(char *); -extern uint64_t spa_get_random(uint64_t range); extern uint64_t spa_generate_guid(spa_t *spa); extern void snprintf_blkptr(char *buf, size_t buflen, const blkptr_t *bp); extern void spa_freeze(spa_t *spa); diff --git a/sys/contrib/openzfs/include/sys/zfs_context.h b/sys/contrib/openzfs/include/sys/zfs_context.h index aa4338ed2859..4d67e652ab62 100644 --- a/sys/contrib/openzfs/include/sys/zfs_context.h +++ b/sys/contrib/openzfs/include/sys/zfs_context.h @@ -638,6 +638,21 @@ extern int lowbit64(uint64_t i); extern int random_get_bytes(uint8_t *ptr, size_t len); extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len); +static __inline__ uint32_t +random_in_range(uint32_t range) +{ + uint32_t r; + + ASSERT(range != 0); + + if (range == 1) + return (0); + + (void) random_get_pseudo_bytes((uint8_t *)&r, sizeof (r)); + + return (r % range); +} + extern void kernel_init(int mode); extern void kernel_fini(void); extern void random_init(void); diff --git a/sys/contrib/openzfs/include/sys/zfs_debug.h b/sys/contrib/openzfs/include/sys/zfs_debug.h index 8b9629fb5e25..7b103510dd07 100644 --- a/sys/contrib/openzfs/include/sys/zfs_debug.h +++ b/sys/contrib/openzfs/include/sys/zfs_debug.h @@ -61,7 +61,7 @@ extern int zfs_dbgmsg_enable; extern void __set_error(const char *file, const char *func, int line, int err); extern void __zfs_dbgmsg(char *buf); extern void __dprintf(boolean_t dprint, const char *file, const char *func, - int line, const char *fmt, ...); + int line, const char *fmt, ...) __attribute__((format(printf, 5, 6))); /* * Some general principles for using zfs_dbgmsg(): diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c b/sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c index 136255786cc1..5c57028c4013 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c @@ -1743,6 +1743,10 @@ zfs_send_resume_impl(libzfs_handle_t *hdl, sendflags_t *flags, int outfd, tmpflags.compress = B_TRUE; if (lzc_flags & LZC_SEND_FLAG_EMBED_DATA) tmpflags.embed_data = B_TRUE; + if (lzc_flags & LZC_SEND_FLAG_RAW) + tmpflags.raw = B_TRUE; + if (lzc_flags & LZC_SEND_FLAG_SAVED) + tmpflags.saved = B_TRUE; error = estimate_size(zhp, fromname, outfd, &tmpflags, resumeobj, resumeoff, bytes, redact_book, errbuf); } diff --git a/sys/contrib/openzfs/lib/libzpool/kernel.c b/sys/contrib/openzfs/lib/libzpool/kernel.c index 836eb176e13d..b6d836f414ee 100644 --- a/sys/contrib/openzfs/lib/libzpool/kernel.c +++ b/sys/contrib/openzfs/lib/libzpool/kernel.c @@ -788,7 +788,7 @@ kernel_init(int mode) physmem = sysconf(_SC_PHYS_PAGES); - dprintf("physmem = %llu pages (%.2f GB)\n", physmem, + dprintf("physmem = %llu pages (%.2f GB)\n", (u_longlong_t)physmem, (double)physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30)); (void) snprintf(hw_serial, sizeof (hw_serial), "%ld", diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_debug.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_debug.c index 7239db80851c..dad342b06fc1 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_debug.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_debug.c @@ -181,7 +181,7 @@ __set_error(const char *file, const char *func, int line, int err) * $ echo 512 >/sys/module/zfs/parameters/zfs_flags */ if (zfs_flags & ZFS_DEBUG_SET_ERROR) - __dprintf(B_FALSE, file, func, line, "error %lu", err); + __dprintf(B_FALSE, file, func, line, "error %lu", (ulong_t)err); } #ifdef _KERNEL diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c index 4e22206de329..42e11eeb183d 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c @@ -1060,7 +1060,7 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting) &zfsvfs->z_kstat, zs.zs_num_entries); dprintf_ds(zfsvfs->z_os->os_dsl_dataset, "num_entries in unlinked set: %llu", - zs.zs_num_entries); + (u_longlong_t)zs.zs_num_entries); } zfs_unlinked_drain(zfsvfs); @@ -1874,7 +1874,9 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) gen_mask = -1ULL >> (64 - 8 * i); - dprintf("getting %llu [%u mask %llx]\n", object, fid_gen, gen_mask); + dprintf("getting %llu [%llu mask %llx]\n", (u_longlong_t)object, + (u_longlong_t)fid_gen, + (u_longlong_t)gen_mask); if ((err = zfs_zget(zfsvfs, object, &zp))) { ZFS_EXIT(zfsvfs); return (err); @@ -1885,7 +1887,8 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) if (zp_gen == 0) zp_gen = 1; if (zp->z_unlinked || zp_gen != fid_gen) { - dprintf("znode gen (%u) != fid gen (%u)\n", zp_gen, fid_gen); + dprintf("znode gen (%llu) != fid gen (%llu)\n", + (u_longlong_t)zp_gen, (u_longlong_t)fid_gen); vrele(ZTOV(zp)); ZFS_EXIT(zfsvfs); return (SET_ERROR(EINVAL)); diff --git a/sys/contrib/openzfs/module/os/linux/zfs/arc_os.c b/sys/contrib/openzfs/module/os/linux/zfs/arc_os.c index b03ad8318d1d..415cfc281ae8 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/arc_os.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/arc_os.c @@ -437,7 +437,7 @@ arc_available_memory(void) int64_t lowest = INT64_MAX; /* Every 100 calls, free a small amount */ - if (spa_get_random(100) == 0) + if (random_in_range(100) == 0) lowest = -1024; return (lowest); @@ -458,7 +458,7 @@ arc_all_memory(void) uint64_t arc_free_memory(void) { - return (spa_get_random(arc_all_memory() * 20 / 100)); + return (random_in_range(arc_all_memory() * 20 / 100)); } void diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_debug.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_debug.c index 8d7f04097da8..98c9923d5927 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zfs_debug.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_debug.c @@ -127,7 +127,8 @@ __set_error(const char *file, const char *func, int line, int err) * $ echo 512 >/sys/module/zfs/parameters/zfs_flags */ if (zfs_flags & ZFS_DEBUG_SET_ERROR) - __dprintf(B_FALSE, file, func, line, "error %lu", err); + __dprintf(B_FALSE, file, func, line, "error %lu", + (ulong_t)err); } void diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zio_crypt.c b/sys/contrib/openzfs/module/os/linux/zfs/zio_crypt.c index 94406999cb89..52e62f4d1da4 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zio_crypt.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zio_crypt.c @@ -190,7 +190,7 @@ unsigned long zfs_key_max_salt_uses = ZFS_KEY_MAX_SALT_USES_DEFAULT; typedef struct blkptr_auth_buf { uint64_t bab_prop; /* blk_prop - portable mask */ - uint8_t bab_mac[ZIO_DATA_MAC_LEN]; /* MAC from blk_cksum */
+ uint8_t bab_mac[ZIO_DATA_MAC_LEN]; /* MAC from blk_cksum */ uint64_t bab_pad; /* reserved for future use */ } blkptr_auth_buf_t; @@ -1045,17 +1045,23 @@ zio_crypt_do_dnode_hmac_updates(crypto_context_t ctx, uint64_t version, boolean_t should_bswap, dnode_phys_t *dnp) { int ret, i; - dnode_phys_t *adnp; + dnode_phys_t *adnp, tmp_dncore; + size_t dn_core_size = offsetof(dnode_phys_t, dn_blkptr); boolean_t le_bswap = (should_bswap == ZFS_HOST_BYTEORDER); crypto_data_t cd; - uint8_t tmp_dncore[offsetof(dnode_phys_t, dn_blkptr)]; cd.cd_format = CRYPTO_DATA_RAW; cd.cd_offset = 0; - /* authenticate the core dnode (masking out non-portable bits) */ - bcopy(dnp, tmp_dncore, sizeof (tmp_dncore)); - adnp = (dnode_phys_t *)tmp_dncore; + /* + * Authenticate the core dnode (masking out non-portable bits). + * We only copy the first 64 bytes we operate on to avoid the overhead + * of copying 512-64 unneeded bytes. The compiler seems to be fine + * with that. + */ + bcopy(dnp, &tmp_dncore, dn_core_size); + adnp = &tmp_dncore; + if (le_bswap) { adnp->dn_datablkszsec = BSWAP_16(adnp->dn_datablkszsec); adnp->dn_bonuslen = BSWAP_16(adnp->dn_bonuslen); @@ -1065,7 +1071,7 @@ zio_crypt_do_dnode_hmac_updates(crypto_context_t ctx, uint64_t version, adnp->dn_flags &= DNODE_CRYPT_PORTABLE_FLAGS_MASK; adnp->dn_used = 0; - cd.cd_length = sizeof (tmp_dncore); + cd.cd_length = dn_core_size; cd.cd_raw.iov_base = (char *)adnp; cd.cd_raw.iov_len = cd.cd_length; diff --git a/sys/contrib/openzfs/module/zfs/abd.c b/sys/contrib/openzfs/module/zfs/abd.c index 2d1be9752d4f..d5fafccd08af 100644 --- a/sys/contrib/openzfs/module/zfs/abd.c +++ b/sys/contrib/openzfs/module/zfs/abd.c @@ -108,15 +108,14 @@ int zfs_abd_scatter_enabled = B_TRUE; void abd_verify(abd_t *abd) { +#ifdef ZFS_DEBUG ASSERT3U(abd->abd_size, >, 0); ASSERT3U(abd->abd_size, <=, SPA_MAXBLOCKSIZE); ASSERT3U(abd->abd_flags, ==, abd->abd_flags & (ABD_FLAG_LINEAR | ABD_FLAG_OWNER | ABD_FLAG_META | ABD_FLAG_MULTI_ZONE | ABD_FLAG_MULTI_CHUNK | ABD_FLAG_LINEAR_PAGE | ABD_FLAG_GANG | ABD_FLAG_GANG_FREE | ABD_FLAG_ZEROS | ABD_FLAG_ALLOCD)); -#ifdef ZFS_DEBUG IMPLY(abd->abd_parent != NULL, !(abd->abd_flags & ABD_FLAG_OWNER)); -#endif IMPLY(abd->abd_flags & ABD_FLAG_META, abd->abd_flags & ABD_FLAG_OWNER); if (abd_is_linear(abd)) { ASSERT3P(ABD_LINEAR_BUF(abd), !=, NULL); @@ -133,6 +132,7 @@ abd_verify(abd_t *abd) } else { abd_verify_scatter(abd); } +#endif } static void diff --git a/sys/contrib/openzfs/module/zfs/arc.c b/sys/contrib/openzfs/module/zfs/arc.c index b0468159d2e6..04d275dd80f4 100644 --- a/sys/contrib/openzfs/module/zfs/arc.c +++ b/sys/contrib/openzfs/module/zfs/arc.c @@ -7179,8 +7179,11 @@ arc_tempreserve_space(spa_t *spa, uint64_t reserve, uint64_t txg) zfs_refcount_count(&arc_anon->arcs_esize[ARC_BUFC_DATA]); dprintf("failing, arc_tempreserve=%lluK anon_meta=%lluK " "anon_data=%lluK tempreserve=%lluK rarc_c=%lluK\n", - arc_tempreserve >> 10, meta_esize >> 10, - data_esize >> 10, reserve >> 10, rarc_c >> 10); + (u_longlong_t)arc_tempreserve >> 10, + (u_longlong_t)meta_esize >> 10, + (u_longlong_t)data_esize >> 10, + (u_longlong_t)reserve >> 10, + (u_longlong_t)rarc_c >> 10); #endif DMU_TX_STAT_BUMP(dmu_tx_dirty_throttle); return (SET_ERROR(ERESTART)); @@ -10250,7 +10253,7 @@ out: * log as the pool may be in the process of being removed. */ zfs_dbgmsg("L2ARC rebuild aborted, restored %llu blocks", - zfs_refcount_count(&dev->l2ad_lb_count)); + (u_longlong_t)zfs_refcount_count(&dev->l2ad_lb_count)); } else if (err != 0) { spa_history_log_internal(spa, "L2ARC rebuild", NULL, "aborted, restored %llu blocks", @@ -10293,7 +10296,8 @@ l2arc_dev_hdr_read(l2arc_dev_t *dev) if (err != 0) { ARCSTAT_BUMP(arcstat_l2_rebuild_abort_dh_errors); zfs_dbgmsg("L2ARC IO error (%d) while reading device header, " - "vdev guid: %llu", err, dev->l2ad_vdev->vdev_guid); + "vdev guid: %llu", err, + (u_longlong_t)dev->l2ad_vdev->vdev_guid); return (err); } @@ -10390,8 +10394,9 @@ l2arc_log_blk_read(l2arc_dev_t *dev, if ((err = zio_wait(this_io)) != 0) { ARCSTAT_BUMP(arcstat_l2_rebuild_abort_io_errors); zfs_dbgmsg("L2ARC IO error (%d) while reading log block, " - "offset: %llu, vdev guid: %llu", err, this_lbp->lbp_daddr, - dev->l2ad_vdev->vdev_guid); + "offset: %llu, vdev guid: %llu", err, + (u_longlong_t)this_lbp->lbp_daddr, + (u_longlong_t)dev->l2ad_vdev->vdev_guid); goto cleanup; } @@ -10405,8 +10410,10 @@ l2arc_log_blk_read(l2arc_dev_t *dev, ARCSTAT_BUMP(arcstat_l2_rebuild_abort_cksum_lb_errors); zfs_dbgmsg("L2ARC log block cksum failed, offset: %llu, " "vdev guid: %llu, l2ad_hand: %llu, l2ad_evict: %llu", - this_lbp->lbp_daddr, dev->l2ad_vdev->vdev_guid, - dev->l2ad_hand, dev->l2ad_evict); + (u_longlong_t)this_lbp->lbp_daddr, + (u_longlong_t)dev->l2ad_vdev->vdev_guid, + (u_longlong_t)dev->l2ad_hand, + (u_longlong_t)dev->l2ad_evict); err = SET_ERROR(ECKSUM); goto cleanup; } @@ -10660,7 +10667,8 @@ l2arc_dev_hdr_update(l2arc_dev_t *dev) if (err != 0) { zfs_dbgmsg("L2ARC IO error (%d) while writing device header, " - "vdev guid: %llu", err, dev->l2ad_vdev->vdev_guid); + "vdev guid: %llu", err, + (u_longlong_t)dev->l2ad_vdev->vdev_guid); } } diff --git a/sys/contrib/openzfs/module/zfs/dbuf.c b/sys/contrib/openzfs/module/zfs/dbuf.c index 5b072f02613b..f9bcd9313f0a 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf.c +++ b/sys/contrib/openzfs/module/zfs/dbuf.c @@ -1153,42 +1153,6 @@ dbuf_set_data(dmu_buf_impl_t *db, arc_buf_t *buf) } static arc_buf_t * -dbuf_alloc_arcbuf_from_arcbuf(dmu_buf_impl_t *db, arc_buf_t *data) -{ - objset_t *os = db->db_objset; - spa_t *spa = os->os_spa; - arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); - enum zio_compress compress_type; - uint8_t complevel; - int psize, lsize; - - psize = arc_buf_size(data); - lsize = arc_buf_lsize(data); - compress_type = arc_get_compression(data); - complevel = arc_get_complevel(data); - - if (arc_is_encrypted(data)) { - boolean_t byteorder; - uint8_t salt[ZIO_DATA_SALT_LEN]; - uint8_t iv[ZIO_DATA_IV_LEN]; - uint8_t mac[ZIO_DATA_MAC_LEN]; - dnode_t *dn = DB_DNODE(db); - - arc_get_raw_params(data, &byteorder, salt, iv, mac); - data = arc_alloc_raw_buf(spa, db, dmu_objset_id(os), - byteorder, salt, iv, mac, dn->dn_type, psize, lsize, - compress_type, complevel); - } else if (compress_type != ZIO_COMPRESS_OFF) { - ASSERT3U(type, ==, ARC_BUFC_DATA); - data = arc_alloc_compressed_buf(spa, db, - psize, lsize, compress_type, complevel); - } else { - data = arc_alloc_buf(spa, db, type, psize); - } - return (data); -} - -static arc_buf_t * dbuf_alloc_arcbuf(dmu_buf_impl_t *db) { spa_t *spa = db->db_objset->os_spa; @@ -1635,9 +1599,35 @@ dbuf_fix_old_data(dmu_buf_impl_t *db, uint64_t txg) arc_space_consume(bonuslen, ARC_SPACE_BONUS); bcopy(db->db.db_data, dr->dt.dl.dr_data, bonuslen); } else if (zfs_refcount_count(&db->db_holds) > db->db_dirtycnt) { - arc_buf_t *buf = dbuf_alloc_arcbuf_from_arcbuf(db, db->db_buf); - dr->dt.dl.dr_data = buf; - bcopy(db->db.db_data, buf->b_data, arc_buf_size(buf)); + dnode_t *dn = DB_DNODE(db); + int size = arc_buf_size(db->db_buf); + arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); + spa_t *spa = db->db_objset->os_spa; + enum zio_compress compress_type = + arc_get_compression(db->db_buf); + uint8_t complevel = arc_get_complevel(db->db_buf); + + if (arc_is_encrypted(db->db_buf)) { + boolean_t byteorder; + uint8_t salt[ZIO_DATA_SALT_LEN]; + uint8_t iv[ZIO_DATA_IV_LEN]; + uint8_t mac[ZIO_DATA_MAC_LEN]; + + arc_get_raw_params(db->db_buf, &byteorder, salt, + iv, mac); + dr->dt.dl.dr_data = arc_alloc_raw_buf(spa, db, + dmu_objset_id(dn->dn_objset), byteorder, salt, iv, + mac, dn->dn_type, size, arc_buf_lsize(db->db_buf), + compress_type, complevel); + } else if (compress_type != ZIO_COMPRESS_OFF) { + ASSERT3U(type, ==, ARC_BUFC_DATA); + dr->dt.dl.dr_data = arc_alloc_compressed_buf(spa, db, + size, arc_buf_lsize(db->db_buf), compress_type, + complevel); + } else { + dr->dt.dl.dr_data = arc_alloc_buf(spa, db, type, size); + } + bcopy(db->db.db_data, dr->dt.dl.dr_data->b_data, size); } else { db->db_buf = NULL; dbuf_clear_data(db); @@ -1858,7 +1848,8 @@ dbuf_free_range(dnode_t *dn, uint64_t start_blkid, uint64_t end_blkid, if (end_blkid > dn->dn_maxblkid && !(start_blkid == DMU_SPILL_BLKID || end_blkid == DMU_SPILL_BLKID)) end_blkid = dn->dn_maxblkid; - dprintf_dnode(dn, "start=%llu end=%llu\n", start_blkid, end_blkid); + dprintf_dnode(dn, "start=%llu end=%llu\n", (u_longlong_t)start_blkid, + (u_longlong_t)end_blkid); db_search = kmem_alloc(sizeof (dmu_buf_impl_t), KM_SLEEP); db_search->db_level = 0; @@ -3438,10 +3429,30 @@ noinline static void dbuf_hold_copy(dnode_t *dn, dmu_buf_impl_t *db) { dbuf_dirty_record_t *dr = db->db_data_pending; - arc_buf_t *newdata, *data = dr->dt.dl.dr_data; + arc_buf_t *data = dr->dt.dl.dr_data; + enum zio_compress compress_type = arc_get_compression(data); + uint8_t complevel = arc_get_complevel(data); + + if (arc_is_encrypted(data)) { + boolean_t byteorder; + uint8_t salt[ZIO_DATA_SALT_LEN]; + uint8_t iv[ZIO_DATA_IV_LEN]; + uint8_t mac[ZIO_DATA_MAC_LEN]; + + arc_get_raw_params(data, &byteorder, salt, iv, mac); + dbuf_set_data(db, arc_alloc_raw_buf(dn->dn_objset->os_spa, db, + dmu_objset_id(dn->dn_objset), byteorder, salt, iv, mac, + dn->dn_type, arc_buf_size(data), arc_buf_lsize(data), + compress_type, complevel)); + } else if (compress_type != ZIO_COMPRESS_OFF) { + dbuf_set_data(db, arc_alloc_compressed_buf( + dn->dn_objset->os_spa, db, arc_buf_size(data), + arc_buf_lsize(data), compress_type, complevel)); + } else { + dbuf_set_data(db, arc_alloc_buf(dn->dn_objset->os_spa, db, + DBUF_GET_BUFC_TYPE(db), db->db.db_size)); + } - newdata = dbuf_alloc_arcbuf_from_arcbuf(db, data); - dbuf_set_data(db, newdata); rw_enter(&db->db_rwlock, RW_WRITER); bcopy(data->b_data, db->db.db_data, arc_buf_size(data)); rw_exit(&db->db_rwlock); @@ -4363,8 +4374,31 @@ dbuf_sync_leaf(dbuf_dirty_record_t *dr, dmu_tx_t *tx) * objects only modified in the syncing context (e.g. * DNONE_DNODE blocks). */ - *datap = dbuf_alloc_arcbuf_from_arcbuf(db, db->db_buf); - bcopy(db->db.db_data, (*datap)->b_data, arc_buf_size(*datap)); + int psize = arc_buf_size(*datap); + int lsize = arc_buf_lsize(*datap); + arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); + enum zio_compress compress_type = arc_get_compression(*datap); + uint8_t complevel = arc_get_complevel(*datap); + + if (arc_is_encrypted(*datap)) { + boolean_t byteorder; + uint8_t salt[ZIO_DATA_SALT_LEN]; + uint8_t iv[ZIO_DATA_IV_LEN]; + uint8_t mac[ZIO_DATA_MAC_LEN]; + + arc_get_raw_params(*datap, &byteorder, salt, iv, mac); + *datap = arc_alloc_raw_buf(os->os_spa, db, + dmu_objset_id(os), byteorder, salt, iv, mac, + dn->dn_type, psize, lsize, compress_type, + complevel); + } else if (compress_type != ZIO_COMPRESS_OFF) { + ASSERT3U(type, ==, ARC_BUFC_DATA); + *datap = arc_alloc_compressed_buf(os->os_spa, db, + psize, lsize, compress_type, complevel); + } else { + *datap = arc_alloc_buf(os->os_spa, db, type, psize); + } + bcopy(db->db.db_data, (*datap)->b_data, psize); } db->db_data_pending = dr; diff --git a/sys/contrib/openzfs/module/zfs/dmu_objset.c b/sys/contrib/openzfs/module/zfs/dmu_objset.c index 8c244dc4c317..22deee7f3dc9 100644 --- a/sys/contrib/openzfs/module/zfs/dmu_objset.c +++ b/sys/contrib/openzfs/module/zfs/dmu_objset.c @@ -1616,7 +1616,7 @@ dmu_objset_sync(objset_t *os, zio_t *pio, dmu_tx_t *tx) blkptr_t *blkptr_copy = kmem_alloc(sizeof (*os->os_rootbp), KM_SLEEP); *blkptr_copy = *os->os_rootbp; - dprintf_ds(os->os_dsl_dataset, "txg=%llu\n", tx->tx_txg); + dprintf_ds(os->os_dsl_dataset, "txg=%llu\n", (u_longlong_t)tx->tx_txg); ASSERT(dmu_tx_is_syncing(tx)); /* XXX the write_done callback should really give us the tx... */ diff --git a/sys/contrib/openzfs/module/zfs/dmu_recv.c b/sys/contrib/openzfs/module/zfs/dmu_recv.c index a713e1329027..0ec46bdb4f47 100644 --- a/sys/contrib/openzfs/module/zfs/dmu_recv.c +++ b/sys/contrib/openzfs/module/zfs/dmu_recv.c @@ -2588,8 +2588,8 @@ dprintf_drr(struct receive_record_arg *rrd, int err) dprintf("drr_type = OBJECT obj = %llu type = %u " "bonustype = %u blksz = %u bonuslen = %u cksumtype = %u " "compress = %u dn_slots = %u err = %d\n", - drro->drr_object, drro->drr_type, drro->drr_bonustype, - drro->drr_blksz, drro->drr_bonuslen, + (u_longlong_t)drro->drr_object, drro->drr_type, + drro->drr_bonustype, drro->drr_blksz, drro->drr_bonuslen, drro->drr_checksumtype, drro->drr_compress, drro->drr_dn_slots, err); break; @@ -2600,7 +2600,8 @@ dprintf_drr(struct receive_record_arg *rrd, int err) &rrd->header.drr_u.drr_freeobjects; dprintf("drr_type = FREEOBJECTS firstobj = %llu " "numobjs = %llu err = %d\n", - drrfo->drr_firstobj, drrfo->drr_numobjs, err); + (u_longlong_t)drrfo->drr_firstobj, + (u_longlong_t)drrfo->drr_numobjs, err); break; } case DRR_WRITE: @@ -2609,10 +2610,12 @@ dprintf_drr(struct receive_record_arg *rrd, int err) dprintf("drr_type = WRITE obj = %llu type = %u offset = %llu " "lsize = %llu cksumtype = %u flags = %u " "compress = %u psize = %llu err = %d\n", - drrw->drr_object, drrw->drr_type, drrw->drr_offset, - drrw->drr_logical_size, drrw->drr_checksumtype, - drrw->drr_flags, drrw->drr_compressiontype, - drrw->drr_compressed_size, err); + (u_longlong_t)drrw->drr_object, drrw->drr_type, + (u_longlong_t)drrw->drr_offset, + (u_longlong_t)drrw->drr_logical_size, + drrw->drr_checksumtype, drrw->drr_flags, + drrw->drr_compressiontype, + (u_longlong_t)drrw->drr_compressed_size, err); break; } case DRR_WRITE_BYREF: @@ -2623,11 +2626,14 @@ dprintf_drr(struct receive_record_arg *rrd, int err) "length = %llu toguid = %llx refguid = %llx " "refobject = %llu refoffset = %llu cksumtype = %u " "flags = %u err = %d\n", - drrwbr->drr_object, drrwbr->drr_offset, - drrwbr->drr_length, drrwbr->drr_toguid, - drrwbr->drr_refguid, drrwbr->drr_refobject, - drrwbr->drr_refoffset, drrwbr->drr_checksumtype, - drrwbr->drr_flags, err); + (u_longlong_t)drrwbr->drr_object, + (u_longlong_t)drrwbr->drr_offset, + (u_longlong_t)drrwbr->drr_length, + (u_longlong_t)drrwbr->drr_toguid, + (u_longlong_t)drrwbr->drr_refguid, + (u_longlong_t)drrwbr->drr_refobject, + (u_longlong_t)drrwbr->drr_refoffset, + drrwbr->drr_checksumtype, drrwbr->drr_flags, err); break; } case DRR_WRITE_EMBEDDED: @@ -2637,7 +2643,9 @@ dprintf_drr(struct receive_record_arg *rrd, int err) dprintf("drr_type = WRITE_EMBEDDED obj = %llu offset = %llu " "length = %llu compress = %u etype = %u lsize = %u " "psize = %u err = %d\n", - drrwe->drr_object, drrwe->drr_offset, drrwe->drr_length, + (u_longlong_t)drrwe->drr_object, + (u_longlong_t)drrwe->drr_offset, + (u_longlong_t)drrwe->drr_length, drrwe->drr_compression, drrwe->drr_etype, drrwe->drr_lsize, drrwe->drr_psize, err); break; @@ -2647,7 +2655,9 @@ dprintf_drr(struct receive_record_arg *rrd, int err) struct drr_free *drrf = &rrd->header.drr_u.drr_free; dprintf("drr_type = FREE obj = %llu offset = %llu " "length = %lld err = %d\n", - drrf->drr_object, drrf->drr_offset, drrf->drr_length, + (u_longlong_t)drrf->drr_object, + (u_longlong_t)drrf->drr_offset, + (longlong_t)drrf->drr_length, err); break; } @@ -2655,7 +2665,8 @@ dprintf_drr(struct receive_record_arg *rrd, int err) { struct drr_spill *drrs = &rrd->header.drr_u.drr_spill; dprintf("drr_type = SPILL obj = %llu length = %llu " - "err = %d\n", drrs->drr_object, drrs->drr_length, err); + "err = %d\n", (u_longlong_t)drrs->drr_object, + (u_longlong_t)drrs->drr_length, err); break; } case DRR_OBJECT_RANGE: @@ -2664,7 +2675,8 @@ dprintf_drr(struct receive_record_arg *rrd, int err) &rrd->header.drr_u.drr_object_range; dprintf("drr_type = OBJECT_RANGE firstobj = %llu " "numslots = %llu flags = %u err = %d\n", - drror->drr_firstobj, drror->drr_numslots, + (u_longlong_t)drror->drr_firstobj, + (u_longlong_t)drror->drr_numslots, drror->drr_flags, err); break; } diff --git a/sys/contrib/openzfs/module/zfs/dmu_tx.c b/sys/contrib/openzfs/module/zfs/dmu_tx.c index 73667915df0f..0beb983f992f 100644 --- a/sys/contrib/openzfs/module/zfs/dmu_tx.c +++ b/sys/contrib/openzfs/module/zfs/dmu_tx.c @@ -613,7 +613,8 @@ dmu_tx_dirty_buf(dmu_tx_t *tx, dmu_buf_impl_t *db) /* XXX txh_arg2 better not be zero... */ dprintf("found txh type %x beginblk=%llx endblk=%llx\n", - txh->txh_type, beginblk, endblk); + txh->txh_type, (u_longlong_t)beginblk, + (u_longlong_t)endblk); switch (txh->txh_type) { case THT_WRITE: diff --git a/sys/contrib/openzfs/module/zfs/dnode.c b/sys/contrib/openzfs/module/zfs/dnode.c index 8434e72aa4f8..b1813a8951d5 100644 --- a/sys/contrib/openzfs/module/zfs/dnode.c +++ b/sys/contrib/openzfs/module/zfs/dnode.c @@ -592,7 +592,8 @@ dnode_allocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs, ibs = MIN(MAX(ibs, DN_MIN_INDBLKSHIFT), DN_MAX_INDBLKSHIFT); dprintf("os=%p obj=%llu txg=%llu blocksize=%d ibs=%d dn_slots=%d\n", - dn->dn_objset, dn->dn_object, tx->tx_txg, blocksize, ibs, dn_slots); + dn->dn_objset, (u_longlong_t)dn->dn_object, + (u_longlong_t)tx->tx_txg, blocksize, ibs, dn_slots); DNODE_STAT_BUMP(dnode_allocate); ASSERT(dn->dn_type == DMU_OT_NONE); @@ -1690,7 +1691,7 @@ dnode_setdirty(dnode_t *dn, dmu_tx_t *tx) ASSERT0(dn->dn_next_bonustype[txg & TXG_MASK]); dprintf_ds(os->os_dsl_dataset, "obj=%llu txg=%llu\n", - dn->dn_object, txg); + (u_longlong_t)dn->dn_object, (u_longlong_t)txg); multilist_sublist_insert_head(mls, dn); @@ -2253,7 +2254,8 @@ done: range_tree_add(dn->dn_free_ranges[txgoff], blkid, nblks); } dprintf_dnode(dn, "blkid=%llu nblks=%llu txg=%llu\n", - blkid, nblks, tx->tx_txg); + (u_longlong_t)blkid, (u_longlong_t)nblks, + (u_longlong_t)tx->tx_txg); mutex_exit(&dn->dn_mtx); dbuf_free_range(dn, blkid, blkid + nblks - 1, tx); diff --git a/sys/contrib/openzfs/module/zfs/dnode_sync.c b/sys/contrib/openzfs/module/zfs/dnode_sync.c index 66e48a1e17d4..dd37e3af7ed5 100644 --- a/sys/contrib/openzfs/module/zfs/dnode_sync.c +++ b/sys/contrib/openzfs/module/zfs/dnode_sync.c @@ -59,7 +59,7 @@ dnode_increase_indirection(dnode_t *dn, dmu_tx_t *tx) dn->dn_phys->dn_nlevels = new_level; dprintf("os=%p obj=%llu, increase to %d\n", dn->dn_objset, - dn->dn_object, dn->dn_phys->dn_nlevels); + (u_longlong_t)dn->dn_object, dn->dn_phys->dn_nlevels); /* * Lock ordering requires that we hold the children's db_mutexes (by @@ -136,7 +136,8 @@ free_blocks(dnode_t *dn, blkptr_t *bp, int num, dmu_tx_t *tx) dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset; uint64_t bytesfreed = 0; - dprintf("ds=%p obj=%llx num=%d\n", ds, dn->dn_object, num); + dprintf("ds=%p obj=%llx num=%d\n", ds, (u_longlong_t)dn->dn_object, + num); for (int i = 0; i < num; i++, bp++) { if (BP_IS_HOLE(bp)) diff --git a/sys/contrib/openzfs/module/zfs/dsl_dataset.c b/sys/contrib/openzfs/module/zfs/dsl_dataset.c index 9b9bb42287d5..1c03216ef6d5 100644 --- a/sys/contrib/openzfs/module/zfs/dsl_dataset.c +++ b/sys/contrib/openzfs/module/zfs/dsl_dataset.c @@ -282,7 +282,7 @@ dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx, if (bp->blk_birth > dsl_dataset_phys(ds)->ds_prev_snap_txg) { int64_t delta; - dprintf_bp(bp, "freeing ds=%llu", ds->ds_object); + dprintf_bp(bp, "freeing ds=%llu", (u_longlong_t)ds->ds_object); dsl_free(tx->tx_pool, tx->tx_txg, bp); mutex_enter(&ds->ds_lock); @@ -721,7 +721,7 @@ dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, void *tag, dsl_dataset_phys(ds)->ds_fsid_guid, (long long)ds->ds_fsid_guid, spa_name(dp->dp_spa), - dsobj); + (u_longlong_t)dsobj); } } } diff --git a/sys/contrib/openzfs/module/zfs/dsl_destroy.c b/sys/contrib/openzfs/module/zfs/dsl_destroy.c index 837d78987e75..a2748197f29d 100644 --- a/sys/contrib/openzfs/module/zfs/dsl_destroy.c +++ b/sys/contrib/openzfs/module/zfs/dsl_destroy.c @@ -654,7 +654,7 @@ dsl_destroy_snapshots_nvl(nvlist_t *snaps, boolean_t defer, char *errorstr = NULL; (void) nvlist_lookup_string(result, ZCP_RET_ERROR, &errorstr); if (errorstr != NULL) { - zfs_dbgmsg(errorstr); + zfs_dbgmsg("%s", errorstr); } fnvlist_free(wrapper); fnvlist_free(result); diff --git a/sys/contrib/openzfs/module/zfs/dsl_dir.c b/sys/contrib/openzfs/module/zfs/dsl_dir.c index 90dd787023be..df2c3d8f0637 100644 --- a/sys/contrib/openzfs/module/zfs/dsl_dir.c +++ b/sys/contrib/openzfs/module/zfs/dsl_dir.c @@ -488,7 +488,7 @@ dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag, if (next[0] == '@') break; dprintf("looking up %s in obj%lld\n", - buf, dsl_dir_phys(dd)->dd_child_dir_zapobj); + buf, (longlong_t)dsl_dir_phys(dd)->dd_child_dir_zapobj); err = zap_lookup(dp->dp_meta_objset, dsl_dir_phys(dd)->dd_child_dir_zapobj, @@ -1156,8 +1156,8 @@ dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx) mutex_enter(&dd->dd_lock); ASSERT0(dd->dd_tempreserved[tx->tx_txg & TXG_MASK]); - dprintf_dd(dd, "txg=%llu towrite=%lluK\n", tx->tx_txg, - dd->dd_space_towrite[tx->tx_txg & TXG_MASK] / 1024); + dprintf_dd(dd, "txg=%llu towrite=%lluK\n", (u_longlong_t)tx->tx_txg, + (u_longlong_t)dd->dd_space_towrite[tx->tx_txg & TXG_MASK] / 1024); dd->dd_space_towrite[tx->tx_txg & TXG_MASK] = 0; mutex_exit(&dd->dd_lock); @@ -1344,8 +1344,9 @@ top_of_function: retval = ERESTART; dprintf_dd(dd, "failing: used=%lluK inflight = %lluK " "quota=%lluK tr=%lluK err=%d\n", - used_on_disk>>10, est_inflight>>10, - quota>>10, asize>>10, retval); + (u_longlong_t)used_on_disk>>10, + (u_longlong_t)est_inflight>>10, + (u_longlong_t)quota>>10, (u_longlong_t)asize>>10, retval); mutex_exit(&dd->dd_lock); DMU_TX_STAT_BUMP(dmu_tx_quota); return (SET_ERROR(retval)); diff --git a/sys/contrib/openzfs/module/zfs/metaslab.c b/sys/contrib/openzfs/module/zfs/metaslab.c index e588765b3382..92f51806ace5 100644 --- a/sys/contrib/openzfs/module/zfs/metaslab.c +++ b/sys/contrib/openzfs/module/zfs/metaslab.c @@ -293,7 +293,7 @@ unsigned long zfs_metaslab_max_size_cache_sec = 3600; /* 1 hour */ * a metaslab would take it over this percentage, the oldest selected metaslab * is automatically unloaded. */ -int zfs_metaslab_mem_limit = 75; +int zfs_metaslab_mem_limit = 25; /* * Force the per-metaslab range trees to use 64-bit integers to store @@ -2437,18 +2437,20 @@ metaslab_load_impl(metaslab_t *msp) "loading_time %lld ms, ms_max_size %llu, " "max size error %lld, " "old_weight %llx, new_weight %llx", - spa_syncing_txg(spa), spa_name(spa), - msp->ms_group->mg_vd->vdev_id, msp->ms_id, - space_map_length(msp->ms_sm), - range_tree_space(msp->ms_unflushed_allocs), - range_tree_space(msp->ms_unflushed_frees), - range_tree_space(msp->ms_freed), - range_tree_space(msp->ms_defer[0]), - range_tree_space(msp->ms_defer[1]), + (u_longlong_t)spa_syncing_txg(spa), spa_name(spa), + (u_longlong_t)msp->ms_group->mg_vd->vdev_id, + (u_longlong_t)msp->ms_id, + (u_longlong_t)space_map_length(msp->ms_sm), + (u_longlong_t)range_tree_space(msp->ms_unflushed_allocs), + (u_longlong_t)range_tree_space(msp->ms_unflushed_frees), + (u_longlong_t)range_tree_space(msp->ms_freed), + (u_longlong_t)range_tree_space(msp->ms_defer[0]), + (u_longlong_t)range_tree_space(msp->ms_defer[1]), (longlong_t)((load_start - msp->ms_unload_time) / 1000000), (longlong_t)((load_end - load_start) / 1000000), - msp->ms_max_size, msp->ms_max_size - max_size, - weight, msp->ms_weight); + (u_longlong_t)msp->ms_max_size, + (u_longlong_t)msp->ms_max_size - max_size, + (u_longlong_t)weight, (u_longlong_t)msp->ms_weight); metaslab_verify_space(msp, spa_syncing_txg(spa)); mutex_exit(&msp->ms_sync_lock); @@ -2545,14 +2547,17 @@ metaslab_unload(metaslab_t *msp) "ms_id %llu, weight %llx, " "selected txg %llu (%llu ms ago), alloc_txg %llu, " "loaded %llu ms ago, max_size %llu", - spa_syncing_txg(spa), spa_name(spa), - msp->ms_group->mg_vd->vdev_id, msp->ms_id, - msp->ms_weight, - msp->ms_selected_txg, - (msp->ms_unload_time - msp->ms_selected_time) / 1000 / 1000, - msp->ms_alloc_txg, - (msp->ms_unload_time - msp->ms_load_time) / 1000 / 1000, - msp->ms_max_size); + (u_longlong_t)spa_syncing_txg(spa), spa_name(spa), + (u_longlong_t)msp->ms_group->mg_vd->vdev_id, + (u_longlong_t)msp->ms_id, + (u_longlong_t)msp->ms_weight, + (u_longlong_t)msp->ms_selected_txg, + (u_longlong_t)(msp->ms_unload_time - + msp->ms_selected_time) / 1000 / 1000, + (u_longlong_t)msp->ms_alloc_txg, + (u_longlong_t)(msp->ms_unload_time - + msp->ms_load_time) / 1000 / 1000, + (u_longlong_t)msp->ms_max_size); } /* @@ -2914,8 +2919,9 @@ metaslab_set_fragmentation(metaslab_t *msp, boolean_t nodirty) msp->ms_condense_wanted = B_TRUE; vdev_dirty(vd, VDD_METASLAB, msp, txg + 1); zfs_dbgmsg("txg %llu, requesting force condense: " - "ms_id %llu, vdev_id %llu", txg, msp->ms_id, - vd->vdev_id); + "ms_id %llu, vdev_id %llu", (u_longlong_t)txg, + (u_longlong_t)msp->ms_id, + (u_longlong_t)vd->vdev_id); } msp->ms_fragmentation = ZFS_FRAG_INVALID; return; @@ -3635,10 +3641,11 @@ metaslab_condense(metaslab_t *msp, dmu_tx_t *tx) ASSERT(range_tree_is_empty(msp->ms_freed)); /* since it is pass 1 */ zfs_dbgmsg("condensing: txg %llu, msp[%llu] %px, vdev id %llu, " - "spa %s, smp size %llu, segments %lu, forcing condense=%s", txg, - msp->ms_id, msp, msp->ms_group->mg_vd->vdev_id, - spa->spa_name, space_map_length(msp->ms_sm), - range_tree_numsegs(msp->ms_allocatable), + "spa %s, smp size %llu, segments %llu, forcing condense=%s", + (u_longlong_t)txg, (u_longlong_t)msp->ms_id, msp, + (u_longlong_t)msp->ms_group->mg_vd->vdev_id, + spa->spa_name, (u_longlong_t)space_map_length(msp->ms_sm), + (u_longlong_t)range_tree_numsegs(msp->ms_allocatable), msp->ms_condense_wanted ? "TRUE" : "FALSE"); msp->ms_condense_wanted = B_FALSE; @@ -3883,11 +3890,13 @@ metaslab_flush(metaslab_t *msp, dmu_tx_t *tx) if (zfs_flags & ZFS_DEBUG_LOG_SPACEMAP) { zfs_dbgmsg("flushing: txg %llu, spa %s, vdev_id %llu, " "ms_id %llu, unflushed_allocs %llu, unflushed_frees %llu, " - "appended %llu bytes", dmu_tx_get_txg(tx), spa_name(spa), - msp->ms_group->mg_vd->vdev_id, msp->ms_id, - range_tree_space(msp->ms_unflushed_allocs), - range_tree_space(msp->ms_unflushed_frees), - (sm_len_after - sm_len_before)); + "appended %llu bytes", (u_longlong_t)dmu_tx_get_txg(tx), + spa_name(spa), + (u_longlong_t)msp->ms_group->mg_vd->vdev_id, + (u_longlong_t)msp->ms_id, + (u_longlong_t)range_tree_space(msp->ms_unflushed_allocs), + (u_longlong_t)range_tree_space(msp->ms_unflushed_frees), + (u_longlong_t)(sm_len_after - sm_len_before)); } ASSERT3U(spa->spa_unflushed_stats.sus_memused, >=, @@ -5070,7 +5079,7 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize, * damage can result in extremely long reconstruction times. This * will also test spilling from special to normal. */ - if (psize >= metaslab_force_ganging && (spa_get_random(100) < 3)) { + if (psize >= metaslab_force_ganging && (random_in_range(100) < 3)) { metaslab_trace_add(zal, NULL, NULL, psize, d, TRACE_FORCE_GANG, allocator); return (SET_ERROR(ENOSPC)); diff --git a/sys/contrib/openzfs/module/zfs/mmp.c b/sys/contrib/openzfs/module/zfs/mmp.c index d05c9db24c20..f67a4eb22a2d 100644 --- a/sys/contrib/openzfs/module/zfs/mmp.c +++ b/sys/contrib/openzfs/module/zfs/mmp.c @@ -485,8 +485,9 @@ mmp_write_uberblock(spa_t *spa) if (mmp->mmp_skip_error != 0) { mmp->mmp_skip_error = 0; zfs_dbgmsg("MMP write after skipping due to unavailable " - "leaves, pool '%s' gethrtime %llu leaf %#llu", - spa_name(spa), gethrtime(), vd->vdev_guid); + "leaves, pool '%s' gethrtime %llu leaf %llu", + spa_name(spa), (u_longlong_t)gethrtime(), + (u_longlong_t)vd->vdev_guid); } if (mmp->mmp_zio_root == NULL) @@ -523,9 +524,9 @@ mmp_write_uberblock(spa_t *spa) mutex_exit(&mmp->mmp_io_lock); offset = VDEV_UBERBLOCK_OFFSET(vd, VDEV_UBERBLOCK_COUNT(vd) - - MMP_BLOCKS_PER_LABEL + spa_get_random(MMP_BLOCKS_PER_LABEL)); + MMP_BLOCKS_PER_LABEL + random_in_range(MMP_BLOCKS_PER_LABEL)); - label = spa_get_random(VDEV_LABELS); + label = random_in_range(VDEV_LABELS); vdev_label_write(zio, vd, label, ub_abd, offset, VDEV_UBERBLOCK_SIZE(vd), mmp_write_done, mmp, flags | ZIO_FLAG_DONT_PROPAGATE); @@ -617,10 +618,11 @@ mmp_thread(void *arg) "mmp_interval %llu last_mmp_fail_intervals %u " "mmp_fail_intervals %u mmp_fail_ns %llu " "skip_wait %d leaves %d next_time %llu", - spa_name(spa), gethrtime(), last_mmp_interval, - mmp_interval, last_mmp_fail_intervals, - mmp_fail_intervals, mmp_fail_ns, skip_wait, leaves, - next_time); + spa_name(spa), (u_longlong_t)gethrtime(), + (u_longlong_t)last_mmp_interval, + (u_longlong_t)mmp_interval, last_mmp_fail_intervals, + mmp_fail_intervals, (u_longlong_t)mmp_fail_ns, + skip_wait, leaves, (u_longlong_t)next_time); } /* @@ -633,8 +635,9 @@ mmp_thread(void *arg) zfs_dbgmsg("MMP state change pool '%s': gethrtime %llu " "last_spa_multihost %u multihost %u " "last_spa_suspended %u suspended %u", - spa_name(spa), last_spa_multihost, multihost, - last_spa_suspended, suspended); + spa_name(spa), (u_longlong_t)gethrtime(), + last_spa_multihost, multihost, last_spa_suspended, + suspended); mutex_enter(&mmp->mmp_io_lock); mmp->mmp_last_write = gethrtime(); mmp->mmp_delay = mmp_interval; diff --git a/sys/contrib/openzfs/module/zfs/multilist.c b/sys/contrib/openzfs/module/zfs/multilist.c index eeac73bd7adf..8bbc9b376ae0 100644 --- a/sys/contrib/openzfs/module/zfs/multilist.c +++ b/sys/contrib/openzfs/module/zfs/multilist.c @@ -20,9 +20,6 @@ #include <sys/multilist.h> #include <sys/trace_zfs.h> -/* needed for spa_get_random() */ -#include <sys/spa.h> - /* * This overrides the number of sublists in each multilist_t, which defaults * to the number of CPUs in the system (see multilist_create()). @@ -275,7 +272,7 @@ multilist_get_num_sublists(multilist_t *ml) unsigned int multilist_get_random_index(multilist_t *ml) { - return (spa_get_random(ml->ml_num_sublists)); + return (random_in_range(ml->ml_num_sublists)); } /* Lock and return the sublist specified at the given index */ diff --git a/sys/contrib/openzfs/module/zfs/range_tree.c b/sys/contrib/openzfs/module/zfs/range_tree.c index 5219fd079b73..595918e5a742 100644 --- a/sys/contrib/openzfs/module/zfs/range_tree.c +++ b/sys/contrib/openzfs/module/zfs/range_tree.c @@ -116,7 +116,8 @@ range_tree_stat_verify(range_tree_t *rt) for (i = 0; i < RANGE_TREE_HISTOGRAM_SIZE; i++) { if (hist[i] != rt->rt_histogram[i]) { zfs_dbgmsg("i=%d, hist=%px, hist=%llu, rt_hist=%llu", - i, hist, hist[i], rt->rt_histogram[i]); + i, hist, (u_longlong_t)hist[i], + (u_longlong_t)rt->rt_histogram[i]); } VERIFY3U(hist[i], ==, rt->rt_histogram[i]); } diff --git a/sys/contrib/openzfs/module/zfs/sa.c b/sys/contrib/openzfs/module/zfs/sa.c index 5af0aaa7d0aa..2604a7513ecf 100644 --- a/sys/contrib/openzfs/module/zfs/sa.c +++ b/sys/contrib/openzfs/module/zfs/sa.c @@ -1292,7 +1292,7 @@ sa_build_index(sa_handle_t *hdl, sa_buf_type_t buftype) mutex_exit(&sa->sa_lock); zfs_dbgmsg("Buffer Header: %x != SA_MAGIC:%x " "object=%#llx\n", sa_hdr_phys->sa_magic, SA_MAGIC, - db->db.db_object); + (u_longlong_t)db->db.db_object); return (SET_ERROR(EIO)); } sa_byteswap(hdl, buftype); diff --git a/sys/contrib/openzfs/module/zfs/spa.c b/sys/contrib/openzfs/module/zfs/spa.c index 26995575adaa..f6dce076d136 100644 --- a/sys/contrib/openzfs/module/zfs/spa.c +++ b/sys/contrib/openzfs/module/zfs/spa.c @@ -2578,8 +2578,9 @@ spa_livelist_delete_cb(void *arg, zthr_t *z) .to_free = &to_free }; zfs_dbgmsg("deleting sublist (id %llu) from" - " livelist %llu, %d remaining", - dle->dle_bpobj.bpo_object, ll_obj, count - 1); + " livelist %llu, %lld remaining", + (u_longlong_t)dle->dle_bpobj.bpo_object, + (u_longlong_t)ll_obj, (longlong_t)count - 1); VERIFY0(dsl_sync_task(spa_name(spa), NULL, sublist_delete_sync, &sync_arg, 0, ZFS_SPACE_CHECK_DESTROY)); @@ -2596,7 +2597,8 @@ spa_livelist_delete_cb(void *arg, zthr_t *z) .ll_obj = ll_obj, .zap_obj = zap_obj }; - zfs_dbgmsg("deletion of livelist %llu completed", ll_obj); + zfs_dbgmsg("deletion of livelist %llu completed", + (u_longlong_t)ll_obj); VERIFY0(dsl_sync_task(spa_name(spa), NULL, livelist_delete_sync, &sync_arg, 0, ZFS_SPACE_CHECK_DESTROY)); } @@ -2696,10 +2698,12 @@ spa_livelist_condense_sync(void *arg, dmu_tx_t *tx) dsl_dataset_name(ds, dsname); zfs_dbgmsg("txg %llu condensing livelist of %s (id %llu), bpobj %llu " "(%llu blkptrs) and bpobj %llu (%llu blkptrs) -> bpobj %llu " - "(%llu blkptrs)", tx->tx_txg, dsname, ds->ds_object, first_obj, - cur_first_size, next_obj, cur_next_size, - first->dle_bpobj.bpo_object, - first->dle_bpobj.bpo_phys->bpo_num_blkptrs); + "(%llu blkptrs)", (u_longlong_t)tx->tx_txg, dsname, + (u_longlong_t)ds->ds_object, (u_longlong_t)first_obj, + (u_longlong_t)cur_first_size, (u_longlong_t)next_obj, + (u_longlong_t)cur_next_size, + (u_longlong_t)first->dle_bpobj.bpo_object, + (u_longlong_t)first->dle_bpobj.bpo_phys->bpo_num_blkptrs); out: dmu_buf_rele(ds->ds_dbuf, spa); spa->spa_to_condense.ds = NULL; @@ -3091,8 +3095,10 @@ spa_activity_check_duration(spa_t *spa, uberblock_t *ub) zfs_dbgmsg("fail_intvals>0 import_delay=%llu ub_mmp " "mmp_fails=%llu ub_mmp mmp_interval=%llu " - "import_intervals=%u", import_delay, MMP_FAIL_INT(ub), - MMP_INTERVAL(ub), import_intervals); + "import_intervals=%llu", (u_longlong_t)import_delay, + (u_longlong_t)MMP_FAIL_INT(ub), + (u_longlong_t)MMP_INTERVAL(ub), + (u_longlong_t)import_intervals); } else if (MMP_INTERVAL_VALID(ub) && MMP_FAIL_INT_VALID(ub) && MMP_FAIL_INT(ub) == 0) { @@ -3103,8 +3109,10 @@ spa_activity_check_duration(spa_t *spa, uberblock_t *ub) zfs_dbgmsg("fail_intvals=0 import_delay=%llu ub_mmp " "mmp_interval=%llu ub_mmp_delay=%llu " - "import_intervals=%u", import_delay, MMP_INTERVAL(ub), - ub->ub_mmp_delay, import_intervals); + "import_intervals=%llu", (u_longlong_t)import_delay, + (u_longlong_t)MMP_INTERVAL(ub), + (u_longlong_t)ub->ub_mmp_delay, + (u_longlong_t)import_intervals); } else if (MMP_VALID(ub)) { /* @@ -3115,15 +3123,18 @@ spa_activity_check_duration(spa_t *spa, uberblock_t *ub) ub->ub_mmp_delay) * import_intervals); zfs_dbgmsg("import_delay=%llu ub_mmp_delay=%llu " - "import_intervals=%u leaves=%u", import_delay, - ub->ub_mmp_delay, import_intervals, + "import_intervals=%llu leaves=%u", + (u_longlong_t)import_delay, + (u_longlong_t)ub->ub_mmp_delay, + (u_longlong_t)import_intervals, vdev_count_leaves(spa)); } else { /* Using local tunings is the only reasonable option */ zfs_dbgmsg("pool last imported on non-MMP aware " "host using import_delay=%llu multihost_interval=%llu " - "import_intervals=%u", import_delay, multihost_interval, - import_intervals); + "import_intervals=%llu", (u_longlong_t)import_delay, + (u_longlong_t)multihost_interval, + (u_longlong_t)import_intervals); } return (import_delay); @@ -3175,7 +3186,7 @@ spa_activity_check(spa_t *spa, uberblock_t *ub, nvlist_t *config) import_delay = spa_activity_check_duration(spa, ub); /* Add a small random factor in case of simultaneous imports (0-25%) */ - import_delay += import_delay * spa_get_random(250) / 1000; + import_delay += import_delay * random_in_range(250) / 1000; import_expire = gethrtime() + import_delay; @@ -3191,8 +3202,11 @@ spa_activity_check(spa_t *spa, uberblock_t *ub, nvlist_t *config) "txg %llu ub_txg %llu " "timestamp %llu ub_timestamp %llu " "mmp_config %#llx ub_mmp_config %#llx", - txg, ub->ub_txg, timestamp, ub->ub_timestamp, - mmp_config, ub->ub_mmp_config); + (u_longlong_t)txg, (u_longlong_t)ub->ub_txg, + (u_longlong_t)timestamp, + (u_longlong_t)ub->ub_timestamp, + (u_longlong_t)mmp_config, + (u_longlong_t)ub->ub_mmp_config); error = SET_ERROR(EREMOTEIO); break; @@ -4619,7 +4633,7 @@ spa_ld_checkpoint_rewind(spa_t *spa) vdev_t *svd[SPA_SYNC_MIN_VDEVS] = { NULL }; int svdcount = 0; int children = rvd->vdev_children; - int c0 = spa_get_random(children); + int c0 = random_in_range(children); for (int c = 0; c < children; c++) { vdev_t *vd = rvd->vdev_child[(c0 + c) % children]; @@ -8716,12 +8730,16 @@ spa_sync_props(void *arg, dmu_tx_t *tx) spa->spa_comment = spa_strdup(strval); /* * We need to dirty the configuration on all the vdevs - * so that their labels get updated. It's unnecessary - * to do this for pool creation since the vdev's - * configuration has already been dirtied. + * so that their labels get updated. We also need to + * update the cache file to keep it in sync with the + * MOS version. It's unnecessary to do this for pool + * creation since the vdev's configuration has already + * been dirtied. */ - if (tx->tx_txg != TXG_INITIAL) + if (tx->tx_txg != TXG_INITIAL) { vdev_config_dirty(spa->spa_root_vdev); + spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE); + } spa_history_log_internal(spa, "set", tx, "%s=%s", nvpair_name(elem), strval); break; @@ -8733,8 +8751,11 @@ spa_sync_props(void *arg, dmu_tx_t *tx) /* * Dirty the configuration on vdevs as above. */ - if (tx->tx_txg != TXG_INITIAL) + if (tx->tx_txg != TXG_INITIAL) { vdev_config_dirty(spa->spa_root_vdev); + spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE); + } + spa_history_log_internal(spa, "set", tx, "%s=%s", nvpair_name(elem), strval); break; @@ -9111,7 +9132,7 @@ spa_sync_rewrite_vdev_config(spa_t *spa, dmu_tx_t *tx) vdev_t *svd[SPA_SYNC_MIN_VDEVS] = { NULL }; int svdcount = 0; int children = rvd->vdev_children; - int c0 = spa_get_random(children); + int c0 = random_in_range(children); for (int c = 0; c < children; c++) { vdev_t *vd = diff --git a/sys/contrib/openzfs/module/zfs/spa_checkpoint.c b/sys/contrib/openzfs/module/zfs/spa_checkpoint.c index 5fb614467273..09f62996853d 100644 --- a/sys/contrib/openzfs/module/zfs/spa_checkpoint.c +++ b/sys/contrib/openzfs/module/zfs/spa_checkpoint.c @@ -337,17 +337,18 @@ spa_checkpoint_discard_thread_sync(void *arg, dmu_tx_t *tx) spa_checkpoint_accounting_verify(vd->vdev_spa); #endif - zfs_dbgmsg("discarding checkpoint: txg %llu, vdev id %d, " + zfs_dbgmsg("discarding checkpoint: txg %llu, vdev id %lld, " "deleted %llu words - %llu words are left", - tx->tx_txg, vd->vdev_id, (words_before - words_after), - words_after); + (u_longlong_t)tx->tx_txg, (longlong_t)vd->vdev_id, + (u_longlong_t)(words_before - words_after), + (u_longlong_t)words_after); if (error != EINTR) { if (error != 0) { - zfs_panic_recover("zfs: error %d was returned " + zfs_panic_recover("zfs: error %lld was returned " "while incrementally destroying the checkpoint " - "space map of vdev %llu\n", - error, vd->vdev_id); + "space map of vdev %u\n", + (longlong_t)error, vd->vdev_id); } ASSERT0(words_after); ASSERT0(space_map_allocated(vd->vdev_checkpoint_sm)); diff --git a/sys/contrib/openzfs/module/zfs/spa_history.c b/sys/contrib/openzfs/module/zfs/spa_history.c index 0482e0f6c39d..dae06e46c316 100644 --- a/sys/contrib/openzfs/module/zfs/spa_history.c +++ b/sys/contrib/openzfs/module/zfs/spa_history.c @@ -296,14 +296,17 @@ spa_history_log_sync(void *arg, dmu_tx_t *tx) } else if (nvlist_exists(nvl, ZPOOL_HIST_INT_NAME)) { if (nvlist_exists(nvl, ZPOOL_HIST_DSNAME)) { zfs_dbgmsg("txg %lld %s %s (id %llu) %s", - fnvlist_lookup_uint64(nvl, ZPOOL_HIST_TXG), + (longlong_t)fnvlist_lookup_uint64(nvl, + ZPOOL_HIST_TXG), fnvlist_lookup_string(nvl, ZPOOL_HIST_INT_NAME), fnvlist_lookup_string(nvl, ZPOOL_HIST_DSNAME), - fnvlist_lookup_uint64(nvl, ZPOOL_HIST_DSID), + (u_longlong_t)fnvlist_lookup_uint64(nvl, + ZPOOL_HIST_DSID), fnvlist_lookup_string(nvl, ZPOOL_HIST_INT_STR)); } else { zfs_dbgmsg("txg %lld %s %s", - fnvlist_lookup_uint64(nvl, ZPOOL_HIST_TXG), + (longlong_t)fnvlist_lookup_uint64(nvl, + ZPOOL_HIST_TXG), fnvlist_lookup_string(nvl, ZPOOL_HIST_INT_NAME), fnvlist_lookup_string(nvl, ZPOOL_HIST_INT_STR)); } diff --git a/sys/contrib/openzfs/module/zfs/spa_misc.c b/sys/contrib/openzfs/module/zfs/spa_misc.c index 1a2e5abc5335..e2523231d280 100644 --- a/sys/contrib/openzfs/module/zfs/spa_misc.c +++ b/sys/contrib/openzfs/module/zfs/spa_misc.c @@ -615,7 +615,7 @@ spa_deadman(void *arg) zfs_dbgmsg("slow spa_sync: started %llu seconds ago, calls %llu", (gethrtime() - spa->spa_sync_starttime) / NANOSEC, - ++spa->spa_deadman_calls); + (u_longlong_t)++spa->spa_deadman_calls); if (zfs_deadman_enabled) vdev_deadman(spa->spa_root_vdev, FTAG); @@ -1495,31 +1495,20 @@ spa_strfree(char *s) } uint64_t -spa_get_random(uint64_t range) -{ - uint64_t r; - - ASSERT(range != 0); - - if (range == 1) - return (0); - - (void) random_get_pseudo_bytes((void *)&r, sizeof (uint64_t)); - - return (r % range); -} - -uint64_t spa_generate_guid(spa_t *spa) { - uint64_t guid = spa_get_random(-1ULL); + uint64_t guid; if (spa != NULL) { - while (guid == 0 || spa_guid_exists(spa_guid(spa), guid)) - guid = spa_get_random(-1ULL); + do { + (void) random_get_pseudo_bytes((void *)&guid, + sizeof (guid)); + } while (guid == 0 || spa_guid_exists(spa_guid(spa), guid)); } else { - while (guid == 0 || spa_guid_exists(guid, 0)) - guid = spa_get_random(-1ULL); + do { + (void) random_get_pseudo_bytes((void *)&guid, + sizeof (guid)); + } while (guid == 0 || spa_guid_exists(guid, 0)); } return (guid); @@ -2888,7 +2877,6 @@ EXPORT_SYMBOL(spa_maxdnodesize); EXPORT_SYMBOL(spa_guid_exists); EXPORT_SYMBOL(spa_strdup); EXPORT_SYMBOL(spa_strfree); -EXPORT_SYMBOL(spa_get_random); EXPORT_SYMBOL(spa_generate_guid); EXPORT_SYMBOL(snprintf_blkptr); EXPORT_SYMBOL(spa_freeze); diff --git a/sys/contrib/openzfs/module/zfs/space_map.c b/sys/contrib/openzfs/module/zfs/space_map.c index 3db7d199199c..11d4798925e4 100644 --- a/sys/contrib/openzfs/module/zfs/space_map.c +++ b/sys/contrib/openzfs/module/zfs/space_map.c @@ -726,7 +726,7 @@ space_map_write_impl(space_map_t *sm, range_tree_t *rt, maptype_t maptype, length > SM_RUN_MAX || vdev_id != SM_NO_VDEVID || (zfs_force_some_double_word_sm_entries && - spa_get_random(100) == 0))) + random_in_range(100) == 0))) words = 2; space_map_write_seg(sm, rs_get_start(rs, rt), rs_get_end(rs, @@ -877,9 +877,11 @@ space_map_truncate(space_map_t *sm, int blocksize, dmu_tx_t *tx) doi.doi_data_block_size != blocksize || doi.doi_metadata_block_size != 1 << space_map_ibs) { zfs_dbgmsg("txg %llu, spa %s, sm %px, reallocating " - "object[%llu]: old bonus %u, old blocksz %u", - dmu_tx_get_txg(tx), spa_name(spa), sm, sm->sm_object, - doi.doi_bonus_size, doi.doi_data_block_size); + "object[%llu]: old bonus %llu, old blocksz %u", + (u_longlong_t)dmu_tx_get_txg(tx), spa_name(spa), sm, + (u_longlong_t)sm->sm_object, + (u_longlong_t)doi.doi_bonus_size, + doi.doi_data_block_size); space_map_free(sm, tx); dmu_buf_rele(sm->sm_dbuf, sm); diff --git a/sys/contrib/openzfs/module/zfs/txg.c b/sys/contrib/openzfs/module/zfs/txg.c index 497e19dd58eb..c55b1d8f9601 100644 --- a/sys/contrib/openzfs/module/zfs/txg.c +++ b/sys/contrib/openzfs/module/zfs/txg.c @@ -554,7 +554,8 @@ txg_sync_thread(void *arg) !txg_has_quiesced_to_sync(dp) && dp->dp_dirty_total < dirty_min_bytes) { dprintf("waiting; tx_synced=%llu waiting=%llu dp=%p\n", - tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp); + (u_longlong_t)tx->tx_synced_txg, + (u_longlong_t)tx->tx_sync_txg_waiting, dp); txg_thread_wait(tx, &cpr, &tx->tx_sync_more_cv, timer); delta = ddi_get_lbolt() - start; timer = (delta > timeout ? 0 : timeout - delta); @@ -587,7 +588,8 @@ txg_sync_thread(void *arg) cv_broadcast(&tx->tx_quiesce_more_cv); dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n", - txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); + (u_longlong_t)txg, (u_longlong_t)tx->tx_quiesce_txg_waiting, + (u_longlong_t)tx->tx_sync_txg_waiting); mutex_exit(&tx->tx_sync_lock); txg_stat_t *ts = spa_txg_history_init_io(spa, txg, dp); @@ -638,8 +640,9 @@ txg_quiesce_thread(void *arg) txg = tx->tx_open_txg; dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n", - txg, tx->tx_quiesce_txg_waiting, - tx->tx_sync_txg_waiting); + (u_longlong_t)txg, + (u_longlong_t)tx->tx_quiesce_txg_waiting, + (u_longlong_t)tx->tx_sync_txg_waiting); tx->tx_quiescing_txg = txg; mutex_exit(&tx->tx_sync_lock); @@ -649,7 +652,8 @@ txg_quiesce_thread(void *arg) /* * Hand this txg off to the sync thread. */ - dprintf("quiesce done, handing off txg %llu\n", txg); + dprintf("quiesce done, handing off txg %llu\n", + (u_longlong_t)txg); tx->tx_quiescing_txg = 0; tx->tx_quiesced_txg = txg; DTRACE_PROBE2(txg__quiesced, dsl_pool_t *, dp, uint64_t, txg); @@ -705,11 +709,13 @@ txg_wait_synced_impl(dsl_pool_t *dp, uint64_t txg, boolean_t wait_sig) if (tx->tx_sync_txg_waiting < txg) tx->tx_sync_txg_waiting = txg; dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n", - txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); + (u_longlong_t)txg, (u_longlong_t)tx->tx_quiesce_txg_waiting, + (u_longlong_t)tx->tx_sync_txg_waiting); while (tx->tx_synced_txg < txg) { dprintf("broadcasting sync more " "tx_synced=%llu waiting=%llu dp=%px\n", - tx->tx_synced_txg, tx->tx_sync_txg_waiting, dp); + (u_longlong_t)tx->tx_synced_txg, + (u_longlong_t)tx->tx_sync_txg_waiting, dp); cv_broadcast(&tx->tx_sync_more_cv); if (wait_sig) { /* @@ -764,7 +770,8 @@ txg_wait_open(dsl_pool_t *dp, uint64_t txg, boolean_t should_quiesce) if (tx->tx_quiesce_txg_waiting < txg && should_quiesce) tx->tx_quiesce_txg_waiting = txg; dprintf("txg=%llu quiesce_txg=%llu sync_txg=%llu\n", - txg, tx->tx_quiesce_txg_waiting, tx->tx_sync_txg_waiting); + (u_longlong_t)txg, (u_longlong_t)tx->tx_quiesce_txg_waiting, + (u_longlong_t)tx->tx_sync_txg_waiting); while (tx->tx_open_txg < txg) { cv_broadcast(&tx->tx_quiesce_more_cv); /* diff --git a/sys/contrib/openzfs/module/zfs/vdev.c b/sys/contrib/openzfs/module/zfs/vdev.c index 5e14d71f1946..4e316d8135ee 100644 --- a/sys/contrib/openzfs/module/zfs/vdev.c +++ b/sys/contrib/openzfs/module/zfs/vdev.c @@ -165,7 +165,8 @@ vdev_dbgmsg_print_tree(vdev_t *vd, int indent) char state[20]; if (vd->vdev_ishole || vd->vdev_ops == &vdev_missing_ops) { - zfs_dbgmsg("%*svdev %u: %s", indent, "", vd->vdev_id, + zfs_dbgmsg("%*svdev %llu: %s", indent, "", + (u_longlong_t)vd->vdev_id, vd->vdev_ops->vdev_op_type); return; } @@ -5208,7 +5209,7 @@ vdev_deadman(vdev_t *vd, char *tag) zio_t *fio; uint64_t delta; - zfs_dbgmsg("slow vdev: %s has %d active IOs", + zfs_dbgmsg("slow vdev: %s has %lu active IOs", vd->vdev_path, avl_numnodes(&vq->vq_active_tree)); /* diff --git a/sys/contrib/openzfs/module/zfs/vdev_indirect.c b/sys/contrib/openzfs/module/zfs/vdev_indirect.c index e539e9aa2d70..e476663ab582 100644 --- a/sys/contrib/openzfs/module/zfs/vdev_indirect.c +++ b/sys/contrib/openzfs/module/zfs/vdev_indirect.c @@ -529,8 +529,9 @@ spa_condense_indirect_complete_sync(void *arg, dmu_tx_t *tx) zfs_dbgmsg("finished condense of vdev %llu in txg %llu: " "new mapping object %llu has %llu entries " "(was %llu entries)", - vd->vdev_id, dmu_tx_get_txg(tx), vic->vic_mapping_object, - new_count, old_count); + (u_longlong_t)vd->vdev_id, (u_longlong_t)dmu_tx_get_txg(tx), + (u_longlong_t)vic->vic_mapping_object, + (u_longlong_t)new_count, (u_longlong_t)old_count); vdev_config_dirty(spa->spa_root_vdev); } @@ -796,7 +797,7 @@ spa_condense_indirect_start_sync(vdev_t *vd, dmu_tx_t *tx) zfs_dbgmsg("starting condense of vdev %llu in txg %llu: " "posm=%llu nm=%llu", - vd->vdev_id, dmu_tx_get_txg(tx), + (u_longlong_t)vd->vdev_id, (u_longlong_t)dmu_tx_get_txg(tx), (u_longlong_t)scip->scip_prev_obsolete_sm_object, (u_longlong_t)scip->scip_next_mapping_object); @@ -1572,7 +1573,7 @@ vdev_indirect_splits_enumerate_randomly(indirect_vsd_t *iv, zio_t *zio) indirect_child_t *ic = list_head(&is->is_unique_child); int children = is->is_unique_children; - for (int i = spa_get_random(children); i > 0; i--) + for (int i = random_in_range(children); i > 0; i--) ic = list_next(&is->is_unique_child, ic); ASSERT3P(ic, !=, NULL); @@ -1736,7 +1737,7 @@ vdev_indirect_reconstruct_io_done(zio_t *zio) * Known_good will be TRUE when reconstruction is known to be possible. */ if (zfs_reconstruct_indirect_damage_fraction != 0 && - spa_get_random(zfs_reconstruct_indirect_damage_fraction) == 0) + random_in_range(zfs_reconstruct_indirect_damage_fraction) == 0) known_good = (vdev_indirect_splits_damage(iv, zio) == 0); /* diff --git a/sys/contrib/openzfs/module/zfs/vdev_mirror.c b/sys/contrib/openzfs/module/zfs/vdev_mirror.c index 106678a8708e..5eb331046953 100644 --- a/sys/contrib/openzfs/module/zfs/vdev_mirror.c +++ b/sys/contrib/openzfs/module/zfs/vdev_mirror.c @@ -496,7 +496,7 @@ vdev_mirror_preferred_child_randomize(zio_t *zio) int p; if (mm->mm_root) { - p = spa_get_random(mm->mm_preferred_cnt); + p = random_in_range(mm->mm_preferred_cnt); return (vdev_mirror_dva_select(zio, p)); } diff --git a/sys/contrib/openzfs/module/zfs/vdev_removal.c b/sys/contrib/openzfs/module/zfs/vdev_removal.c index d7c0641c8c2c..f762c1df96aa 100644 --- a/sys/contrib/openzfs/module/zfs/vdev_removal.c +++ b/sys/contrib/openzfs/module/zfs/vdev_removal.c @@ -345,8 +345,9 @@ vdev_remove_initiate_sync(void *arg, dmu_tx_t *tx) vdev_config_dirty(vd); zfs_dbgmsg("starting removal thread for vdev %llu (%px) in txg %llu " - "im_obj=%llu", vd->vdev_id, vd, dmu_tx_get_txg(tx), - vic->vic_mapping_object); + "im_obj=%llu", (u_longlong_t)vd->vdev_id, vd, + (u_longlong_t)dmu_tx_get_txg(tx), + (u_longlong_t)vic->vic_mapping_object); spa_history_log_internal(spa, "vdev remove started", tx, "%s vdev %llu %s", spa_name(spa), (u_longlong_t)vd->vdev_id, @@ -474,7 +475,8 @@ spa_restart_removal(spa_t *spa) if (!spa_writeable(spa)) return; - zfs_dbgmsg("restarting removal of %llu", svr->svr_vdev_id); + zfs_dbgmsg("restarting removal of %llu", + (u_longlong_t)svr->svr_vdev_id); svr->svr_thread = thread_create(NULL, 0, spa_vdev_remove_thread, spa, 0, &p0, TS_RUN, minclsyspri); } @@ -1196,7 +1198,7 @@ vdev_remove_complete(spa_t *spa) ESC_ZFS_VDEV_REMOVE_DEV); zfs_dbgmsg("finishing device removal for vdev %llu in txg %llu", - vd->vdev_id, txg); + (u_longlong_t)vd->vdev_id, (u_longlong_t)txg); /* * Discard allocation state. @@ -1490,8 +1492,9 @@ spa_vdev_remove_thread(void *arg) vca.vca_msp = msp; zfs_dbgmsg("copying %llu segments for metaslab %llu", - zfs_btree_numnodes(&svr->svr_allocd_segs->rt_root), - msp->ms_id); + (u_longlong_t)zfs_btree_numnodes( + &svr->svr_allocd_segs->rt_root), + (u_longlong_t)msp->ms_id); while (!svr->svr_thread_exit && !range_tree_is_empty(svr->svr_allocd_segs)) { @@ -1588,8 +1591,8 @@ spa_vdev_remove_thread(void *arg) vca.vca_write_error_bytes > 0)) { zfs_dbgmsg("canceling removal due to IO errors: " "[read_error_bytes=%llu] [write_error_bytes=%llu]", - vca.vca_read_error_bytes, - vca.vca_write_error_bytes); + (u_longlong_t)vca.vca_read_error_bytes, + (u_longlong_t)vca.vca_write_error_bytes); spa_vdev_remove_cancel_impl(spa); } } else { @@ -1761,7 +1764,7 @@ spa_vdev_remove_cancel_sync(void *arg, dmu_tx_t *tx) vdev_config_dirty(vd); zfs_dbgmsg("canceled device removal for vdev %llu in %llu", - vd->vdev_id, dmu_tx_get_txg(tx)); + (u_longlong_t)vd->vdev_id, (u_longlong_t)dmu_tx_get_txg(tx)); spa_history_log_internal(spa, "vdev remove canceled", tx, "%s vdev %llu %s", spa_name(spa), (u_longlong_t)vd->vdev_id, diff --git a/sys/contrib/openzfs/module/zfs/zap.c b/sys/contrib/openzfs/module/zfs/zap.c index c0c280c52076..6f03beef3bdb 100644 --- a/sys/contrib/openzfs/module/zfs/zap.c +++ b/sys/contrib/openzfs/module/zfs/zap.c @@ -221,7 +221,8 @@ zap_table_grow(zap_t *zap, zap_table_phys_t *tbl, tbl->zt_blks_copied++; dprintf("copied block %llu of %llu\n", - tbl->zt_blks_copied, tbl->zt_numblks); + (u_longlong_t)tbl->zt_blks_copied, + (u_longlong_t)tbl->zt_numblks); if (tbl->zt_blks_copied == tbl->zt_numblks) { (void) dmu_free_range(zap->zap_objset, zap->zap_object, @@ -234,7 +235,7 @@ zap_table_grow(zap_t *zap, zap_table_phys_t *tbl, tbl->zt_blks_copied = 0; dprintf("finished; numblocks now %llu (%uk entries)\n", - tbl->zt_numblks, 1<<(tbl->zt_shift-10)); + (u_longlong_t)tbl->zt_numblks, 1<<(tbl->zt_shift-10)); } return (0); @@ -249,7 +250,8 @@ zap_table_store(zap_t *zap, zap_table_phys_t *tbl, uint64_t idx, uint64_t val, ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); ASSERT(tbl->zt_blk != 0); - dprintf("storing %llx at index %llx\n", val, idx); + dprintf("storing %llx at index %llx\n", (u_longlong_t)val, + (u_longlong_t)idx); uint64_t blk = idx >> (bs-3); uint64_t off = idx & ((1<<(bs-3))-1); diff --git a/sys/contrib/openzfs/module/zfs/zap_micro.c b/sys/contrib/openzfs/module/zfs/zap_micro.c index 5d9bc2076068..b4611685b204 100644 --- a/sys/contrib/openzfs/module/zfs/zap_micro.c +++ b/sys/contrib/openzfs/module/zfs/zap_micro.c @@ -563,7 +563,7 @@ zap_lockdir_impl(dmu_buf_t *db, void *tag, dmu_tx_t *tx, uint64_t newsz = db->db_size + SPA_MINBLOCKSIZE; if (newsz > MZAP_MAX_BLKSZ) { dprintf("upgrading obj %llu: num_entries=%u\n", - obj, zap->zap_m.zap_num_entries); + (u_longlong_t)obj, zap->zap_m.zap_num_entries); *zapp = zap; int err = mzap_upgrade(zapp, tag, tx, 0); if (err != 0) @@ -656,7 +656,7 @@ mzap_upgrade(zap_t **zapp, void *tag, dmu_tx_t *tx, zap_flags_t flags) } dprintf("upgrading obj=%llu with %u chunks\n", - zap->zap_object, nchunks); + (u_longlong_t)zap->zap_object, nchunks); /* XXX destroy the avl later, so we can use the stored hash value */ mze_destroy(zap); @@ -667,7 +667,7 @@ mzap_upgrade(zap_t **zapp, void *tag, dmu_tx_t *tx, zap_flags_t flags) if (mze->mze_name[0] == 0) continue; dprintf("adding %s=%llu\n", - mze->mze_name, mze->mze_value); + mze->mze_name, (u_longlong_t)mze->mze_value); zap_name_t *zn = zap_name_alloc(zap, mze->mze_name, 0); /* If we fail here, we would end up losing entries */ VERIFY0(fzap_add_cd(zn, 8, 1, &mze->mze_value, mze->mze_cd, @@ -1339,7 +1339,8 @@ zap_update(objset_t *os, uint64_t zapobj, const char *name, } else if (integer_size != 8 || num_integers != 1 || strlen(name) >= MZAP_NAME_LEN) { dprintf("upgrading obj %llu: intsz=%u numint=%llu name=%s\n", - zapobj, integer_size, num_integers, name); + (u_longlong_t)zapobj, integer_size, + (u_longlong_t)num_integers, name); err = mzap_upgrade(&zn->zn_zap, FTAG, tx, 0); if (err == 0) { err = fzap_update(zn, integer_size, num_integers, diff --git a/sys/contrib/openzfs/module/zfs/zcp.c b/sys/contrib/openzfs/module/zfs/zcp.c index 1ad53eae1eef..f724b44baf1d 100644 --- a/sys/contrib/openzfs/module/zfs/zcp.c +++ b/sys/contrib/openzfs/module/zfs/zcp.c @@ -654,7 +654,8 @@ zcp_debug(lua_State *state) dbgstring = lua_tostring(state, 1); - zfs_dbgmsg("txg %lld ZCP: %s", ri->zri_tx->tx_txg, dbgstring); + zfs_dbgmsg("txg %lld ZCP: %s", (longlong_t)ri->zri_tx->tx_txg, + dbgstring); return (0); } diff --git a/sys/contrib/openzfs/module/zfs/zil.c b/sys/contrib/openzfs/module/zfs/zil.c index d9c3042084e3..78d0711cce4e 100644 --- a/sys/contrib/openzfs/module/zfs/zil.c +++ b/sys/contrib/openzfs/module/zfs/zil.c @@ -205,8 +205,10 @@ zil_init_log_chain(zilog_t *zilog, blkptr_t *bp) { zio_cksum_t *zc = &bp->blk_cksum; - zc->zc_word[ZIL_ZC_GUID_0] = spa_get_random(-1ULL); - zc->zc_word[ZIL_ZC_GUID_1] = spa_get_random(-1ULL); + (void) random_get_pseudo_bytes((void *)&zc->zc_word[ZIL_ZC_GUID_0], + sizeof (zc->zc_word[ZIL_ZC_GUID_0])); + (void) random_get_pseudo_bytes((void *)&zc->zc_word[ZIL_ZC_GUID_1], + sizeof (zc->zc_word[ZIL_ZC_GUID_1])); zc->zc_word[ZIL_ZC_OBJSET] = dmu_objset_id(zilog->zl_os); zc->zc_word[ZIL_ZC_SEQ] = 1ULL; } @@ -1960,7 +1962,7 @@ zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx) * This should be rare. */ zfs_dbgmsg("zil_itx_assign: missed itx cleanup for " - "txg %llu", itxg->itxg_txg); + "txg %llu", (u_longlong_t)itxg->itxg_txg); clean = itxg->itxg_itxs; } itxg->itxg_txg = txg; @@ -3285,7 +3287,8 @@ zil_close(zilog_t *zilog) txg_wait_synced(zilog->zl_dmu_pool, txg); if (zilog_is_dirty(zilog)) - zfs_dbgmsg("zil (%px) is dirty, txg %llu", zilog, txg); + zfs_dbgmsg("zil (%px) is dirty, txg %llu", zilog, + (u_longlong_t)txg); if (txg < spa_freeze_txg(zilog->zl_spa)) VERIFY(!zilog_is_dirty(zilog)); diff --git a/sys/contrib/openzfs/module/zfs/zio.c b/sys/contrib/openzfs/module/zfs/zio.c index 66ac545c7981..e33d36dab5f9 100644 --- a/sys/contrib/openzfs/module/zfs/zio.c +++ b/sys/contrib/openzfs/module/zfs/zio.c @@ -2014,18 +2014,24 @@ zio_deadman_impl(zio_t *pio, int ziodepth) zfs_dbgmsg("slow zio[%d]: zio=%px timestamp=%llu " "delta=%llu queued=%llu io=%llu " - "path=%s last=%llu " - "type=%d priority=%d flags=0x%x " - "stage=0x%x pipeline=0x%x pipeline-trace=0x%x " - "objset=%llu object=%llu level=%llu blkid=%llu " - "offset=%llu size=%llu error=%d", + "path=%s " + "last=%llu type=%d " + "priority=%d flags=0x%x stage=0x%x " + "pipeline=0x%x pipeline-trace=0x%x " + "objset=%llu object=%llu " + "level=%llu blkid=%llu " + "offset=%llu size=%llu " + "error=%d", ziodepth, pio, pio->io_timestamp, - delta, pio->io_delta, pio->io_delay, - vd ? vd->vdev_path : "NULL", vq ? vq->vq_io_complete_ts : 0, - pio->io_type, pio->io_priority, pio->io_flags, - pio->io_stage, pio->io_pipeline, pio->io_pipeline_trace, - zb->zb_objset, zb->zb_object, zb->zb_level, zb->zb_blkid, - pio->io_offset, pio->io_size, pio->io_error); + (u_longlong_t)delta, pio->io_delta, pio->io_delay, + vd ? vd->vdev_path : "NULL", + vq ? vq->vq_io_complete_ts : 0, pio->io_type, + pio->io_priority, pio->io_flags, pio->io_stage, + pio->io_pipeline, pio->io_pipeline_trace, + (u_longlong_t)zb->zb_objset, (u_longlong_t)zb->zb_object, + (u_longlong_t)zb->zb_level, (u_longlong_t)zb->zb_blkid, + (u_longlong_t)pio->io_offset, (u_longlong_t)pio->io_size, + pio->io_error); (void) zfs_ereport_post(FM_EREPORT_ZFS_DEADMAN, pio->io_spa, vd, zb, pio, 0); @@ -3533,7 +3539,8 @@ zio_dva_allocate(zio_t *zio) if (zfs_flags & ZFS_DEBUG_METASLAB_ALLOC) { zfs_dbgmsg("%s: metaslab allocation failure, " "trying normal class: zio %px, size %llu, error %d", - spa_name(spa), zio, zio->io_size, error); + spa_name(spa), zio, (u_longlong_t)zio->io_size, + error); } error = metaslab_alloc(spa, mc, zio->io_size, bp, @@ -3545,7 +3552,8 @@ zio_dva_allocate(zio_t *zio) if (zfs_flags & ZFS_DEBUG_METASLAB_ALLOC) { zfs_dbgmsg("%s: metaslab allocation failure, " "trying ganging: zio %px, size %llu, error %d", - spa_name(spa), zio, zio->io_size, error); + spa_name(spa), zio, (u_longlong_t)zio->io_size, + error); } return (zio_write_gang_block(zio, mc)); } @@ -3554,7 +3562,8 @@ zio_dva_allocate(zio_t *zio) (zfs_flags & ZFS_DEBUG_METASLAB_ALLOC)) { zfs_dbgmsg("%s: metaslab allocation failure: zio %px, " "size %llu, error %d", - spa_name(spa), zio, zio->io_size, error); + spa_name(spa), zio, (u_longlong_t)zio->io_size, + error); } zio->io_error = error; } @@ -3680,7 +3689,8 @@ zio_alloc_zil(spa_t *spa, objset_t *os, uint64_t txg, blkptr_t *new_bp, } } else { zfs_dbgmsg("%s: zil block allocation failure: " - "size %llu, error %d", spa_name(spa), size, error); + "size %llu, error %d", spa_name(spa), (u_longlong_t)size, + error); } return (error); diff --git a/sys/contrib/openzfs/module/zfs/zio_compress.c b/sys/contrib/openzfs/module/zfs/zio_compress.c index 2db3cec35d5d..33602bd471f3 100644 --- a/sys/contrib/openzfs/module/zfs/zio_compress.c +++ b/sys/contrib/openzfs/module/zfs/zio_compress.c @@ -201,7 +201,7 @@ zio_decompress_data(enum zio_compress c, abd_t *src, void *dst, * in non-ECC RAM), we handle this error (and test it). */ if (zio_decompress_fail_fraction != 0 && - spa_get_random(zio_decompress_fail_fraction) == 0) + random_in_range(zio_decompress_fail_fraction) == 0) ret = SET_ERROR(EINVAL); return (ret); diff --git a/sys/contrib/openzfs/module/zfs/zio_inject.c b/sys/contrib/openzfs/module/zfs/zio_inject.c index e56ea88682ff..feaf41dc65e3 100644 --- a/sys/contrib/openzfs/module/zfs/zio_inject.c +++ b/sys/contrib/openzfs/module/zfs/zio_inject.c @@ -117,7 +117,7 @@ freq_triggered(uint32_t frequency) */ uint32_t maximum = (frequency <= 100) ? 100 : ZI_PERCENTAGE_MAX; - return (spa_get_random(maximum) < frequency); + return (random_in_range(maximum) < frequency); } /* @@ -347,12 +347,12 @@ zio_inject_bitflip_cb(void *data, size_t len, void *private) { zio_t *zio __maybe_unused = private; uint8_t *buffer = data; - uint_t byte = spa_get_random(len); + uint_t byte = random_in_range(len); ASSERT(zio->io_type == ZIO_TYPE_READ); /* flip a single random bit in an abd data buffer */ - buffer[byte] ^= 1 << spa_get_random(8); + buffer[byte] ^= 1 << random_in_range(8); return (1); /* stop after first flip */ } @@ -493,7 +493,7 @@ zio_handle_ignored_writes(zio_t *zio) } /* Have a "problem" writing 60% of the time */ - if (spa_get_random(100) < 60) + if (random_in_range(100) < 60) zio->io_pipeline &= ~ZIO_VDEV_IO_STAGES; break; } diff --git a/sys/contrib/openzfs/tests/runfiles/common.run b/sys/contrib/openzfs/tests/runfiles/common.run index e87c1cd641ff..996e5f615cd4 100644 --- a/sys/contrib/openzfs/tests/runfiles/common.run +++ b/sys/contrib/openzfs/tests/runfiles/common.run @@ -351,7 +351,8 @@ tests = ['zpool_create_001_pos', 'zpool_create_002_pos', 'zpool_create_features_003_pos', 'zpool_create_features_004_neg', 'zpool_create_features_005_pos', 'zpool_create_features_006_pos', 'zpool_create_features_007_pos', 'zpool_create_features_008_pos', - 'create-o_ashift', 'zpool_create_tempname', 'zpool_create_dryrun_output'] + 'zpool_create_features_009_pos', 'create-o_ashift', + 'zpool_create_tempname', 'zpool_create_dryrun_output'] tags = ['functional', 'cli_root', 'zpool_create'] [tests/functional/cli_root/zpool_destroy] diff --git a/sys/contrib/openzfs/tests/test-runner/bin/zts-report.py.in b/sys/contrib/openzfs/tests/test-runner/bin/zts-report.py.in index a3e9f2a82e69..27c865ed5c7a 100755 --- a/sys/contrib/openzfs/tests/test-runner/bin/zts-report.py.in +++ b/sys/contrib/openzfs/tests/test-runner/bin/zts-report.py.in @@ -261,6 +261,8 @@ if sys.platform.startswith('freebsd'): maybe.update({ 'cli_root/zfs_copies/zfs_copies_002_pos': ['FAIL', known_reason], 'cli_root/zfs_inherit/zfs_inherit_001_neg': ['FAIL', known_reason], + 'cli_root/zfs_receive/receive-o-x_props_override': + ['FAIL', known_reason], 'cli_root/zfs_share/zfs_share_011_pos': ['FAIL', known_reason], 'cli_root/zfs_share/zfs_share_concurrent_shares': ['FAIL', known_reason], @@ -282,6 +284,7 @@ elif sys.platform.startswith('linux'): 'alloc_class/alloc_class_009_pos': ['FAIL', known_reason], 'alloc_class/alloc_class_010_pos': ['FAIL', known_reason], 'alloc_class/alloc_class_011_neg': ['FAIL', known_reason], + 'alloc_class/alloc_class_012_pos': ['FAIL', known_reason], 'alloc_class/alloc_class_013_pos': ['FAIL', '11888'], 'cli_root/zfs_rename/zfs_rename_002_pos': ['FAIL', known_reason], 'cli_root/zpool_expand/zpool_expand_001_pos': ['FAIL', known_reason], diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg b/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg index 0db9724eead0..1ec73f25bae7 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg @@ -188,7 +188,6 @@ export ZFS_FILES='zdb zed zgenhostid zstream - zstreamdump zfs_ids_to_path zpool_influxdb' diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am index 5e9e83f0db91..5ffaae5b152c 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am @@ -39,6 +39,7 @@ dist_pkgdata_SCRIPTS = \ zpool_create_features_006_pos.ksh \ zpool_create_features_007_pos.ksh \ zpool_create_features_008_pos.ksh \ + zpool_create_features_009_pos.ksh \ create-o_ashift.ksh \ zpool_create_tempname.ksh \ zpool_create_dryrun_output.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_009_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_009_pos.ksh new file mode 100755 index 000000000000..052c18dcee2b --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_009_pos.ksh @@ -0,0 +1,92 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2021 Lawrence Livermore National Security, LLC. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify '-o compatibility' property is updated in both the +# pool config MOS object and the cache file. +# +# STRATEGY: +# 1. Create a pool with '-o compatibility=legacy', then verify +# the property exists in the MOS config and cache file. +# 2. Create a pool, set the 'compatibility=off' property, then +# verify the property exists in the MOS config and cache file. +# + +verify_runnable "global" + +function cleanup +{ + datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL + rm -f $CACHE_FILE +} + +function check_config +{ + typeset propval=$1 + + poolval="$(zpool get -H -o value compatibility $TESTPOOL)" + if [ "$poolval" != "$propval" ]; then + log_fail "compatibility property set incorrectly $curval" + fi + + if ! zdb -C -U $CACHE_FILE | grep "compatibility: '$propval'"; then + log_fail "compatibility property missing in cache file" + fi + + if ! zdb -C -U $CACHE_FILE $TESTPOOL | grep "compatibility: '$propval'"; then + log_fail "compatibility property missing from MOS object" + fi +} + +log_onexit cleanup + +log_assert "verify '-o compatibility' in MOS object and cache file" + +CACHE_FILE=$TEST_BASE_DIR/cachefile.$$ + +# 1. Create a pool with '-o compatibility=legacy', then verify +# the property exists in the MOS config and cache file. +log_must zpool create -f -o cachefile=$CACHE_FILE -o compatibility=legacy $TESTPOOL $DISKS +log_must check_config legacy +log_must zpool export -F $TESTPOOL +log_must zpool import -c $CACHE_FILE $TESTPOOL +log_must check_config legacy +log_must zpool destroy -f $TESTPOOL + +# 2. Create a pool, set the 'compatibility=off' property, then +# verify the property exists in the MOS config and cache file. +log_must zpool create -f -o cachefile=$CACHE_FILE $TESTPOOL $DISKS +log_must zpool set compatibility=legacy $TESTPOOL +log_must check_config legacy +log_must zpool export -F $TESTPOOL +log_must zpool import -c $CACHE_FILE $TESTPOOL +log_must check_config legacy +log_must zpool destroy -f $TESTPOOL + +log_pass "verify '-o compatibility' in MOS object and cache file" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh index 94937a2f79ab..1c5b503a9be5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh @@ -65,7 +65,7 @@ for recsize in 512 1024 2048 4096 8192 16384; do grep -q "EMBEDDED" $tmpdir/recv.zdb || \ log_fail "Obj $recv_obj not embedded in $recvfs" - cat $stream | zstreamdump -v | log_must grep -q \ + cat $stream | zstream dump -v | log_must grep -q \ "WRITE_EMBEDDED object = $send_obj offset = 0" done @@ -96,7 +96,7 @@ for recsize in 1024 4096 16384; do grep -q "EMBEDDED" $tmpdir/recv.zdb || \ log_fail "Obj $recv_obj not embedded in $recvfs" - cat $stream | zstreamdump -v | log_must grep -q \ + cat $stream | zstream dump -v | log_must grep -q \ "WRITE_EMBEDDED object = $send_obj offset = 0" done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 26755e87d0a5..d06bd39b4d49 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -584,13 +584,13 @@ function mess_send_file # The random offset might truncate the send stream to be # smaller than the DRR_BEGIN record. If this happens, then # the receiving system won't have enough info to create the - # partial dataset at all. We use zstreamdump to check for + # partial dataset at all. We use zstream dump to check for # this and retry in this case. - nr_begins=$(head -c $offset $file | zstreamdump | \ + nr_begins=$(head -c $offset $file | zstream dump | \ grep DRR_BEGIN | awk '{ print $5 }') while [ "$nr_begins" -eq 0 ]; do offset=$(($RANDOM * $RANDOM % $filesize)) - nr_begins=$(head -c $offset $file | zstreamdump | \ + nr_begins=$(head -c $offset $file | zstream dump | \ grep DRR_BEGIN | awk '{ print $5 }') done @@ -741,7 +741,7 @@ function stream_has_features shift [[ -f $file ]] || log_fail "Couldn't find file: $file" - typeset flags=$(cat $file | zstreamdump | \ + typeset flags=$(cat $file | zstream dump | \ awk '/features =/ {features = $3} END {print features}') typeset -A feature feature[dedup]="1" @@ -774,7 +774,7 @@ function stream_has_features # comparing. This function does not currently handle incremental streams # that remove data. # -# $1 The zstreamdump output file +# $1 The zstream dump output file # $2 The dataset to compare against # This can be a source of a send or recv target (fs, not snapshot) # $3 The percentage below which verification is deemed a failure @@ -791,7 +791,7 @@ function verify_stream_size [[ -f $stream ]] || log_fail "No such file: $stream" datasetexists $ds || log_fail "No such dataset: $ds" - typeset stream_size=$(cat $stream | zstreamdump | sed -n \ + typeset stream_size=$(cat $stream | zstream dump | sed -n \ 's/ Total payload size = \(.*\) (0x.*)/\1/p') typeset inc_size=0 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_embedded_blocks.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_embedded_blocks.ksh index 70f79b3173b7..3dce217d8955 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_embedded_blocks.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_embedded_blocks.ksh @@ -63,17 +63,17 @@ for recsize in "${recsize_prop_vals[@]}"; do fi done -# Generate the streams and zstreamdump output. +# Generate the streams and zstream dump output. log_must zfs snapshot $sendfs@now log_must eval "zfs send -c $sendfs@now >$stream" -log_must eval "zstreamdump -v <$stream >$dump" +log_must eval "zstream dump -v <$stream >$dump" log_must eval "zfs recv -d $recvfs <$stream" cmp_ds_cont $sendfs $recvfs verify_stream_size $stream $sendfs log_mustnot stream_has_features $stream embed_data log_must eval "zfs send -c -e $sendfs@now >$stream2" -log_must eval "zstreamdump -v <$stream2 >$dump2" +log_must eval "zstream dump -v <$stream2 >$dump2" log_must eval "zfs recv -d $recvfs2 <$stream2" cmp_ds_cont $sendfs $recvfs2 verify_stream_size $stream2 $sendfs @@ -101,9 +101,9 @@ for recsize in "${recsize_prop_vals[@]}"; do log_fail "Obj $recv2_obj not embedded in $recvfs2" grep -q "WRITE_EMBEDDED object = $send_obj offset = 0" $dump && \ - log_fail "Obj $obj embedded in zstreamdump output" + log_fail "Obj $obj embedded in zstream dump output" grep -q "WRITE_EMBEDDED object = $send_obj offset = 0" $dump2 || \ - log_fail "Obj $obj not embedded in zstreamdump output" + log_fail "Obj $obj not embedded in zstream dump output" done log_pass "Compressed streams can contain embedded blocks." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh index b4dc00cec4e7..5b9939c6a64c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh @@ -21,12 +21,12 @@ # # Description: -# Verify compression features show up in zstreamdump +# Verify compression features show up in zstream dump # # Strategy: # 1. Create a full compressed send stream -# 2. Verify zstreamdump shows this stream has the relevant features -# 3. Verify zstreamdump's accounting of logical and compressed size is correct +# 2. Verify zstream dump shows this stream has the relevant features +# 3. Verify zstream dump's accounting of logical and compressed size is correct # 4. Verify the toname from a resume token # 5. Verify it fails with corrupted resume token # 6. Verify it fails with missing resume token @@ -34,7 +34,7 @@ verify_runnable "both" -log_assert "Verify zstreamdump correctly interprets compressed send streams." +log_assert "Verify zstream dump correctly interprets compressed send streams." log_onexit cleanup_pool $POOL2 typeset sendfs=$POOL2/fs @@ -49,7 +49,7 @@ log_must zfs snapshot $sendfs@full log_must eval "zfs send -c $sendfs@full >$BACKDIR/full" log_must stream_has_features $BACKDIR/full lz4 compressed -cat $BACKDIR/full | zstreamdump -v > $BACKDIR/dump.out +cat $BACKDIR/full | zstream dump -v > $BACKDIR/dump.out lsize=$(awk '/^WRITE [^0]/ {lsize += $24} END {printf("%d", lsize)}' \ $BACKDIR/dump.out) @@ -72,4 +72,4 @@ bad_resume_token="1-1162e8285b-100789c6360" log_mustnot eval "zstream token $bad_resume_token 2>&1" log_mustnot eval "zstream token 2>&1" -log_pass "zstreamdump correctly interprets compressed send streams." +log_pass "zstream dump correctly interprets compressed send streams." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-cpL_varied_recsize.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-cpL_varied_recsize.ksh index e1ac00c79c96..e2810651a60e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-cpL_varied_recsize.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-cpL_varied_recsize.ksh @@ -134,7 +134,7 @@ function check [[ -f $stream ]] && log_must rm $stream log_must eval "zfs send $flags $send_snap >$stream" $verify eval "zfs recv $recv_ds <$stream" - typeset stream_size=$(cat $stream | zstreamdump | sed -n \ + typeset stream_size=$(cat $stream | zstream dump | sed -n \ 's/ Total write size = \(.*\) (0x.*)/\1/p') # |