From d830d4795a210b5ba85482fe26909e64857af763 Mon Sep 17 00:00:00 2001 From: Matt Ahrens Date: Mon, 24 Jul 2017 11:07:39 -0700 Subject: [PATCH] OpenZFS 9280 - Assertion failure while running removal_with_ganging test with 4K devices Authored by: Matt Ahrens Reviewed by: George Wilson Reviewed by: John Kennedy Reviewed-by: Giuseppe Di Natale Approved by: Garrett D'Amore Ported-by: Brian Behlendorf OpenZFS-issue: https://www.illumos.org/issues/9280 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/243952c Closes #7445 --- cmd/ztest/ztest.c | 20 +++++++++---------- man/man5/zfs-module-parameters.5 | 12 +++++++++++ module/zfs/metaslab.c | 12 ++++++----- .../removal/removal_with_ganging.ksh | 6 +++--- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 315169571db6..84e13c14a42e 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -168,7 +168,7 @@ typedef struct ztest_shared_opts { int zo_init; uint64_t zo_time; uint64_t zo_maxloops; - uint64_t zo_metaslab_gang_bang; + uint64_t zo_metaslab_force_ganging; int zo_mmp_test; } ztest_shared_opts_t; @@ -192,10 +192,10 @@ static const ztest_shared_opts_t ztest_opts_defaults = { .zo_init = 1, .zo_time = 300, /* 5 minutes */ .zo_maxloops = 50, /* max loops during spa_freeze() */ - .zo_metaslab_gang_bang = 32 << 10 + .zo_metaslab_force_ganging = 32 << 10 }; -extern uint64_t metaslab_gang_bang; +extern uint64_t metaslab_force_ganging; extern uint64_t metaslab_df_alloc_threshold; extern unsigned long zfs_deadman_synctime_ms; extern int metaslab_preload_limit; @@ -635,12 +635,12 @@ usage(boolean_t requested) const ztest_shared_opts_t *zo = &ztest_opts_defaults; char nice_vdev_size[NN_NUMBUF_SZ]; - char nice_gang_bang[NN_NUMBUF_SZ]; + char nice_force_ganging[NN_NUMBUF_SZ]; FILE *fp = requested ? stdout : stderr; nicenum(zo->zo_vdev_size, nice_vdev_size, sizeof (nice_vdev_size)); - nicenum(zo->zo_metaslab_gang_bang, nice_gang_bang, - sizeof (nice_gang_bang)); + nicenum(zo->zo_metaslab_force_ganging, nice_force_ganging, + sizeof (nice_force_ganging)); (void) fprintf(fp, "Usage: %s\n" "\t[-v vdevs (default: %llu)]\n" @@ -677,7 +677,7 @@ usage(boolean_t requested) zo->zo_raidz_parity, /* -R */ zo->zo_datasets, /* -d */ zo->zo_threads, /* -t */ - nice_gang_bang, /* -g */ + nice_force_ganging, /* -g */ zo->zo_init, /* -i */ (u_longlong_t)zo->zo_killrate, /* -k */ zo->zo_pool, /* -p */ @@ -746,8 +746,8 @@ process_options(int argc, char **argv) zo->zo_threads = MAX(1, value); break; case 'g': - zo->zo_metaslab_gang_bang = MAX(SPA_MINBLOCKSIZE << 1, - value); + zo->zo_metaslab_force_ganging = + MAX(SPA_MINBLOCKSIZE << 1, value); break; case 'i': zo->zo_init = value; @@ -7299,7 +7299,7 @@ main(int argc, char **argv) zs = ztest_shared; if (fd_data_str) { - metaslab_gang_bang = ztest_opts.zo_metaslab_gang_bang; + metaslab_force_ganging = ztest_opts.zo_metaslab_force_ganging; metaslab_df_alloc_threshold = zs->zs_metaslab_df_alloc_threshold; diff --git a/man/man5/zfs-module-parameters.5 b/man/man5/zfs-module-parameters.5 index 8b007ea17e8b..75fd5808b30e 100644 --- a/man/man5/zfs-module-parameters.5 +++ b/man/man5/zfs-module-parameters.5 @@ -220,6 +220,18 @@ relative to the pool. Use \fB1\fR for yes (default) and \fB0\fR for no. .RE +.sp +.ne 2 +.na +\fBmetaslab_force_ganging\fR (ulong) +.ad +.RS 12n +Make some blocks above a certain size be gang blocks. This option is used +by the test suite to facilitate testing. +.sp +Default value: \fB16,777,217\fR. +.RE + .sp .ne 2 .na diff --git a/module/zfs/metaslab.c b/module/zfs/metaslab.c index 52a60cc5eb08..ae98c514305c 100644 --- a/module/zfs/metaslab.c +++ b/module/zfs/metaslab.c @@ -48,8 +48,10 @@ */ unsigned long metaslab_aliquot = 512 << 10; -/* force gang blocks */ -unsigned long metaslab_gang_bang = SPA_MAXBLOCKSIZE + 1; +/* + * For testing, make some blocks above a certain size be gang blocks. + */ +unsigned long metaslab_force_ganging = SPA_MAXBLOCKSIZE + 1; /* * The in-core space map representation is more compact than its on-disk form. @@ -2952,7 +2954,7 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize, /* * For testing, make some blocks above a certain size be gang blocks. */ - if (psize >= metaslab_gang_bang && (ddi_get_lbolt() & 3) == 0) { + if (psize >= metaslab_force_ganging && (ddi_get_lbolt() & 3) == 0) { metaslab_trace_add(zal, NULL, NULL, psize, d, TRACE_FORCE_GANG); return (SET_ERROR(ENOSPC)); } @@ -3900,7 +3902,7 @@ MODULE_PARM_DESC(zfs_metaslab_switch_threshold, "segment-based metaslab selection maximum buckets before switching"); /* CSTYLED */ -module_param(metaslab_gang_bang, ulong, 0644); -MODULE_PARM_DESC(metaslab_gang_bang, +module_param(metaslab_force_ganging, ulong, 0644); +MODULE_PARM_DESC(metaslab_force_ganging, "blocks larger than this size are forced to be gang blocks"); #endif /* _KERNEL && HAVE_SPL */ diff --git a/tests/zfs-tests/tests/functional/removal/removal_with_ganging.ksh b/tests/zfs-tests/tests/functional/removal/removal_with_ganging.ksh index cfbca89bda34..0cb22e3e1ac2 100755 --- a/tests/zfs-tests/tests/functional/removal/removal_with_ganging.ksh +++ b/tests/zfs-tests/tests/functional/removal/removal_with_ganging.ksh @@ -15,7 +15,7 @@ # # -# Copyright (c) 2014, 2016 by Delphix. All rights reserved. +# Copyright (c) 2014, 2017 by Delphix. All rights reserved. # . $STF_SUITE/include/libtest.shlib @@ -23,12 +23,12 @@ function cleanup { - log_must set_tunable64 metaslab_gang_bang $((2**17 + 1)) + log_must set_tunable64 metaslab_force_ganging $((2**17 + 1)) default_cleanup_noexit } default_setup_noexit "$DISKS" -log_must set_tunable64 metaslab_gang_bang $((2**12)) +log_must set_tunable64 metaslab_force_ganging $((2**14)) log_onexit cleanup FILE_CONTENTS="Leeloo Dallas mul-ti-pass."