From 66dbeba3853690c0b4f259c8b0957dd517e188d7 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Thu, 3 Sep 2015 18:39:15 -0400 Subject: [PATCH] Experiment: Make dmu_free_long_range configurably yield the floor --- module/zfs/dmu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index ac7499d0176e..903cc80a345e 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -56,6 +56,11 @@ */ int zfs_nopwrite_enabled = 1; +/* + * Enable artificial yields when freeing a large range + */ +int zfs_dmu_free_long_range_yield = 0; + const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES] = { { DMU_BSWAP_UINT8, TRUE, "unallocated" }, { DMU_BSWAP_ZAP, TRUE, "object directory" }, @@ -647,6 +652,7 @@ dmu_free_long_range_impl(objset_t *os, dnode_t *dn, uint64_t offset, { uint64_t object_size; int err; + int chunks = 0; if (dn == NULL) return (SET_ERROR(EINVAL)); @@ -683,6 +689,20 @@ dmu_free_long_range_impl(objset_t *os, dnode_t *dn, uint64_t offset, dmu_tx_commit(tx); length -= chunk_end - chunk_begin; + + /* + * If we are asked to do so, occasionally wait for the next txg. + * This should let other threads that want to use the disk in! + */ + if(zfs_dmu_free_long_range_yield > 0) { + if (chunks++ == zfs_dmu_free_long_range_yield) { + dsl_dir_t *dd = os->os_dsl_dataset->ds_dir; + if(dd != NULL) { + txg_wait_open(dd->dd_pool, 0); + } + chunks = 0; + } + } } return (0); } @@ -2178,4 +2198,6 @@ MODULE_PARM_DESC(zfs_mdcomp_disable, "Disable meta data compression"); module_param(zfs_nopwrite_enabled, int, 0644); MODULE_PARM_DESC(zfs_nopwrite_enabled, "Enable NOP writes"); +module_param(zfs_dmu_free_long_range_yield, int, 0644); +MODULE_PARM_DESC(zfs_dmu_free_long_range_yield, "Enable extra waits when freeing long ranges"); #endif