-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix several raidz_test issues #17977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The output is not so big here, so lets collect something useful. Signed-off-by: Alexander Motin <[email protected]>
- io_offset of 1 makes no sense. Set default to 0. - Initialize io_offset in all cases. Signed-off-by: Alexander Motin <[email protected]>
- When filling ABDs of several segments, consider offset. - "Corrupt" ABDs with actually different data to fail something. Signed-off-by: Alexander Motin <[email protected]>
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 <[email protected]>
robn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is all pretty sensible. What a funny little program.
| err = run_test(NULL); | ||
| } | ||
|
|
||
| mprotect(rand_data, SPA_MAXBLOCKSIZE, PROT_READ | PROT_WRITE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right about using mprotect() on memory obtained from libc (technically, wherever umem_alloc() got it from, which is kinda worse maybe?). POSIX explicitly says calling it on a pointer you didn't get from mmap() is unspecified, so.
I don't care for this PR, since we were already doing and your change is an improvement, but if you like we could just use an anonymous mapping:
diff --git a/cmd/raidz_test/raidz_test.c b/cmd/raidz_test/raidz_test.c
index 4839e909e4..eb1d6a562a 100644
--- a/cmd/raidz_test/raidz_test.c
+++ b/cmd/raidz_test/raidz_test.c
@@ -820,7 +820,8 @@ main(int argc, char **argv)
kernel_init(SPA_MODE_READ);
/* setup random data because rand() is not reentrant */
- rand_data = (int *)umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
+ rand_data = (int *)mmap(NULL, SPA_MAXBLOCKSIZE, PROT_READ|PROT_WRITE,
+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
srand((unsigned)time(NULL) * getpid());
for (i = 0; i < SPA_MAXBLOCKSIZE / sizeof (int); i++)
rand_data[i] = rand();
@@ -835,7 +836,7 @@ main(int argc, char **argv)
err = run_test(NULL);
}
- umem_free(rand_data, SPA_MAXBLOCKSIZE);
+ munmap(rand_data, SPA_MAXBLOCKSIZE);
kernel_fini();
return (err);
Trying to investigate CI
raidz_001_negfailures on FreeBSD 16 I ended up with few patches.Types of changes
Checklist:
Signed-off-by.