aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/module/zfs
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2020-10-01 23:28:21 +0000
committerMatt Macy <mmacy@FreeBSD.org>2020-10-01 23:28:21 +0000
commitc40487d49bde43806672a0917a7ccc5d1e6301fd (patch)
tree57d0633d07fdee5d1cf318c53be9d183d61de835 /sys/contrib/openzfs/module/zfs
parent494955366a2053888d12f741ae883b48e552ca90 (diff)
parente2228bd99047bb6a0cef0da931147b1f28f155c2 (diff)
downloadsrc-c40487d49bde43806672a0917a7ccc5d1e6301fd.tar.gz
src-c40487d49bde43806672a0917a7ccc5d1e6301fd.zip
OpenZFS: MFV 2.0-rc3-gfc5966
- Annotate FreeBSD sysctls with CTLFLAG_MPSAFE - Reduce stack usage of Lua - Don't save user FPU context in kernel threads - Add support for procfs_list - Code cleanup in zio_crypt - Add DB_RF_NOPREFETCH to dbuf_read()s in dnode.c - Drop references when skipping dmu_send due to EXDEV - Eliminate gratuitous bzeroing in dbuf_stats_hash_table_data - Fix legacy compat for platform IOCs
Notes
Notes: svn path=/head/; revision=366350
Diffstat (limited to 'sys/contrib/openzfs/module/zfs')
-rw-r--r--sys/contrib/openzfs/module/zfs/arc.c10
-rw-r--r--sys/contrib/openzfs/module/zfs/dbuf_stats.c3
-rw-r--r--sys/contrib/openzfs/module/zfs/dmu_send.c15
-rw-r--r--sys/contrib/openzfs/module/zfs/dnode.c6
-rw-r--r--sys/contrib/openzfs/module/zfs/dsl_crypt.c6
-rw-r--r--sys/contrib/openzfs/module/zfs/spa_misc.c1
-rw-r--r--sys/contrib/openzfs/module/zfs/spa_stats.c26
-rw-r--r--sys/contrib/openzfs/module/zfs/zfs_log.c23
8 files changed, 47 insertions, 43 deletions
diff --git a/sys/contrib/openzfs/module/zfs/arc.c b/sys/contrib/openzfs/module/zfs/arc.c
index 7a499298f75c..3ba198380733 100644
--- a/sys/contrib/openzfs/module/zfs/arc.c
+++ b/sys/contrib/openzfs/module/zfs/arc.c
@@ -308,6 +308,7 @@
#include <sys/aggsum.h>
#include <cityhash.h>
#include <sys/vdev_trim.h>
+#include <sys/zstd/zstd.h>
#ifndef _KERNEL
/* set with ZFS_DEBUG=watch, to enable watchpoints on frozen buffers */
@@ -4859,6 +4860,7 @@ static boolean_t
arc_reap_cb_check(void *arg, zthr_t *zthr)
{
int64_t free_memory = arc_available_memory();
+ static int reap_cb_check_counter = 0;
/*
* If a kmem reap is already active, don't schedule more. We must
@@ -4883,6 +4885,14 @@ arc_reap_cb_check(void *arg, zthr_t *zthr)
arc_no_grow = B_FALSE;
}
+ /*
+ * Called unconditionally every 60 seconds to reclaim unused
+ * zstd compression and decompression context. This is done
+ * here to avoid the need for an independent thread.
+ */
+ if (!((reap_cb_check_counter++) % 60))
+ zfs_zstd_cache_reap_now();
+
return (B_FALSE);
}
diff --git a/sys/contrib/openzfs/module/zfs/dbuf_stats.c b/sys/contrib/openzfs/module/zfs/dbuf_stats.c
index a2f3c580ee6c..12bb568a08cc 100644
--- a/sys/contrib/openzfs/module/zfs/dbuf_stats.c
+++ b/sys/contrib/openzfs/module/zfs/dbuf_stats.c
@@ -134,7 +134,8 @@ dbuf_stats_hash_table_data(char *buf, size_t size, void *data)
ASSERT3S(dsh->idx, >=, 0);
ASSERT3S(dsh->idx, <=, h->hash_table_mask);
- memset(buf, 0, size);
+ if (size)
+ buf[0] = 0;
mutex_enter(DBUF_HASH_MUTEX(h, dsh->idx));
for (db = h->hash_table[dsh->idx]; db != NULL; db = db->db_hash_next) {
diff --git a/sys/contrib/openzfs/module/zfs/dmu_send.c b/sys/contrib/openzfs/module/zfs/dmu_send.c
index 33e99c2e02ab..9480c8b75497 100644
--- a/sys/contrib/openzfs/module/zfs/dmu_send.c
+++ b/sys/contrib/openzfs/module/zfs/dmu_send.c
@@ -643,7 +643,7 @@ dump_freeobjects(dmu_send_cookie_t *dscp, uint64_t firstobj, uint64_t numobjs)
* receiving side.
*/
if (maxobj > 0) {
- if (maxobj < firstobj)
+ if (maxobj <= firstobj)
return (0);
if (maxobj < firstobj + numobjs)
@@ -663,8 +663,6 @@ dump_freeobjects(dmu_send_cookie_t *dscp, uint64_t firstobj, uint64_t numobjs)
return (SET_ERROR(EINTR));
dscp->dsc_pending_op = PENDING_NONE;
}
- if (numobjs == 0)
- numobjs = UINT64_MAX - firstobj;
if (dscp->dsc_pending_op == PENDING_FREEOBJECTS) {
/*
@@ -2686,12 +2684,15 @@ dmu_send_obj(const char *pool, uint64_t tosnap, uint64_t fromsnap,
bcopy(fromredact, dspp.fromredactsnaps, size);
}
- if (!dsl_dataset_is_before(dspp.to_ds, fromds, 0)) {
+ boolean_t is_before =
+ dsl_dataset_is_before(dspp.to_ds, fromds, 0);
+ dspp.is_clone = (dspp.to_ds->ds_dir !=
+ fromds->ds_dir);
+ dsl_dataset_rele(fromds, FTAG);
+ if (!is_before) {
+ dsl_pool_rele(dspp.dp, FTAG);
err = SET_ERROR(EXDEV);
} else {
- dspp.is_clone = (dspp.to_ds->ds_dir !=
- fromds->ds_dir);
- dsl_dataset_rele(fromds, FTAG);
err = dmu_send_impl(&dspp);
}
} else {
diff --git a/sys/contrib/openzfs/module/zfs/dnode.c b/sys/contrib/openzfs/module/zfs/dnode.c
index 30d20bfefa12..23364dbae897 100644
--- a/sys/contrib/openzfs/module/zfs/dnode.c
+++ b/sys/contrib/openzfs/module/zfs/dnode.c
@@ -1355,7 +1355,8 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag, int slots,
* We do not need to decrypt to read the dnode so it doesn't matter
* if we get the encrypted or decrypted version.
*/
- err = dbuf_read(db, NULL, DB_RF_CANFAIL | DB_RF_NO_DECRYPT);
+ err = dbuf_read(db, NULL, DB_RF_CANFAIL |
+ DB_RF_NO_DECRYPT | DB_RF_NOPREFETCH);
if (err) {
DNODE_STAT_BUMP(dnode_hold_dbuf_read);
dbuf_rele(db, FTAG);
@@ -2396,7 +2397,8 @@ dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset,
return (SET_ERROR(ESRCH));
}
error = dbuf_read(db, NULL,
- DB_RF_CANFAIL | DB_RF_HAVESTRUCT | DB_RF_NO_DECRYPT);
+ DB_RF_CANFAIL | DB_RF_HAVESTRUCT |
+ DB_RF_NO_DECRYPT | DB_RF_NOPREFETCH);
if (error) {
dbuf_rele(db, FTAG);
return (error);
diff --git a/sys/contrib/openzfs/module/zfs/dsl_crypt.c b/sys/contrib/openzfs/module/zfs/dsl_crypt.c
index 33c21e86c4d7..26d4c2fe7e33 100644
--- a/sys/contrib/openzfs/module/zfs/dsl_crypt.c
+++ b/sys/contrib/openzfs/module/zfs/dsl_crypt.c
@@ -235,11 +235,7 @@ dsl_crypto_params_create_nvlist(dcp_cmd_t cmd, nvlist_t *props,
return (0);
error:
- if (wkey != NULL)
- dsl_wrapping_key_free(wkey);
- if (dcp != NULL)
- kmem_free(dcp, sizeof (dsl_crypto_params_t));
-
+ kmem_free(dcp, sizeof (dsl_crypto_params_t));
*dcp_out = NULL;
return (ret);
}
diff --git a/sys/contrib/openzfs/module/zfs/spa_misc.c b/sys/contrib/openzfs/module/zfs/spa_misc.c
index 41f0ddbde288..04210472886c 100644
--- a/sys/contrib/openzfs/module/zfs/spa_misc.c
+++ b/sys/contrib/openzfs/module/zfs/spa_misc.c
@@ -2169,6 +2169,7 @@ spa_import_progress_init(void)
spa_import_progress_list;
procfs_list_install("zfs",
+ NULL,
"import_progress",
0644,
&spa_import_progress_list->procfs_list,
diff --git a/sys/contrib/openzfs/module/zfs/spa_stats.c b/sys/contrib/openzfs/module/zfs/spa_stats.c
index cf0be3c45dc8..c3eacc14239e 100644
--- a/sys/contrib/openzfs/module/zfs/spa_stats.c
+++ b/sys/contrib/openzfs/module/zfs/spa_stats.c
@@ -122,14 +122,11 @@ static void
spa_read_history_init(spa_t *spa)
{
spa_history_list_t *shl = &spa->spa_stats.read_history;
- char *module;
shl->size = 0;
-
- module = kmem_asprintf("zfs/%s", spa_name(spa));
-
shl->procfs_list.pl_private = shl;
- procfs_list_install(module,
+ procfs_list_install("zfs",
+ spa_name(spa),
"reads",
0600,
&shl->procfs_list,
@@ -137,8 +134,6 @@ spa_read_history_init(spa_t *spa)
spa_read_history_show_header,
spa_read_history_clear,
offsetof(spa_read_history_t, srh_node));
-
- kmem_strfree(module);
}
static void
@@ -293,14 +288,11 @@ static void
spa_txg_history_init(spa_t *spa)
{
spa_history_list_t *shl = &spa->spa_stats.txg_history;
- char *module;
shl->size = 0;
-
- module = kmem_asprintf("zfs/%s", spa_name(spa));
-
shl->procfs_list.pl_private = shl;
- procfs_list_install(module,
+ procfs_list_install("zfs",
+ spa_name(spa),
"txgs",
0644,
&shl->procfs_list,
@@ -308,8 +300,6 @@ spa_txg_history_init(spa_t *spa)
spa_txg_history_show_header,
spa_txg_history_clear,
offsetof(spa_txg_history_t, sth_node));
-
- kmem_strfree(module);
}
static void
@@ -699,14 +689,12 @@ static void
spa_mmp_history_init(spa_t *spa)
{
spa_history_list_t *shl = &spa->spa_stats.mmp_history;
- char *module;
shl->size = 0;
- module = kmem_asprintf("zfs/%s", spa_name(spa));
-
shl->procfs_list.pl_private = shl;
- procfs_list_install(module,
+ procfs_list_install("zfs",
+ spa_name(spa),
"multihost",
0644,
&shl->procfs_list,
@@ -714,8 +702,6 @@ spa_mmp_history_init(spa_t *spa)
spa_mmp_history_show_header,
spa_mmp_history_clear,
offsetof(spa_mmp_history_t, smh_node));
-
- kmem_strfree(module);
}
static void
diff --git a/sys/contrib/openzfs/module/zfs/zfs_log.c b/sys/contrib/openzfs/module/zfs/zfs_log.c
index 4eae855f4274..fb44007fefc3 100644
--- a/sys/contrib/openzfs/module/zfs/zfs_log.c
+++ b/sys/contrib/openzfs/module/zfs/zfs_log.c
@@ -584,15 +584,22 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
(wr_state == WR_COPIED ? len : 0));
lr = (lr_write_t *)&itx->itx_lr;
- DB_DNODE_ENTER(db);
- if (wr_state == WR_COPIED && dmu_read_by_dnode(DB_DNODE(db),
- off, len, lr + 1, DMU_READ_NO_PREFETCH) != 0) {
- zil_itx_destroy(itx);
- itx = zil_itx_create(txtype, sizeof (*lr));
- lr = (lr_write_t *)&itx->itx_lr;
- wr_state = WR_NEED_COPY;
+ /*
+ * For WR_COPIED records, copy the data into the lr_write_t.
+ */
+ if (wr_state == WR_COPIED) {
+ int err;
+ DB_DNODE_ENTER(db);
+ err = dmu_read_by_dnode(DB_DNODE(db), off, len, lr + 1,
+ DMU_READ_NO_PREFETCH);
+ if (err != 0) {
+ zil_itx_destroy(itx);
+ itx = zil_itx_create(txtype, sizeof (*lr));
+ lr = (lr_write_t *)&itx->itx_lr;
+ wr_state = WR_NEED_COPY;
+ }
+ DB_DNODE_EXIT(db);
}
- DB_DNODE_EXIT(db);
itx->itx_wr_state = wr_state;
lr->lr_foid = zp->z_id;