Commit 95c6b1b6 authored by Mo Zhou's avatar Mo Zhou

Cherry-pick upstream patches (Thanks to Colin Ian King):

 + 2301-zfs-promote-rename-.-recv-should-be-an-error.patch
 + 2302-Fix-parsable-zfs-get-for-compressratios.patch
 + 2303-Fix-zpool-events-scripted-mode-tab-separator.patch
 + 2305-Allow-longer-SPA-names-in-stats.patch
 + 2308-OpenZFS-8375-Kernel-memory-leak-in-nvpair-code.patch
 + 2309-OpenZFS-7261-nvlist-code-should-enforce-name-length-.patch
 + 2310-OpenZFS-5778-nvpair_type_is_array-does-not-recognize.patch
 + 2313-Fix-printk-calls-missing-log-level.patch
 + 2314-Fix-abdstats-kstat-on-32-bit-systems.patch
 + 2316-Fix-coverity-defects-147480-147584.patch
 + 2317-Fix-coverity-defects-CID-161388.patch
 + 2318-Use-ashift-12-by-default-on-SSDSC2BW48-disks.patch
 + 2319-OpenZFS-8558-8602-lwp_create-returns-EAGAIN.patch
 + 2320-ZFS-send-fails-to-dump-objects-larger-than-128PiB.patch
 + 2323-Fix-segfault-in-zpool-iostat-when-adding-VDEVs.patch
 + 2328-Fix-fsanitize-address-memory-leak.patch
 + 2331-OpenZFS-8897-zpool-online-e-fails-assertion-when-run.patch
 + 2332-OpenZFS-8898-creating-fs-with-checksum-skein-on-the-.patch
 + 2334-OpenZFS-8641-zpool-clear-and-zinject-don-t-work-on-s.patch
 + 2336-OpenZFS-8972-zfs-holds-In-scripted-mode-do-not-pad-c.patch
 + 2337-Revert-Remove-wrong-ASSERT-in-annotate_ecksum.patch
 + 2338-OpenZFS-8731-ASSERT3U-nui64s-UINT16_MAX-fails-for-la.patch
 + 2339-Prevent-zdb-8-from-occasionally-hanging-on-I-O.patch
 + 2341-Change-movaps-to-movups-in-AES-NI-code.patch
 + 3203-Fix-zpool-create-t-tempname.patch

