diff --git a/usr/src/Makefile.master b/usr/src/Makefile.master index 08bdc3758ba..0a6bef7c5f2 100644 --- a/usr/src/Makefile.master +++ b/usr/src/Makefile.master @@ -584,6 +584,8 @@ NATIVE_CFLAGS= $(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) \ $(CCNOREORDER) $(CCNOAGGRESSIVELOOPS) $(CCINLINESIZE) \ $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS) +NATIVE_ASFLAGS= $(NATIVE_CFLAGS) + NATIVE_CCFLAGS= $(CCOPTFLAG) $($(NATIVE_MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \ $(CCUSERFLAGS) @@ -592,6 +594,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 6b0c8d0abed..7a310f03ded 100644 --- a/usr/src/Makefile.master.64 +++ b/usr/src/Makefile.master.64 @@ -42,6 +42,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) 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/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)); } 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 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/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, 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." 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 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); }