Date: Thu, 23 Mar 2017 08:59:17 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315852 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys Message-ID: <201703230859.v2N8xHdg011666@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Thu Mar 23 08:59:17 2017 New Revision: 315852 URL: https://svnweb.freebsd.org/changeset/base/315852 Log: zfs: add zio_buf_alloc_nowait and use it in vdev_queue_aggregate This way we can avoid blocking the whole queue in the low memory situations. It's better to sacrifice some I/O performance by not doing the aggregation than to add an indefinite wait for more memory. Reviewed by: smh MFC after: 2 weeks Sponsored by: Panzura Differential Revision: https://reviews.freebsd.org/D9999 Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Thu Mar 23 08:57:04 2017 (r315851) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Thu Mar 23 08:59:17 2017 (r315852) @@ -567,6 +567,7 @@ extern zio_t *zio_unique_parent(zio_t *c 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); Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c Thu Mar 23 08:57:04 2017 (r315851) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c Thu Mar 23 08:59:17 2017 (r315852) @@ -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, z 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; Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Thu Mar 23 08:57:04 2017 (r315851) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Thu Mar 23 08:59:17 2017 (r315852) @@ -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)); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703230859.v2N8xHdg011666>