summaryrefslogtreecommitdiffstats
path: root/include/sys
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2012-05-07 13:49:51 -0400
committerBrian Behlendorf <[email protected]>2012-08-27 12:01:37 -0700
commitb8d06fca089fae4680c3a552fc55c512bfb02202 (patch)
treedfb5f3d20c5f417110359d39e8af6e8fecb1fcf3 /include/sys
parent991fc1d7ae2589c01a939a9cbd0e866c90fdd03b (diff)
Switch KM_SLEEP to KM_PUSHPAGE
Differences between how paging is done on Solaris and Linux can cause deadlocks if KM_SLEEP is used in any the following contexts. * The txg_sync thread * The zvol write/discard threads * The zpl_putpage() VFS callback This is because KM_SLEEP will allow for direct reclaim which may result in the VM calling back in to the filesystem or block layer to write out pages. If a lock is held over this operation the potential exists to deadlock the system. To ensure forward progress all memory allocations in these contexts must us KM_PUSHPAGE which disables performing any I/O to accomplish the memory allocation. Previously, this behavior was acheived by setting PF_MEMALLOC on the thread. However, that resulted in unexpected side effects such as the exhaustion of pages in ZONE_DMA. This approach touchs more of the zfs code, but it is more consistent with the right way to handle these cases under Linux. This is patch lays the ground work for being able to safely revert the following commits which used PF_MEMALLOC: 21ade34 Disable direct reclaim for z_wr_* threads cfc9a5c Fix zpl_writepage() deadlock eec8164 Fix ASSERTION(!dsl_pool_sync_context(tx->tx_pool)) Signed-off-by: Richard Yao <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #726
Diffstat (limited to 'include/sys')
-rw-r--r--include/sys/dbuf.h14
-rw-r--r--include/sys/dsl_dataset.h2
-rw-r--r--include/sys/dsl_dir.h2
-rw-r--r--include/sys/spa.h12
4 files changed, 15 insertions, 15 deletions
diff --git a/include/sys/dbuf.h b/include/sys/dbuf.h
index f3e14aad3..ef93eb54c 100644
--- a/include/sys/dbuf.h
+++ b/include/sys/dbuf.h
@@ -345,13 +345,13 @@ boolean_t dbuf_is_metadata(dmu_buf_impl_t *db);
} \
_NOTE(CONSTCOND) } while (0)
-#define dprintf_dbuf_bp(db, bp, fmt, ...) do { \
- if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
- char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_SLEEP); \
- sprintf_blkptr(__blkbuf, bp); \
- dprintf_dbuf(db, fmt " %s\n", __VA_ARGS__, __blkbuf); \
- kmem_free(__blkbuf, BP_SPRINTF_LEN); \
- } \
+#define dprintf_dbuf_bp(db, bp, fmt, ...) do { \
+ if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
+ char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_PUSHPAGE); \
+ sprintf_blkptr(__blkbuf, bp); \
+ dprintf_dbuf(db, fmt " %s\n", __VA_ARGS__, __blkbuf); \
+ kmem_free(__blkbuf, BP_SPRINTF_LEN); \
+ } \
_NOTE(CONSTCOND) } while (0)
#define DBUF_VERIFY(db) dbuf_verify(db)
diff --git a/include/sys/dsl_dataset.h b/include/sys/dsl_dataset.h
index c4530a8f0..948abb020 100644
--- a/include/sys/dsl_dataset.h
+++ b/include/sys/dsl_dataset.h
@@ -271,7 +271,7 @@ int dsl_destroy_inconsistent(const char *dsname, void *arg);
#ifdef ZFS_DEBUG
#define dprintf_ds(ds, fmt, ...) do { \
if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
- char *__ds_name = kmem_alloc(MAXNAMELEN, KM_SLEEP); \
+ char *__ds_name = kmem_alloc(MAXNAMELEN, KM_PUSHPAGE); \
dsl_dataset_name(ds, __ds_name); \
dprintf("ds=%s " fmt, __ds_name, __VA_ARGS__); \
kmem_free(__ds_name, MAXNAMELEN); \
diff --git a/include/sys/dsl_dir.h b/include/sys/dsl_dir.h
index 2191635dd..65ad202bb 100644
--- a/include/sys/dsl_dir.h
+++ b/include/sys/dsl_dir.h
@@ -150,7 +150,7 @@ timestruc_t dsl_dir_snap_cmtime(dsl_dir_t *dd);
#define dprintf_dd(dd, fmt, ...) do { \
if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
char *__ds_name = kmem_alloc(MAXNAMELEN + strlen(MOS_DIR_NAME) + 1, \
- KM_SLEEP); \
+ KM_PUSHPAGE); \
dsl_dir_name(dd, __ds_name); \
dprintf("dd=%s " fmt, __ds_name, __VA_ARGS__); \
kmem_free(__ds_name, MAXNAMELEN + strlen(MOS_DIR_NAME) + 1); \
diff --git a/include/sys/spa.h b/include/sys/spa.h
index 9de5736ed..28bb4e1de 100644
--- a/include/sys/spa.h
+++ b/include/sys/spa.h
@@ -690,12 +690,12 @@ extern void spa_configfile_set(spa_t *, nvlist_t *, boolean_t);
extern void spa_event_notify(spa_t *spa, vdev_t *vdev, const char *name);
#ifdef ZFS_DEBUG
-#define dprintf_bp(bp, fmt, ...) do { \
- if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
- char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_SLEEP); \
- sprintf_blkptr(__blkbuf, (bp)); \
- dprintf(fmt " %s\n", __VA_ARGS__, __blkbuf); \
- kmem_free(__blkbuf, BP_SPRINTF_LEN); \
+#define dprintf_bp(bp, fmt, ...) do { \
+ if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
+ char *__blkbuf = kmem_alloc(BP_SPRINTF_LEN, KM_PUSHPAGE); \
+ sprintf_blkptr(__blkbuf, (bp)); \
+ dprintf(fmt " %s\n", __VA_ARGS__, __blkbuf); \
+ kmem_free(__blkbuf, BP_SPRINTF_LEN); \
} \
_NOTE(CONSTCOND) } while (0)
#else