Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream merge/2024071301 #1495

Merged
merged 8 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions usr/src/Makefile.master
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
1 change: 1 addition & 0 deletions usr/src/Makefile.master.64
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
26 changes: 26 additions & 0 deletions usr/src/cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <signal.h>
#include <sys/debug.h>
#include <sys/list.h>
#include <sys/sysmacros.h>
#include <sys/mkdev.h>
#include <sys/mntent.h>
#include <sys/mnttab.h>
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions usr/src/lib/libscf/common/lowlevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
#include <string.h>
#include <sys/mman.h>
#include <sys/sysmacros.h>
#ifndef NATIVE_BUILD
#include <libzonecfg.h>
#endif /* !NATIVE_BUILD */
#include <unistd.h>
#include <dlfcn.h>

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion usr/src/man/man8/svccfg.8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions usr/src/man/man8/zfs.8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions usr/src/test/nvme-tests/tests/unit/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -39,14 +40,16 @@
# 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"

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
Expand All @@ -60,7 +63,7 @@ log_onexit cleanup
log_assert "'zfs create -s -V <size> <volume>' 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]}"

Expand All @@ -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 <size> <volume>' works as expected."
2 changes: 1 addition & 1 deletion usr/src/tools/svc/libscf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions usr/src/uts/common/fs/zfs/dsl_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down