--- a/usr/src/uts/common/fs/zfs/zio.c Fri Feb 16 12:27:32 2007 -0800
+++ b/usr/src/uts/common/fs/zfs/zio.c Fri Feb 16 13:39:57 2007 -0800
@@ -64,6 +64,9 @@
/* At or above this size, force gang blocking - for testing */
uint64_t zio_gang_bang = SPA_MAXBLOCKSIZE + 1;
+/* Force an allocation failure when non-zero */
+uint16_t zio_zil_fail_shift = 0;
+
typedef struct zio_sync_pass {
int zp_defer_free; /* defer frees after this pass */
int zp_dontcompress; /* don't compress after this pass */
@@ -1751,6 +1754,14 @@
}
}
+static boolean_t
+zio_alloc_should_fail(void)
+{
+ static uint16_t allocs = 0;
+
+ return (P2PHASE(allocs++, 1U<<zio_zil_fail_shift) == 0);
+}
+
/*
* Try to allocate an intent log block. Return 0 on success, errno on failure.
*/
@@ -1762,6 +1773,11 @@
spa_config_enter(spa, RW_READER, FTAG);
+ if (zio_zil_fail_shift && zio_alloc_should_fail()) {
+ spa_config_exit(spa, FTAG);
+ return (ENOSPC);
+ }
+
/*
* We were passed the previous log blocks dva_t in bp->blk_dva[0].
*/