From 2cba99c1bec0dad4227d1055188686c8df92cea1 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 24 Nov 2025 10:27:18 -0500 Subject: [PATCH 1/4] ZFS: Enable more logs for raidz_001_neg The output is not so big here, so lets collect something useful. Signed-off-by: Alexander Motin --- tests/zfs-tests/tests/functional/raidz/raidz_001_neg.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/zfs-tests/tests/functional/raidz/raidz_001_neg.ksh b/tests/zfs-tests/tests/functional/raidz/raidz_001_neg.ksh index ad6faaf7ee59..ec06435c8cc9 100755 --- a/tests/zfs-tests/tests/functional/raidz/raidz_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/raidz/raidz_001_neg.ksh @@ -34,6 +34,6 @@ # This option should make raidz_test to return non 0. # -log_mustnot raidz_test -T +log_mustnot raidz_test -Tv log_pass "raidz_test detects errors as expected." From 91dd365b55f9c4af96e5d159035acd6de04b9e4d Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 24 Nov 2025 13:36:58 -0500 Subject: [PATCH 2/4] raidz_test: Set io_offset reasonably - io_offset of 1 makes no sense. Set default to 0. - Initialize io_offset in all cases. Signed-off-by: Alexander Motin --- cmd/raidz_test/raidz_test.c | 2 +- cmd/raidz_test/raidz_test.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/raidz_test/raidz_test.c b/cmd/raidz_test/raidz_test.c index 4839e909e4f7..7b4118ba3541 100644 --- a/cmd/raidz_test/raidz_test.c +++ b/cmd/raidz_test/raidz_test.c @@ -374,7 +374,7 @@ init_raidz_map(raidz_test_opts_t *opts, zio_t **zio, const int parity) *zio = umem_zalloc(sizeof (zio_t), UMEM_NOFAIL); - (*zio)->io_offset = 0; + (*zio)->io_offset = opts->rto_offset; (*zio)->io_size = alloc_dsize; (*zio)->io_abd = raidz_alloc(alloc_dsize); init_zio_abd(*zio); diff --git a/cmd/raidz_test/raidz_test.h b/cmd/raidz_test/raidz_test.h index f0b854cefb5d..77f15e847c1a 100644 --- a/cmd/raidz_test/raidz_test.h +++ b/cmd/raidz_test/raidz_test.h @@ -72,7 +72,7 @@ typedef struct raidz_test_opts { static const raidz_test_opts_t rto_opts_defaults = { .rto_ashift = 9, - .rto_offset = 1ULL << 0, + .rto_offset = 0, .rto_dcols = 8, .rto_dsize = 1<<19, .rto_v = D_ALL, From a902ee742e10dbe7b94210f1b764ad779c2ef277 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 24 Nov 2025 13:38:31 -0500 Subject: [PATCH 3/4] raidz_test: Fix ZIO ABDs initialization - When filling ABDs of several segments, consider offset. - "Corrupt" ABDs with actually different data to fail something. Signed-off-by: Alexander Motin --- cmd/raidz_test/raidz_test.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cmd/raidz_test/raidz_test.c b/cmd/raidz_test/raidz_test.c index 7b4118ba3541..701779dad3c2 100644 --- a/cmd/raidz_test/raidz_test.c +++ b/cmd/raidz_test/raidz_test.c @@ -265,9 +265,21 @@ cmp_data(raidz_test_opts_t *opts, raidz_map_t *rm) static int init_rand(void *data, size_t size, void *private) +{ + size_t *offsetp = (size_t *)private; + size_t offset = *offsetp; + + VERIFY3U(offset + size, <=, SPA_MAXBLOCKSIZE); + memcpy(data, (char *)rand_data + offset, size); + *offsetp = offset + size; + return (0); +} + +static int +corrupt_rand_fill(void *data, size_t size, void *private) { (void) private; - memcpy(data, rand_data, size); + memset(data, 0xAA, size); return (0); } @@ -279,7 +291,7 @@ corrupt_colums(raidz_map_t *rm, const int *tgts, const int cnt) for (int i = 0; i < cnt; i++) { raidz_col_t *col = &rr->rr_col[tgts[i]]; abd_iterate_func(col->rc_abd, 0, col->rc_size, - init_rand, NULL); + corrupt_rand_fill, NULL); } } } @@ -287,7 +299,8 @@ corrupt_colums(raidz_map_t *rm, const int *tgts, const int cnt) void init_zio_abd(zio_t *zio) { - abd_iterate_func(zio->io_abd, 0, zio->io_size, init_rand, NULL); + size_t offset = 0; + abd_iterate_func(zio->io_abd, 0, zio->io_size, init_rand, &offset); } static void From 0b8532a4133e5bda43ca7ac5b3e99dbb01c63c77 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 25 Nov 2025 05:07:00 -0500 Subject: [PATCH 4/4] raidz_test: Restore rand_data protection It feels dirty to modify protection of a memory allocated via libc, but at least we should try to restore it before freeing. Signed-off-by: Alexander Motin --- cmd/raidz_test/raidz_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/raidz_test/raidz_test.c b/cmd/raidz_test/raidz_test.c index 701779dad3c2..153e1f5f7405 100644 --- a/cmd/raidz_test/raidz_test.c +++ b/cmd/raidz_test/raidz_test.c @@ -848,6 +848,8 @@ main(int argc, char **argv) err = run_test(NULL); } + mprotect(rand_data, SPA_MAXBLOCKSIZE, PROT_READ | PROT_WRITE); + umem_free(rand_data, SPA_MAXBLOCKSIZE); kernel_fini();