diff options
author | Bryan Cantrill <bryan@joyent.com> | 2013-09-05 06:53:03 +0000 |
---|---|---|
committer | Bryan Cantrill <bryan@joyent.com> | 2013-09-05 06:53:03 +0000 |
commit | 092fe49637e40ccc367f723900bcb91ba2fab46d (patch) | |
tree | 3bb6d2698378bacbff0aa02e613f3665a9925cdc /usr/src/uts/common/fs/zfs/zio.c | |
parent | 64af696dbea3e718e4c758e173de5fa35826dd41 (diff) | |
download | illumos-joyent-release-20130905.tar.gz |
OS-2437 arc_get_data_buf() blocks in vmem_alloc() instead of evicting20130905release-20130905
Diffstat (limited to 'usr/src/uts/common/fs/zfs/zio.c')
-rw-r--r-- | usr/src/uts/common/fs/zfs/zio.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/usr/src/uts/common/fs/zfs/zio.c b/usr/src/uts/common/fs/zfs/zio.c index eb06151cee..dfd8fa3f65 100644 --- a/usr/src/uts/common/fs/zfs/zio.c +++ b/usr/src/uts/common/fs/zfs/zio.c @@ -22,6 +22,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. */ #include <sys/zfs_context.h> @@ -228,6 +229,20 @@ zio_buf_alloc(size_t size) } /* + * Same as zio_buf_alloc, but won't sleep in case memory cannot be allocated + * and will instead return immediately with a failure. + */ +void * +zio_buf_alloc_canfail(size_t size) +{ + size_t c = (size - 1) >> SPA_MINBLOCKSHIFT; + + ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT); + + return (kmem_cache_alloc(zio_buf_cache[c], KM_NOSLEEP | KM_NORMALPRI)); +} + +/* * Use zio_data_buf_alloc to allocate data. The data will not appear in a * crashdump if the kernel panics. This exists so that we will limit the amount * of ZFS data that shows up in a kernel crashdump. (Thus reducing the amount @@ -243,6 +258,21 @@ zio_data_buf_alloc(size_t size) return (kmem_cache_alloc(zio_data_buf_cache[c], KM_PUSHPAGE)); } +/* + * Same as zio_data_buf_alloc, but won't sleep in case memory cannot be + * allocated and will instead return immediately with a failure. + */ +void * +zio_data_buf_alloc_canfail(size_t size) +{ + size_t c = (size - 1) >> SPA_MINBLOCKSHIFT; + + ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT); + + return (kmem_cache_alloc(zio_data_buf_cache[c], + KM_NOSLEEP | KM_NORMALPRI)); +} + void zio_buf_free(void *buf, size_t size) { |