aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/module
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2021-03-03 01:15:33 +0000
committerMartin Matuska <mm@FreeBSD.org>2021-03-03 01:15:33 +0000
commitcaed7b1c399de04279822028e15b36367e84232f (patch)
tree11a8e01977837b40590b640f9bb404a5aca4ee85 /sys/contrib/openzfs/module
parentdf3747c6607be12d48db825653e6adfc3041e97f (diff)
parent154ce66101db0e1a9c90a94e391612b2ab8c048f (diff)
downloadsrc-caed7b1c399de04279822028e15b36367e84232f.tar.gz
src-caed7b1c399de04279822028e15b36367e84232f.zip
zfs: merge OpenZFS master-bedbc13da
Notable upstream commits: 8e43fa12c Fix vdev_rebuild_thread deadlock 03ef8f09e Add missing checks for unsupported features 2e160dee9 Fix assert in FreeBSD-specific dmu_read_pages bedbc13da Cancel TRIM / initialize on FAULTED non-writeable vdevs MFC after: 1 week Obtained from: OpenZFS
Diffstat (limited to 'sys/contrib/openzfs/module')
-rw-r--r--sys/contrib/openzfs/module/os/freebsd/zfs/dmu_os.c2
-rw-r--r--sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c4
-rw-r--r--sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c2
-rw-r--r--sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c4
-rw-r--r--sys/contrib/openzfs/module/zfs/spa_misc.c31
-rw-r--r--sys/contrib/openzfs/module/zfs/vdev_initialize.c10
-rw-r--r--sys/contrib/openzfs/module/zfs/vdev_rebuild.c2
-rw-r--r--sys/contrib/openzfs/module/zfs/vdev_trim.c15
-rw-r--r--sys/contrib/openzfs/module/zfs/zfs_ioctl.c4
9 files changed, 51 insertions, 23 deletions
diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/dmu_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/dmu_os.c
index 8e412d9c1359..fb8f560316ea 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/dmu_os.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/dmu_os.c
@@ -319,7 +319,7 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
break;
}
ASSERT(m->dirty == 0);
- ASSERT(!pmap_page_is_mapped(m));
+ ASSERT(!pmap_page_is_write_mapped(m));
ASSERT(db->db_size > PAGE_SIZE);
bufoff = IDX_TO_OFF(m->pindex) % db->db_size;
diff --git a/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c b/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c
index b373f2c2e83c..ff71ef4cd065 100644
--- a/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c
+++ b/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c
@@ -494,7 +494,11 @@ vdev_blkg_tryget(struct blkcg_gq *blkg)
static inline void
vdev_bio_associate_blkg(struct bio *bio)
{
+#if defined(HAVE_BIO_BDEV_DISK)
+ struct request_queue *q = bio->bi_bdev->bd_disk->queue;
+#else
struct request_queue *q = bio->bi_disk->queue;
+#endif
ASSERT3P(q, !=, NULL);
ASSERT3P(bio->bi_blkg, ==, NULL);
diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c
index b88e0497d000..6f5cff1770e1 100644
--- a/sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c
+++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c
@@ -209,7 +209,7 @@ zfs_max_nvlist_src_size_os(void)
if (zfs_max_nvlist_src_size != 0)
return (zfs_max_nvlist_src_size);
- return (KMALLOC_MAX_SIZE);
+ return (MIN(ptob(zfs_totalram_pages) / 4, 128 * 1024 * 1024));
}
void
diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c b/sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c
index 0caf31307718..0d62b1490702 100644
--- a/sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c
+++ b/sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c
@@ -307,8 +307,12 @@ zvol_request(struct request_queue *q, struct bio *bio)
#endif
{
#ifdef HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS
+#if defined(HAVE_BIO_BDEV_DISK)
+ struct request_queue *q = bio->bi_bdev->bd_disk->queue;
+#else
struct request_queue *q = bio->bi_disk->queue;
#endif
+#endif
zvol_state_t *zv = q->queuedata;
fstrans_cookie_t cookie = spl_fstrans_mark();
uint64_t offset = BIO_BI_SECTOR(bio) << 9;
diff --git a/sys/contrib/openzfs/module/zfs/spa_misc.c b/sys/contrib/openzfs/module/zfs/spa_misc.c
index b4c73f58d3bc..0dacf9027b27 100644
--- a/sys/contrib/openzfs/module/zfs/spa_misc.c
+++ b/sys/contrib/openzfs/module/zfs/spa_misc.c
@@ -347,13 +347,14 @@ int spa_asize_inflation = 24;
/*
* Normally, we don't allow the last 3.2% (1/(2^spa_slop_shift)) of space in
- * the pool to be consumed. This ensures that we don't run the pool
- * completely out of space, due to unaccounted changes (e.g. to the MOS).
- * It also limits the worst-case time to allocate space. If we have less than
- * this amount of free space, most ZPL operations (e.g. write, create) will
- * return ENOSPC. The ZIL metaslabs (spa_embedded_log_class) are also part of
- * this 3.2% of space which can't be consumed by normal writes; the slop space
- * "proper" (spa_get_slop_space()) is decreased by the embedded log space.
+ * the pool to be consumed (bounded by spa_max_slop). This ensures that we
+ * don't run the pool completely out of space, due to unaccounted changes (e.g.
+ * to the MOS). It also limits the worst-case time to allocate space. If we
+ * have less than this amount of free space, most ZPL operations (e.g. write,
+ * create) will return ENOSPC. The ZIL metaslabs (spa_embedded_log_class) are
+ * also part of this 3.2% of space which can't be consumed by normal writes;
+ * the slop space "proper" (spa_get_slop_space()) is decreased by the embedded
+ * log space.
*
* Certain operations (e.g. file removal, most administrative actions) can
* use half the slop space. They will only return ENOSPC if less than half
@@ -376,10 +377,15 @@ int spa_asize_inflation = 24;
* 3.2%, in an effort to have it be at least spa_min_slop (128MB),
* but we never allow it to be more than half the pool size.
*
+ * Further, on very large pools, the slop space will be smaller than
+ * 3.2%, to avoid reserving much more space than we actually need; bounded
+ * by spa_max_slop (128GB).
+ *
* See also the comments in zfs_space_check_t.
*/
int spa_slop_shift = 5;
-uint64_t spa_min_slop = 128 * 1024 * 1024;
+uint64_t spa_min_slop = 128ULL * 1024 * 1024;
+uint64_t spa_max_slop = 128ULL * 1024 * 1024 * 1024;
int spa_allocators = 4;
@@ -1278,9 +1284,9 @@ spa_vdev_config_exit(spa_t *spa, vdev_t *vd, uint64_t txg, int error, char *tag)
*/
vdev_autotrim_stop_wait(vd);
- spa_config_enter(spa, SCL_ALL, spa, RW_WRITER);
+ spa_config_enter(spa, SCL_STATE_ALL, spa, RW_WRITER);
vdev_free(vd);
- spa_config_exit(spa, SCL_ALL, spa);
+ spa_config_exit(spa, SCL_STATE_ALL, spa);
}
/*
@@ -1781,7 +1787,8 @@ spa_get_worst_case_asize(spa_t *spa, uint64_t lsize)
/*
* Return the amount of slop space in bytes. It is typically 1/32 of the pool
* (3.2%), minus the embedded log space. On very small pools, it may be
- * slightly larger than this. The embedded log space is not included in
+ * slightly larger than this. On very large pools, it will be capped to
+ * the value of spa_max_slop. The embedded log space is not included in
* spa_dspace. By subtracting it, the usable space (per "zfs list") is a
* constant 97% of the total space, regardless of metaslab size (assuming the
* default spa_slop_shift=5 and a non-tiny pool).
@@ -1792,7 +1799,7 @@ uint64_t
spa_get_slop_space(spa_t *spa)
{
uint64_t space = spa_get_dspace(spa);
- uint64_t slop = space >> spa_slop_shift;
+ uint64_t slop = MIN(space >> spa_slop_shift, spa_max_slop);
/*
* Subtract the embedded log space, but no more than half the (3.2%)
diff --git a/sys/contrib/openzfs/module/zfs/vdev_initialize.c b/sys/contrib/openzfs/module/zfs/vdev_initialize.c
index 083ad2861b5b..e9156c32f384 100644
--- a/sys/contrib/openzfs/module/zfs/vdev_initialize.c
+++ b/sys/contrib/openzfs/module/zfs/vdev_initialize.c
@@ -553,8 +553,14 @@ vdev_initialize_thread(void *arg)
vd->vdev_initialize_tree = NULL;
mutex_enter(&vd->vdev_initialize_lock);
- if (!vd->vdev_initialize_exit_wanted && vdev_writeable(vd)) {
- vdev_initialize_change_state(vd, VDEV_INITIALIZE_COMPLETE);
+ if (!vd->vdev_initialize_exit_wanted) {
+ if (vdev_writeable(vd)) {
+ vdev_initialize_change_state(vd,
+ VDEV_INITIALIZE_COMPLETE);
+ } else if (vd->vdev_faulted) {
+ vdev_initialize_change_state(vd,
+ VDEV_INITIALIZE_CANCELED);
+ }
}
ASSERT(vd->vdev_initialize_thread != NULL ||
vd->vdev_initialize_inflight == 0);
diff --git a/sys/contrib/openzfs/module/zfs/vdev_rebuild.c b/sys/contrib/openzfs/module/zfs/vdev_rebuild.c
index 037abc01f7a7..a77ff99faa92 100644
--- a/sys/contrib/openzfs/module/zfs/vdev_rebuild.c
+++ b/sys/contrib/openzfs/module/zfs/vdev_rebuild.c
@@ -807,8 +807,8 @@ vdev_rebuild_thread(void *arg)
ASSERT0(range_tree_space(vr->vr_scan_tree));
/* Disable any new allocations to this metaslab */
- metaslab_disable(msp);
spa_config_exit(spa, SCL_CONFIG, FTAG);
+ metaslab_disable(msp);
mutex_enter(&msp->ms_sync_lock);
mutex_enter(&msp->ms_lock);
diff --git a/sys/contrib/openzfs/module/zfs/vdev_trim.c b/sys/contrib/openzfs/module/zfs/vdev_trim.c
index 895957bda195..deea7fedd770 100644
--- a/sys/contrib/openzfs/module/zfs/vdev_trim.c
+++ b/sys/contrib/openzfs/module/zfs/vdev_trim.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2016 by Delphix. All rights reserved.
* Copyright (c) 2019 by Lawrence Livermore National Security, LLC.
+ * Copyright (c) 2021 Hewlett Packard Enterprise Development LP
*/
#include <sys/spa.h>
@@ -930,10 +931,16 @@ vdev_trim_thread(void *arg)
range_tree_destroy(ta.trim_tree);
mutex_enter(&vd->vdev_trim_lock);
- if (!vd->vdev_trim_exit_wanted && vdev_writeable(vd)) {
- vdev_trim_change_state(vd, VDEV_TRIM_COMPLETE,
- vd->vdev_trim_rate, vd->vdev_trim_partial,
- vd->vdev_trim_secure);
+ if (!vd->vdev_trim_exit_wanted) {
+ if (vdev_writeable(vd)) {
+ vdev_trim_change_state(vd, VDEV_TRIM_COMPLETE,
+ vd->vdev_trim_rate, vd->vdev_trim_partial,
+ vd->vdev_trim_secure);
+ } else if (vd->vdev_faulted) {
+ vdev_trim_change_state(vd, VDEV_TRIM_CANCELED,
+ vd->vdev_trim_rate, vd->vdev_trim_partial,
+ vd->vdev_trim_secure);
+ }
}
ASSERT(vd->vdev_trim_thread != NULL || vd->vdev_trim_inflight[0] == 0);
diff --git a/sys/contrib/openzfs/module/zfs/zfs_ioctl.c b/sys/contrib/openzfs/module/zfs/zfs_ioctl.c
index 922253469fba..5f291d067bef 100644
--- a/sys/contrib/openzfs/module/zfs/zfs_ioctl.c
+++ b/sys/contrib/openzfs/module/zfs/zfs_ioctl.c
@@ -3988,7 +3988,7 @@ zfs_ioc_pool_initialize(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
fnvlist_free(vdev_errlist);
spa_close(spa, FTAG);
- return (total_errors > 0 ? EINVAL : 0);
+ return (total_errors > 0 ? SET_ERROR(EINVAL) : 0);
}
/*
@@ -4073,7 +4073,7 @@ zfs_ioc_pool_trim(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
fnvlist_free(vdev_errlist);
spa_close(spa, FTAG);
- return (total_errors > 0 ? EINVAL : 0);
+ return (total_errors > 0 ? SET_ERROR(EINVAL) : 0);
}
/*