summaryrefslogtreecommitdiffstats
path: root/sys/cddl
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2017-04-14 15:09:23 +0000
committeravg <avg@FreeBSD.org>2017-04-14 15:09:23 +0000
commitc559b8882674d010b7492b441e99d464955d0f57 (patch)
treedfd16f14a0a6ead3fd9deae59fe6aca74db630f5 /sys/cddl
parentf80e9f9fe0e96afb07393ac458982af8e11bb5e7 (diff)
downloadFreeBSD-src-c559b8882674d010b7492b441e99d464955d0f57.zip
FreeBSD-src-c559b8882674d010b7492b441e99d464955d0f57.tar.gz
MFC r315852: zfs: add zio_buf_alloc_nowait and use it in vdev_queue_aggregate
Diffstat (limited to 'sys/cddl')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c7
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c27
3 files changed, 28 insertions, 7 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
index c57d0ad..1e89b28 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
@@ -566,6 +566,7 @@ extern zio_t *zio_unique_parent(zio_t *cio);
extern void zio_add_child(zio_t *pio, zio_t *cio);
extern void *zio_buf_alloc(size_t size);
+extern void *zio_buf_alloc_nowait(size_t size);
extern void zio_buf_free(void *buf, size_t size);
extern void *zio_data_buf_alloc(size_t size);
extern void zio_data_buf_free(void *buf, size_t size);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c
index d45662f..46e76b8 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c
@@ -647,6 +647,7 @@ static zio_t *
vdev_queue_aggregate(vdev_queue_t *vq, zio_t *zio)
{
zio_t *first, *last, *aio, *dio, *mandatory, *nio;
+ void *abuf;
uint64_t maxgap = 0;
uint64_t size;
boolean_t stretch;
@@ -755,8 +756,12 @@ vdev_queue_aggregate(vdev_queue_t *vq, zio_t *zio)
size = IO_SPAN(first, last);
ASSERT3U(size, <=, zfs_vdev_aggregation_limit);
+ abuf = zio_buf_alloc_nowait(size);
+ if (abuf == NULL)
+ return (NULL);
+
aio = zio_vdev_delegated_io(first->io_vd, first->io_offset,
- zio_buf_alloc(size), size, first->io_type, zio->io_priority,
+ abuf, size, first->io_type, zio->io_priority,
flags | ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_QUEUE,
vdev_queue_agg_io_done, NULL);
aio->io_timestamp = first->io_timestamp;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
index d72fb92..425d791 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
@@ -272,18 +272,33 @@ zio_fini(void)
* useful to inspect ZFS metadata, but if possible, we should avoid keeping
* excess / transient data in-core during a crashdump.
*/
-void *
-zio_buf_alloc(size_t size)
+static void *
+zio_buf_alloc_impl(size_t size, boolean_t canwait)
{
size_t c = (size - 1) >> SPA_MINBLOCKSHIFT;
int flags = zio_exclude_metadata ? KM_NODEBUG : 0;
VERIFY3U(c, <, SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
- if (zio_use_uma)
- return (kmem_cache_alloc(zio_buf_cache[c], KM_PUSHPAGE));
- else
- return (kmem_alloc(size, KM_SLEEP|flags));
+ if (zio_use_uma) {
+ return (kmem_cache_alloc(zio_buf_cache[c],
+ canwait ? KM_PUSHPAGE : KM_NOSLEEP));
+ } else {
+ return (kmem_alloc(size,
+ (canwait ? KM_SLEEP : KM_NOSLEEP) | flags));
+ }
+}
+
+void *
+zio_buf_alloc(size_t size)
+{
+ return (zio_buf_alloc_impl(size, B_TRUE));
+}
+
+void *
+zio_buf_alloc_nowait(size_t size)
+{
+ return (zio_buf_alloc_impl(size, B_FALSE));
}
/*
OpenPOWER on IntegriCloud