Gbp-Dch: Full
parent 66a59c35
Pipeline #34622 failed with stages
in 22 minutes and 56 seconds
From 650258d7c786b8e62ca847a926f6f038cd3e5d94 Mon Sep 17 00:00:00 2001
From: LOLi <loli10K@users.noreply.github.com>
Date: Fri, 28 Jul 2017 23:12:34 +0200
Subject: [PATCH] zfs promote|rename .../%recv should be an error
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
If we are in the middle of an incremental 'zfs receive', the child
.../%recv will exist. If we run 'zfs promote' .../%recv, it will "work",
but then zfs gets confused about the status of the new dataset.
Attempting to do this promote should be an error.
Similarly renaming .../%recv datasets should not be allowed.
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #4843
Closes #6339
---
lib/libzfs/libzfs_dataset.c | 7 +++++
module/zfs/zfs_ioctl.c | 12 ++++++--
tests/zfs-tests/include/libtest.shlib | 35 ++++++++++++++++++++++
.../cli_root/zfs_promote/zfs_promote_006_neg.ksh | 15 ++++++----
.../functional/cli_root/zfs_rename/zfs_rename.cfg | 1 +
.../cli_root/zfs_rename/zfs_rename.kshlib | 5 ++++
.../cli_root/zfs_rename/zfs_rename_004_neg.ksh | 4 +--
7 files changed, 70 insertions(+), 9 deletions(-)
Index: zfs-linux-0.7.11/lib/libzfs/libzfs_dataset.c
===================================================================
--- zfs-linux-0.7.11.orig/lib/libzfs/libzfs_dataset.c
+++ zfs-linux-0.7.11/lib/libzfs/libzfs_dataset.c
@@ -3761,6 +3761,9 @@ zfs_promote(zfs_handle_t *zhp)
return (zfs_error(hdl, EZFS_BADTYPE, errbuf));
}
+ if (!zfs_validate_name(hdl, zhp->zfs_name, zhp->zfs_type, B_TRUE))
+ return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
+
ret = lzc_promote(zhp->zfs_name, snapname, sizeof (snapname));
if (ret != 0) {
@@ -4090,6 +4093,10 @@ zfs_rename(zfs_handle_t *zhp, const char
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
"cannot rename to '%s'"), target);
+ /* make sure source name is valid */
+ if (!zfs_validate_name(hdl, zhp->zfs_name, zhp->zfs_type, B_TRUE))
+ return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
+
/*
* Make sure the target name is valid
*/
Index: zfs-linux-0.7.11/module/zfs/zfs_ioctl.c
===================================================================
--- zfs-linux-0.7.11.orig/module/zfs/zfs_ioctl.c
+++ zfs-linux-0.7.11/module/zfs/zfs_ioctl.c
@@ -3738,9 +3738,12 @@ zfs_ioc_rename(zfs_cmd_t *zc)
boolean_t recursive = zc->zc_cookie & 1;
char *at;
+ /* "zfs rename" from and to ...%recv datasets should both fail */
+ zc->zc_name[sizeof (zc->zc_name) - 1] = '\0';
zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
- if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
- strchr(zc->zc_value, '%'))
+ if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 ||
+ dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
+ strchr(zc->zc_name, '%') || strchr(zc->zc_value, '%'))
return (SET_ERROR(EINVAL));
at = strchr(zc->zc_name, '@');
@@ -4993,6 +4996,11 @@ zfs_ioc_promote(zfs_cmd_t *zc)
char *cp;
int error;
+ zc->zc_name[sizeof (zc->zc_name) - 1] = '\0';
+ if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 ||
+ strchr(zc->zc_name, '%'))
+ return (SET_ERROR(EINVAL));
+
error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
if (error != 0)
return (error);
Index: zfs-linux-0.7.11/tests/zfs-tests/include/libtest.shlib
===================================================================
--- zfs-linux-0.7.11.orig/tests/zfs-tests/include/libtest.shlib
+++ zfs-linux-0.7.11/tests/zfs-tests/include/libtest.shlib
@@ -351,6 +351,41 @@ function create_bookmark
log_must zfs bookmark $fs_vol@$snap $fs_vol#$bkmark
}
+#
+# Create a temporary clone result of an interrupted resumable 'zfs receive'
+# $1 Destination filesystem name. Must not exist, will be created as the result
+# of this function along with its %recv temporary clone
+# $2 Source filesystem name. Must not exist, will be created and destroyed
+#
+function create_recv_clone
+{
+ typeset recvfs="$1"
+ typeset sendfs="${2:-$TESTPOOL/create_recv_clone}"
+ typeset snap="$sendfs@snap1"
+ typeset incr="$sendfs@snap2"
+ typeset mountpoint="$TESTDIR/create_recv_clone"
+ typeset sendfile="$TESTDIR/create_recv_clone.zsnap"
+
+ [[ -z $recvfs ]] && log_fail "Recv filesystem's name is undefined."
+
+ datasetexists $recvfs && log_fail "Recv filesystem must not exist."
+ datasetexists $sendfs && log_fail "Send filesystem must not exist."
+
+ log_must zfs create -o mountpoint="$mountpoint" $sendfs
+ log_must zfs snapshot $snap
+ log_must eval "zfs send $snap | zfs recv -u $recvfs"
+ log_must mkfile 1m "$mountpoint/data"
+ log_must zfs snapshot $incr
+ log_must eval "zfs send -i $snap $incr | dd bs=10K count=1 > $sendfile"
+ log_mustnot eval "zfs recv -su $recvfs < $sendfile"
+ log_must zfs destroy -r $sendfs
+ log_must rm -f "$sendfile"
+
+ if [[ $(get_prop 'inconsistent' "$recvfs/%recv") -ne 1 ]]; then
+ log_fail "Error creating temporary $recvfs/%recv clone"
+ fi
+}
+
function default_mirror_setup
{
default_mirror_setup_noexit $1 $2 $3
Index: zfs-linux-0.7.11/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh
===================================================================
--- zfs-linux-0.7.11.orig/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh
+++ zfs-linux-0.7.11/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh
@@ -40,6 +40,7 @@
# pool, fs, snapshot,volume
# (4) too many arguments.
# (5) invalid options
+# (6) temporary %recv datasets
#
# STRATEGY:
# 1. Create an array of invalid arguments
@@ -50,11 +51,14 @@
verify_runnable "both"
snap=$TESTPOOL/$TESTFS@$TESTSNAP
+clone=$TESTPOOL/$TESTCLONE
+recvfs=$TESTPOOL/recvfs
set -A args "" \
"$TESTPOOL/blah" \
"$TESTPOOL" "$TESTPOOL/$TESTFS" "$snap" \
"$TESTPOOL/$TESTVOL" "$TESTPOOL $TESTPOOL/$TESTFS" \
- "$clone $TESTPOOL/$TESTFS" "- $clone" "-? $clone"
+ "$clone $TESTPOOL/$TESTFS" "- $clone" "-? $clone" \
+ "$recvfs/%recv"
function cleanup
{
@@ -62,6 +66,10 @@ function cleanup
log_must zfs destroy $clone
fi
+ if datasetexists $recvfs; then
+ log_must zfs destroy -r $recvfs
+ fi
+
if snapexists $snap; then
destroy_snapshot $snap
fi
@@ -70,10 +78,7 @@ function cleanup
log_assert "'zfs promote' will fail with invalid arguments. "
log_onexit cleanup
-snap=$TESTPOOL/$TESTFS@$TESTSNAP
-clone=$TESTPOOL/$TESTCLONE
-log_must zfs snapshot $snap
-log_must zfs clone $snap $clone
+create_recv_clone $recvfs
typeset -i i=0
while (( i < ${#args[*]} )); do
Index: zfs-linux-0.7.11/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg
===================================================================
--- zfs-linux-0.7.11.orig/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg
+++ zfs-linux-0.7.11/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg
@@ -36,3 +36,4 @@ export BS=512
export CNT=2048
export VOL_R_PATH=$ZVOL_RDEVDIR/$TESTPOOL/$TESTVOL
export VOLDATA=$TESTDIR2/voldata.rename
+export RECVFS=recvfs
Index: zfs-linux-0.7.11/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib
===================================================================
--- zfs-linux-0.7.11.orig/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib
+++ zfs-linux-0.7.11/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib
@@ -63,6 +63,8 @@ function additional_setup
log_must cp $DATA $(get_prop mountpoint $TESTPOOL/$TESTVOL)/$TESTFILE0
fi
+ # Create temporary %recv clone
+ create_recv_clone $TESTPOOL/$RECVFS
}
function rename_dataset # src dest
@@ -110,6 +112,9 @@ function cleanup
log_must zfs destroy -fR $TESTPOOL/$TESTFS@snapshot
fi
+ if datasetexists $TESTPOOL/$RECVFS; then
+ log_must zfs destroy -r $TESTPOOL/$RECVFS
+ fi
}
function cmp_data #<$1 src data, $2 tgt data>
Index: zfs-linux-0.7.11/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh
===================================================================
--- zfs-linux-0.7.11.orig/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh
+++ zfs-linux-0.7.11/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh
@@ -77,8 +77,8 @@ set -A bad_dataset $TESTPOOL/$TESTFS1 $T
$TESTPOOL/$TESTFS1 $TESTPOOL/${TESTFS1}%x \
$TESTPOOL/$TESTFS1 $TESTPOOL/${TESTFS1}%p \
$TESTPOOL/$TESTFS1 $TESTPOOL/${TESTFS1}%s \
- $TESTPOOL/$TESTFS@snapshot \
- $TESTPOOL/$TESTFS@snapshot/fs
+ $TESTPOOL/$TESTFS@snapshot $TESTPOOL/$TESTFS@snapshot/fs \
+ $TESTPOOL/$RECVFS/%recv $TESTPOOL/renamed.$$
#
# cleanup defined in zfs_rename.kshlib
From b0bd8ffecd70b46e584e2e52ea74f2373b544217 Mon Sep 17 00:00:00 2001
From: LOLi <loli10K@users.noreply.github.com>
Date: Thu, 3 Aug 2017 18:43:17 +0200
Subject: [PATCH] Fix parsable 'zfs get' for compressratios
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
This is consistent with the change introduced in bc2d809 where
'zpool get -p dedupratio' does not add a trailing "x" to the output.
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #6436
Closes #6449
---
lib/libzfs/libzfs_dataset.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
Index: zfs-linux-0.7.9/lib/libzfs/libzfs_dataset.c
===================================================================
--- zfs-linux-0.7.9.orig/lib/libzfs/libzfs_dataset.c
+++ zfs-linux-0.7.9/lib/libzfs/libzfs_dataset.c
@@ -2611,9 +2611,14 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop
case ZFS_PROP_COMPRESSRATIO:
if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
return (-1);
- (void) snprintf(propbuf, proplen, "%llu.%02llux",
- (u_longlong_t)(val / 100),
- (u_longlong_t)(val % 100));
+ if (literal)
+ (void) snprintf(propbuf, proplen, "%llu.%02llu",
+ (u_longlong_t)(val / 100),
+ (u_longlong_t)(val % 100));
+ else
+ (void) snprintf(propbuf, proplen, "%llu.%02llux",
+ (u_longlong_t)(val / 100),
+ (u_longlong_t)(val % 100));
break;
case ZFS_PROP_TYPE:
From 1e1c398033384106c8ee96435ba0683797b41a46 Mon Sep 17 00:00:00 2001
From: Sen Haerens <sen@senhaerens.be>
Date: Thu, 3 Aug 2017 18:56:15 +0200
Subject: [PATCH] Fix zpool events scripted mode tab separator
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Sen Haerens <sen@senhaerens.be>
Closes #6444
Closes #6445
---
cmd/zpool/zpool_main.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Index: zfs-linux-0.7.11/cmd/zpool/zpool_main.c
===================================================================
--- zfs-linux-0.7.11.orig/cmd/zpool/zpool_main.c
+++ zfs-linux-0.7.11/cmd/zpool/zpool_main.c
@@ -7358,7 +7358,7 @@ typedef struct ev_opts {
} ev_opts_t;
static void
-zpool_do_events_short(nvlist_t *nvl)
+zpool_do_events_short(nvlist_t *nvl, ev_opts_t *opts)
{
char ctime_str[26], str[32], *ptr;
int64_t *tv;
@@ -7371,7 +7371,10 @@ zpool_do_events_short(nvlist_t *nvl)
(void) strncpy(str+7, ctime_str+20, 4); /* '1993' */
(void) strncpy(str+12, ctime_str+11, 8); /* '21:49:08' */
(void) sprintf(str+20, ".%09lld", (longlong_t)tv[1]); /* '.123456789' */
- (void) printf(gettext("%s "), str);
+ if (opts->scripted)
+ (void) printf(gettext("%s\t"), str);
+ else
+ (void) printf(gettext("%s "), str);
verify(nvlist_lookup_string(nvl, FM_CLASS, &ptr) == 0);
(void) printf(gettext("%s\n"), ptr);
@@ -7635,7 +7638,7 @@ zpool_do_events_next(ev_opts_t *opts)
if (dropped > 0)
(void) printf(gettext("dropped %d events\n"), dropped);
- zpool_do_events_short(nvl);
+ zpool_do_events_short(nvl, opts);
if (opts->verbose) {
zpool_do_events_nvprint(nvl, 8);
From 761b8ec6bf98f39550353173ad7bec5306073f9c Mon Sep 17 00:00:00 2001
From: gaurkuma <gaurkuma@users.noreply.github.com>
Date: Fri, 11 Aug 2017 08:56:24 -0700
Subject: [PATCH] Allow longer SPA names in stats
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
The pool name can be 256 chars long. Today, in /proc/spl/kstat/zfs/
the name is limited to < 32 characters. This change is to allows
bigger pool names.
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: gaurkuma <gauravk.18@gmail.com>
Closes #6481
---
lib/libspl/include/sys/kstat.h | 2 +-
module/icp/spi/kcf_spi.c | 11 ++++++-----
module/zfs/spa_stats.c | 25 +++++++++++++++----------
3 files changed, 22 insertions(+), 16 deletions(-)
Index: zfs-linux-0.7.11/lib/libspl/include/sys/kstat.h
===================================================================
--- zfs-linux-0.7.11.orig/lib/libspl/include/sys/kstat.h
+++ zfs-linux-0.7.11/lib/libspl/include/sys/kstat.h
@@ -59,7 +59,7 @@ typedef int kid_t; /* unique kstat id *
* kcid = ioctl(kd, KSTAT_IOC_WRITE, kstat_t *);
*/
-#define KSTAT_STRLEN 31 /* 30 chars + NULL; must be 16 * n - 1 */
+#define KSTAT_STRLEN 255 /* 254 chars + NULL; must be 16 * n - 1 */
/*
* The generic kstat header
Index: zfs-linux-0.7.11/module/icp/spi/kcf_spi.c
===================================================================
--- zfs-linux-0.7.11.orig/module/icp/spi/kcf_spi.c
+++ zfs-linux-0.7.11/module/icp/spi/kcf_spi.c
@@ -111,7 +111,7 @@ int
crypto_register_provider(crypto_provider_info_t *info,
crypto_kcf_provider_handle_t *handle)
{
- char ks_name[KSTAT_STRLEN];
+ char *ks_name;
kcf_provider_desc_t *prov_desc = NULL;
int ret = CRYPTO_ARGUMENTS_BAD;
@@ -238,12 +238,12 @@ crypto_register_provider(crypto_provider
* This kstat is deleted, when the provider unregisters.
*/
if (prov_desc->pd_prov_type == CRYPTO_SW_PROVIDER) {
- (void) snprintf(ks_name, KSTAT_STRLEN, "%s_%s",
+ ks_name = kmem_asprintf("%s_%s",
"NONAME", "provider_stats");
} else {
- (void) snprintf(ks_name, KSTAT_STRLEN, "%s_%d_%u_%s",
- "NONAME", 0,
- prov_desc->pd_prov_id, "provider_stats");
+ ks_name = kmem_asprintf("%s_%d_%u_%s",
+ "NONAME", 0, prov_desc->pd_prov_id,
+ "provider_stats");
}
prov_desc->pd_kstat = kstat_create("kcf", 0, ks_name, "crypto",
@@ -261,6 +261,7 @@ crypto_register_provider(crypto_provider
prov_desc->pd_kstat->ks_update = kcf_prov_kstat_update;
kstat_install(prov_desc->pd_kstat);
}
+ strfree(ks_name);
}
if (prov_desc->pd_prov_type == CRYPTO_HW_PROVIDER)
Index: zfs-linux-0.7.11/module/zfs/spa_stats.c
===================================================================
--- zfs-linux-0.7.11.orig/module/zfs/spa_stats.c
+++ zfs-linux-0.7.11/module/zfs/spa_stats.c
@@ -144,7 +144,7 @@ static void
spa_read_history_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.read_history;
- char name[KSTAT_STRLEN];
+ char *name;
kstat_t *ksp;
mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL);
@@ -155,7 +155,7 @@ spa_read_history_init(spa_t *spa)
ssh->size = 0;
ssh->private = NULL;
- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
+ name = kmem_asprintf("zfs/%s", spa_name(spa));
ksp = kstat_create(name, 0, "reads", "misc",
KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL);
@@ -170,6 +170,7 @@ spa_read_history_init(spa_t *spa)
spa_read_history_data, spa_read_history_addr);
kstat_install(ksp);
}
+ strfree(name);
}
static void
@@ -367,7 +368,7 @@ static void
spa_txg_history_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.txg_history;
- char name[KSTAT_STRLEN];
+ char *name;
kstat_t *ksp;
mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL);
@@ -378,7 +379,7 @@ spa_txg_history_init(spa_t *spa)
ssh->size = 0;
ssh->private = NULL;
- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
+ name = kmem_asprintf("zfs/%s", spa_name(spa));
ksp = kstat_create(name, 0, "txgs", "misc",
KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL);
@@ -393,6 +394,7 @@ spa_txg_history_init(spa_t *spa)
spa_txg_history_data, spa_txg_history_addr);
kstat_install(ksp);
}
+ strfree(name);
}
static void
@@ -600,7 +602,7 @@ static void
spa_tx_assign_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.tx_assign_histogram;
- char name[KSTAT_STRLEN];
+ char *name;
kstat_named_t *ks;
kstat_t *ksp;
int i;
@@ -611,7 +613,7 @@ spa_tx_assign_init(spa_t *spa)
ssh->size = ssh->count * sizeof (kstat_named_t);
ssh->private = kmem_alloc(ssh->size, KM_SLEEP);
- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
+ name = kmem_asprintf("zfs/%s", spa_name(spa));
for (i = 0; i < ssh->count; i++) {
ks = &((kstat_named_t *)ssh->private)[i];
@@ -634,6 +636,7 @@ spa_tx_assign_init(spa_t *spa)
ksp->ks_update = spa_tx_assign_update;
kstat_install(ksp);
}
+ strfree(name);
}
static void
@@ -680,12 +683,12 @@ static void
spa_io_history_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.io_history;
- char name[KSTAT_STRLEN];
+ char *name;
kstat_t *ksp;
mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL);
- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
+ name = kmem_asprintf("zfs/%s", spa_name(spa));
ksp = kstat_create(name, 0, "io", "disk", KSTAT_TYPE_IO, 1, 0);
ssh->kstat = ksp;
@@ -696,6 +699,7 @@ spa_io_history_init(spa_t *spa)
ksp->ks_update = spa_io_history_update;
kstat_install(ksp);
}
+ strfree(name);
}
static void
@@ -825,7 +829,7 @@ static void
spa_mmp_history_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.mmp_history;
- char name[KSTAT_STRLEN];
+ char *name;
kstat_t *ksp;
mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL);
@@ -836,7 +840,7 @@ spa_mmp_history_init(spa_t *spa)
ssh->size = 0;
ssh->private = NULL;
- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
+ name = kmem_asprintf("zfs/%s", spa_name(spa));
ksp = kstat_create(name, 0, "multihost", "misc",
KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL);
@@ -851,6 +855,7 @@ spa_mmp_history_init(spa_t *spa)
spa_mmp_history_data, spa_mmp_history_addr);
kstat_install(ksp);
}
+ strfree(name);
}
static void
From 006309e8d75b22efc7418095e408b3b3774ef8ea Mon Sep 17 00:00:00 2001
From: Matthew Ahrens <mahrens@delphix.com>
Date: Mon, 3 Apr 2017 09:47:11 -0700
Subject: [PATCH] OpenZFS 8375 - Kernel memory leak in nvpair code
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Prashanth Sreenivasa <pks@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Reviewed-by: Don Brady <dev.fs.zfs@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/8375
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/843c211
Closes #6578
---
module/nvpair/nvpair.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c
index 2e3820981..8e654053c 100644
--- a/module/nvpair/nvpair.c
+++ b/module/nvpair/nvpair.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015, 2016 by Delphix. All rights reserved.
+ * Copyright (c) 2015, 2017 by Delphix. All rights reserved.
*/
#include <sys/stropts.h>
@@ -2200,8 +2200,10 @@ nvs_embedded(nvstream_t *nvs, nvlist_t *embedded)
nvlist_init(embedded, embedded->nvl_nvflag, priv);
- if (nvs->nvs_recursion >= nvpair_max_recursion)
+ if (nvs->nvs_recursion >= nvpair_max_recursion) {
+ nvlist_free(embedded);
return (EINVAL);
+ }
nvs->nvs_recursion++;
if ((err = nvs_operation(nvs, embedded, NULL)) != 0)
nvlist_free(embedded);
--
2.15.1
From 24ded86e8dd528b056d73630ff33e526f9540dbc Mon Sep 17 00:00:00 2001
From: Matthew Ahrens <mahrens@delphix.com>
Date: Thu, 4 Aug 2016 16:16:29 -0700
Subject: [PATCH] OpenZFS 7261 - nvlist code should enforce name length limit
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
Reviewed-by: Don Brady <dev.fs.zfs@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7261
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/48dd5e6
Closes #6579
---
module/nvpair/nvpair.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c
index 8e654053c..dffb226a2 100644
--- a/module/nvpair/nvpair.c
+++ b/module/nvpair/nvpair.c
@@ -916,6 +916,8 @@ nvlist_add_common(nvlist_t *nvl, const char *name,
/* calculate sizes of the nvpair elements and the nvpair itself */
name_sz = strlen(name) + 1;
+ if (name_sz >= 1ULL << (sizeof (nvp->nvp_name_sz) * NBBY - 1))
+ return (EINVAL);
nvp_sz = NVP_SIZE_CALC(name_sz, value_sz);
--
2.15.1
From ecaebdbcf693d9f08844e04dc97f6859b7c37c80 Mon Sep 17 00:00:00 2001
From: Andriy Gapon <avg@icyb.net.ua>
Date: Thu, 12 Nov 2015 11:23:37 -0800
Subject: [PATCH] OpenZFS 5778 - nvpair_type_is_array() does not recognize
DATA_TYPE_INT8_ARRAY
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Authored by: Andriy Gapon <avg@icyb.net.ua>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>
Reviewed-by: Don Brady <dev.fs.zfs@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/5778
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/bf4d553
Closes #6580
---
module/nvpair/nvpair.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c
index dffb226a2..24ef61e93 100644
--- a/module/nvpair/nvpair.c
+++ b/module/nvpair/nvpair.c
@@ -1244,6 +1244,7 @@ nvpair_type_is_array(nvpair_t *nvp)
data_type_t type = NVP_TYPE(nvp);
if ((type == DATA_TYPE_BYTE_ARRAY) ||
+ (type == DATA_TYPE_INT8_ARRAY) ||
(type == DATA_TYPE_UINT8_ARRAY) ||
(type == DATA_TYPE_INT16_ARRAY) ||
(type == DATA_TYPE_UINT16_ARRAY) ||
--
2.15.1
From 7e98073379353a05498ac5a2f1a5df2a2257d6b0 Mon Sep 17 00:00:00 2001
From: DeHackEd <DeHackEd@users.noreply.github.com>
Date: Mon, 25 Sep 2017 13:38:27 -0400
Subject: [PATCH] Fix printk() calls missing log level
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: DHE <git@dehacked.net>
Closes #6672
---
module/zfs/vdev_disk.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Index: zfs-linux-0.7.11/module/zfs/vdev_disk.c
===================================================================
--- zfs-linux-0.7.11.orig/module/zfs/vdev_disk.c
+++ zfs-linux-0.7.11/module/zfs/vdev_disk.c
@@ -99,7 +99,7 @@ static void
vdev_disk_error(zio_t *zio)
{
#ifdef ZFS_DEBUG
- printk("ZFS: zio error=%d type=%d offset=%llu size=%llu "
+ printk(KERN_WARNING "ZFS: zio error=%d type=%d offset=%llu size=%llu "
"flags=%x\n", zio->io_error, zio->io_type,
(u_longlong_t)zio->io_offset, (u_longlong_t)zio->io_size,
zio->io_flags);
From 57f4ef2e819670f8b28760b32745e0729f8d80d7 Mon Sep 17 00:00:00 2001
From: Brian Behlendorf <behlendorf1@llnl.gov>
Date: Fri, 6 Oct 2017 11:23:12 -0700
Subject: [PATCH] Fix abdstats kstat on 32-bit systems
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
When decrementing the struct_size and scatter_chunk_waste kstats
the value needs to be cast to an int on 32-bit systems.
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #6721
---