From c9fe07ff3ef9537a33e80be1e020525f0270f419 Mon Sep 17 00:00:00 2001 From: Richard Lowe Date: Thu, 4 Jul 2024 21:42:47 +0000 Subject: [PATCH 1/7] 16569 want a more foolproof method to build native tools (fix native assembler) --- usr/src/Makefile.master | 4 ++++ usr/src/Makefile.master.64 | 1 + 2 files changed, 5 insertions(+) diff --git a/usr/src/Makefile.master b/usr/src/Makefile.master index f1d43c19330..69104cd8cef 100644 --- a/usr/src/Makefile.master +++ b/usr/src/Makefile.master @@ -570,6 +570,8 @@ NATIVE_CFLAGS= $(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) \ $(CCNOREORDER) $(CCNOAGGRESSIVELOOPS) $(CCINLINESIZE) \ $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS) +NATIVE_ASFLAGS= $(NATIVE_CFLAGS) + NATIVE_CCFLAGS= $(CCOPTFLAG) $($(NATIVE_MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \ $(CCUSERFLAGS) @@ -578,6 +580,8 @@ NATIVE_CFLAGS64= $(COPTFLAG64) $($(NATIVE_MACH64)_CFLAGS) \ $(CCNOREORDER) $(CCNOAGGRESSIVELOOPS) $(CCINLINESIZE) \ $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64) +NATIVE_ASFLAGS64= $(NATIVE_CFLAGS64) + NATIVE_CCFLAGS64= $(CCOPTFLAG64) $($(NATIVE_MACH64)_CCFLAGS) \ $(CCSOURCEDEBUGFLAGS) $(CCUSERFLAGS64) diff --git a/usr/src/Makefile.master.64 b/usr/src/Makefile.master.64 index 606c3c5826b..82aedf6a7a7 100644 --- a/usr/src/Makefile.master.64 +++ b/usr/src/Makefile.master.64 @@ -41,6 +41,7 @@ LINK.c= $(LINK64.c) LINK.cc= $(LINK64.cc) NATIVE_CFLAGS= $(NATIVE_CFLAGS64) NATIVE_CCFLAGS= $(NATIVE_CCFLAGS64) +NATIVE_ASFLAGS= $(NATIVE_ASFLAGS64) CTF_FLAGS= $(CTF_FLAGS_64) From f40f2f085cf8ecca831ce8866e47dcbe39fa3e7c Mon Sep 17 00:00:00 2001 From: Richard Lowe Date: Thu, 4 Jul 2024 21:43:19 +0000 Subject: [PATCH 2/7] 16570 tools svccfg could be built more normally (fix libscf) --- usr/src/tools/svc/libscf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/src/tools/svc/libscf/Makefile b/usr/src/tools/svc/libscf/Makefile index 5648b906a3b..aed4618982b 100644 --- a/usr/src/tools/svc/libscf/Makefile +++ b/usr/src/tools/svc/libscf/Makefile @@ -29,7 +29,7 @@ include $(SRC)/lib/libscf/Makefile.shared.com SRCDIR = $(SRC)/lib/libscf/common COMDIR = $(SRC)/common/svc -LIBUUTIL = ../libuutil +LIBUUTIL = $(SRC)/lib/libuutil/ CPPFLAGS += -DNATIVE_BUILD $(DTEXTDOM) \ -I$(SRC)/lib/libscf/inc -I$(COMDIR) -I$(LIBUUTIL)/common From be110a578e894046e2e5313de9bd967606e34e8c Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 10 Jun 2022 13:01:46 -0400 Subject: [PATCH 3/7] 14736 zfs: Improve sorted scan memory accounting Reviewed by: Toomas Soome Reviewed by: Gordon Ross Approved by: Robert Mustacchi --- usr/src/uts/common/fs/zfs/dsl_scan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr/src/uts/common/fs/zfs/dsl_scan.c b/usr/src/uts/common/fs/zfs/dsl_scan.c index 6359b180ffb..1d34b5f7d53 100644 --- a/usr/src/uts/common/fs/zfs/dsl_scan.c +++ b/usr/src/uts/common/fs/zfs/dsl_scan.c @@ -1241,9 +1241,12 @@ dsl_scan_should_clear(dsl_scan_t *scn) mutex_enter(&tvd->vdev_scan_io_queue_lock); queue = tvd->vdev_scan_io_queue; if (queue != NULL) { - /* # extents in exts_by_size = # in exts_by_addr */ + /* + * # of extents in exts_by_size = # in exts_by_addr. + * B-tree efficiency is ~75%, but can be as low as 50%. + */ mused += zfs_btree_numnodes(&queue->q_exts_by_size) * - sizeof (range_seg_gap_t) + queue->q_sio_memused; + 3 * sizeof (range_seg_gap_t) + queue->q_sio_memused; } mutex_exit(&tvd->vdev_scan_io_queue_lock); } From f657d0ee09408a17fec39ba31acbf81446fcad47 Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Sat, 6 Jul 2024 21:47:16 +0000 Subject: [PATCH 4/7] 16641 svccfg(8) has markup leaking into the rendering Reviewed by: Peter Tribble Reviewed by: Dominik Hassler Approved by: Robert Mustacchi --- usr/src/man/man8/svccfg.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/src/man/man8/svccfg.8 b/usr/src/man/man8/svccfg.8 index 3b1aa5b443c..156e1e6fb29 100644 --- a/usr/src/man/man8/svccfg.8 +++ b/usr/src/man/man8/svccfg.8 @@ -359,7 +359,7 @@ flag is specified. If a service or service instance has a .Dq dependents property group of type -Dq framework , +.Dq framework , then for each of its properties with type .Dq astring or From b208366a8d213438f976f410282f05cd0ab98057 Mon Sep 17 00:00:00 2001 From: Robert Mustacchi Date: Mon, 8 Jul 2024 02:59:56 +0000 Subject: [PATCH 5/7] 16644 tools libscf should not depend on libzonecfg.h Reviewed by: Toomas Soome Reviewed by: Andy Fiddaman Reviewed by: Andrew Stormont Reviewed by: Dale Ghent Approved by: Dan McDonald --- usr/src/lib/libscf/common/lowlevel.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/usr/src/lib/libscf/common/lowlevel.c b/usr/src/lib/libscf/common/lowlevel.c index ce0c1cb459a..ea39f6ed54b 100644 --- a/usr/src/lib/libscf/common/lowlevel.c +++ b/usr/src/lib/libscf/common/lowlevel.c @@ -54,7 +54,9 @@ #include #include #include +#ifndef NATIVE_BUILD #include +#endif /* !NATIVE_BUILD */ #include #include @@ -900,6 +902,12 @@ scf_handle_decorate(scf_handle_t *handle, const char *name, scf_value_t *v) return (0); } +/* + * To simplify the tools bootstrap, because the tools svccfg is only operating + * on local files, we remove the ability for it to call into libzonecfg as there + * is no need to find a repository in another zone. + */ +#ifndef NATIVE_BUILD if (strcmp(name, "zone") == 0) { char zone[MAXPATHLEN], root[MAXPATHLEN], door[MAXPATHLEN]; static int (*zone_get_rootpath)(char *, char *, size_t); @@ -966,6 +974,7 @@ scf_handle_decorate(scf_handle_t *handle, const char *name, scf_value_t *v) return (0); } +#endif /* !NATIVE_BUILD */ return (scf_set_error(SCF_ERROR_INVALID_ARGUMENT)); } From 3cf6ec9c119d42bc30a5c1b2ac1e160eba0ffc9b Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 25 Apr 2020 10:04:34 +0800 Subject: [PATCH 6/7] 15514 zfs: zfs_do_create: round up volume size to multiple of bs Reviewed by: Marco van Wieringen Approved by: Dan McDonald --- usr/src/cmd/zfs/zfs_main.c | 26 +++++++++++++++++++ usr/src/man/man8/zfs.8 | 3 +-- .../cli_root/zfs_create/zfs_create.cfg | 8 +++++- .../zfs_create/zfs_create_002_pos.ksh | 16 ++++++++++-- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/usr/src/cmd/zfs/zfs_main.c b/usr/src/cmd/zfs/zfs_main.c index 72ea6320ceb..0237422a27a 100644 --- a/usr/src/cmd/zfs/zfs_main.c +++ b/usr/src/cmd/zfs/zfs_main.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -990,6 +991,31 @@ zfs_do_create(int argc, char **argv) } } + /* + * if volsize is not a multiple of volblocksize, round it up to the + * nearest multiple of the volblocksize + */ + if (type == ZFS_TYPE_VOLUME) { + uint64_t volblocksize; + + if (nvlist_lookup_uint64(props, + zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), + &volblocksize) != 0) + volblocksize = ZVOL_DEFAULT_BLOCKSIZE; + + if (volsize % volblocksize) { + volsize = P2ROUNDUP_TYPED(volsize, volblocksize, + uint64_t); + + if (nvlist_add_uint64(props, + zfs_prop_to_name(ZFS_PROP_VOLSIZE), volsize) != 0) { + nvlist_free(props); + nomem(); + } + } + } + + if (type == ZFS_TYPE_VOLUME && !noreserve) { uint64_t spa_version; zfs_prop_t resv_prop; diff --git a/usr/src/man/man8/zfs.8 b/usr/src/man/man8/zfs.8 index 25e2f89659f..a971637bbb8 100644 --- a/usr/src/man/man8/zfs.8 +++ b/usr/src/man/man8/zfs.8 @@ -2343,8 +2343,7 @@ The size represents the logical size as exported by the device. By default, a reservation of equal size is created. .Pp .Ar size -is automatically rounded up to the nearest 128 Kbytes to ensure that the volume -has an integral number of blocks regardless of +is automatically rounded up to the nearest multiple of the .Sy blocksize . .Bl -tag -width "-b" .It Fl b Ar blocksize diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create.cfg b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create.cfg index b96908ce12c..9bf25327ef8 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create.cfg +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create.cfg @@ -54,6 +54,12 @@ export VOL_LIMIT_KEYWORD1="1TB on 32-bit" export VOL_LIMIT_KEYWORD2="value is too large" export VOL_LIMIT_KEYWORD3="volume size exceeds limit" -set -A size "8k" "8K" "1m" "1M" "1mb" "1mB" "1Mb" "1MB" "1g" "1G" \ +set -A size "8k" "8K" "35K" "1m" "1M" "1mb" "1mB" "1Mb" "1MB" "1g" "1G" \ "1p" "1P" "1z" "1Z" "1gb" "1gB" "1Gb" "1GB" "1pb" "1pB" "1Pb" \ "1PB" "1zb" "1zB" "1Zb" "1ZB" + +# If a datasize has a volume size that is not a multiple of the blocksize, +# explicitly check that its size has been rounded up to the nearest multiple +# The volume with the exact size must exist in the "size" array above +set -A explicit_size_check "35K" +set -A expected_rounded_size "40960" diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh index 2498e4a4c9f..1f60445d56c 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh @@ -31,6 +31,7 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/cli_root/zfs_create/zfs_create.cfg +. $STF_SUITE/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib # # DESCRIPTION: @@ -39,6 +40,8 @@ # STRATEGY: # 1. Create a volume in the storage pool. # 2. Verify the volume is created correctly. +# 3. Verify that the volume created has its volsize rounded to the nearest +# multiple of the blocksize (in this case, the default blocksize) # verify_runnable "global" @@ -46,7 +49,7 @@ verify_runnable "global" function cleanup { typeset -i j=0 - while [[ $j -lt ${#size[*]} ]]; do + while (( j < ${#size[*]} )); do if datasetexists $TESTPOOL/${TESTVOL}${size[j]}; then log_must zfs destroy $TESTPOOL/${TESTVOL}${size[j]} fi @@ -60,7 +63,7 @@ log_onexit cleanup log_assert "'zfs create -s -V ' succeeds" typeset -i j=0 -while (( $j < ${#size[*]} )); do +while (( j < ${#size[*]} )); do typeset cmdline="zfs create -s -V ${size[j]} \ $TESTPOOL/${TESTVOL}${size[j]}" @@ -78,6 +81,15 @@ while (( $j < ${#size[*]} )); do fi ((j = j + 1)) +done + +typeset -i j=0 +while (( j < ${#explicit_size_check[*]} )); do + propertycheck ${TESTPOOL}/${TESTVOL}${explicit_size_check[j]} \ + volsize=${expected_rounded_size[j]} || \ + log_fail "volsize ${size[j]} was not rounded up" + ((j = j + 1)) done + log_pass "'zfs create -s -V ' works as expected." From 919db99e8d8594a40e2014b640c1a36d29ce8697 Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Thu, 11 Jul 2024 17:12:33 +0000 Subject: [PATCH 7/7] 16646 Fix nvme tests after 16633 Reviewed by: Bill Sommerfeld Reviewed by: Dan McDonald Approved by: Robert Mustacchi --- usr/src/test/nvme-tests/tests/unit/firmware.c | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/usr/src/test/nvme-tests/tests/unit/firmware.c b/usr/src/test/nvme-tests/tests/unit/firmware.c index 647f55e488a..da82bccc501 100644 --- a/usr/src/test/nvme-tests/tests/unit/firmware.c +++ b/usr/src/test/nvme-tests/tests/unit/firmware.c @@ -53,7 +53,7 @@ static const nvme_unit_field_test_t firmware_field_tests[] = { { .nu_fields = nvme_fw_load_fields, .nu_index = NVME_FW_LOAD_REQ_FIELD_NUMD, .nu_data = &nvme_ctrl_base_1v0, - .nu_value = 0xfff, + .nu_value = 0xfff, /* Invalid since not a whole number of dwords */ .nu_ret = NVME_FIELD_ERR_BAD_VALUE }, { .nu_desc = "valid fw load numd 4K gran (1)", @@ -256,14 +256,7 @@ static const nvme_unit_field_test_t firmware_field_tests[] = { { .nu_fields = nvme_fw_load_fields, .nu_index = NVME_FW_LOAD_REQ_FIELD_NUMD, .nu_data = &nvme_ctrl_8kgran_1v3, - .nu_value = 0x1000, - .nu_ret = NVME_FIELD_ERR_BAD_VALUE -}, { - .nu_desc = "invalid fw load numd 8k gran (4)", - .nu_fields = nvme_fw_load_fields, - .nu_index = NVME_FW_LOAD_REQ_FIELD_NUMD, - .nu_data = &nvme_ctrl_8kgran_1v3, - .nu_value = 0x4004, + .nu_value = 0x1001, /* Invalid since not a whole number of dwords */ .nu_ret = NVME_FIELD_ERR_BAD_VALUE }, { .nu_desc = "valid fw load numd 8k gran (1)", @@ -286,6 +279,19 @@ static const nvme_unit_field_test_t firmware_field_tests[] = { { .nu_data = &nvme_ctrl_8kgran_1v3, .nu_value = 0x42000, .nu_ret = NVME_FIELD_ERR_OK +}, { + /* + * Although the spec states that the length should be consistent with + * the advertised FWUG granularity, experience has shown that not all + * drives/controllers are as picky, and so we allow lengths shorter + * than the FWUG, as long as they are a whole number of dwords. + */ + .nu_desc = "valid fw load numd 8k gran (4)", + .nu_fields = nvme_fw_load_fields, + .nu_index = NVME_FW_LOAD_REQ_FIELD_NUMD, + .nu_data = &nvme_ctrl_8kgran_1v3, + .nu_value = 0x4004, + .nu_ret = NVME_FIELD_ERR_OK }, { .nu_desc = "invalid fw load offset 8k gran (1)", .nu_fields = nvme_fw_load_fields,