From 36283ca23346061cb653dc7b6bd583d1cf772808 Mon Sep 17 00:00:00 2001 From: Max Grossman Date: Sun, 7 Sep 2014 17:06:08 +0200 Subject: Illumos 5138 - add tunable for maximum number of blocks freed in one txg Reviewed by: Adam Leventhal Reviewed by: Mattew Ahrens Reviewed by: Josef 'Jeff' Sipek Reviewed by: Richard Elling Reviewed by: George Wilson Approved by: Dan McDonald References: https://www.illumos.org/issues/5138 https://github.com/illumos/illumos-gate/commit/af3465d Porting notes: Because support for exposing a uint64_t parameter wasn't added until v3.17-rc1 the zfs_free_max_blocks variable has been declared as a unsigned long. This is already far larger than required and it allows us to avoid additional autoconf compatibility code. The default value has been set to 100,000 on Linux instead of ULONG_MAX which is used on Illumos. This was done to limit the number of outstanding IOs in the system when snapshots are destroyed. This helps ensure individual TXG sync times are kept reasonable and memory isn't wasted managing a huge backlog of outstanding IOs. Ported by: Turbo Fredriksson Signed-off-by: Brian Behlendorf Closes #2675 Closes #2581 --- module/zfs/dsl_scan.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'module') diff --git a/module/zfs/dsl_scan.c b/module/zfs/dsl_scan.c index 5546dad5f..eeec76f78 100644 --- a/module/zfs/dsl_scan.c +++ b/module/zfs/dsl_scan.c @@ -69,6 +69,8 @@ int zfs_no_scrub_io = B_FALSE; /* set to disable scrub i/o */ int zfs_no_scrub_prefetch = B_FALSE; /* set to disable scrub prefetch */ enum ddt_class zfs_scrub_ddt_class_max = DDT_CLASS_DUPLICATE; int dsl_scan_delay_completion = B_FALSE; /* set to delay scan completion */ +/* max number of blocks to free in a single TXG */ +ulong zfs_free_max_blocks = 100000; #define DSL_SCAN_IS_SCRUB_RESILVER(scn) \ ((scn)->scn_phys.scn_func == POOL_SCAN_SCRUB || \ @@ -1370,6 +1372,9 @@ dsl_scan_free_should_pause(dsl_scan_t *scn) if (zfs_recover) return (B_FALSE); + if (scn->scn_visited_this_txg >= zfs_free_max_blocks) + return (B_TRUE); + elapsed_nanosecs = gethrtime() - scn->scn_sync_start_time; return (elapsed_nanosecs / NANOSEC > zfs_txg_timeout || (NSEC2MSEC(elapsed_nanosecs) > zfs_free_min_time_ms && @@ -1868,4 +1873,7 @@ MODULE_PARM_DESC(zfs_no_scrub_io, "Set to disable scrub I/O"); module_param(zfs_no_scrub_prefetch, int, 0644); MODULE_PARM_DESC(zfs_no_scrub_prefetch, "Set to disable scrub prefetching"); + +module_param(zfs_free_max_blocks, ulong, 0644); +MODULE_PARM_DESC(zfs_free_max_blocks, "Max number of blocks freed in one txg"); #endif -- cgit v1.2.3