-
Notifications
You must be signed in to change notification settings - Fork 1.9k
zdb: fix bug with -A flag #17825
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?
zdb: fix bug with -A flag #17825
Conversation
I'm not sure what you're seeing, but the existing code is correct in intent. |
Thank you for the comment, that helps me better understand the expected behavior. What I am seeing is that as we hit Btw, I am running |
89f5c86
to
b72b0e6
Compare
Fixes openzfs#10544. According to the manpage, zdb -A should ignore all assertions. But it currently does not do that. This commit fixes this bug. Signed-off-by: Shreshth Srivastava <[email protected]>
b72b0e6
to
7b67d66
Compare
Oh wow, that's actually subtly broken, and has been since I'm not sure which of these is the better fix. We can just set up the assertions and recovery options before messing around with the switches: diff --git cmd/zdb/zdb.c cmd/zdb/zdb.c
index 70a4ed46f2..c55d630673 100644
--- cmd/zdb/zdb.c
+++ cmd/zdb/zdb.c
@@ -9582,6 +9582,9 @@ main(int argc, char **argv)
*/
spa_mode_readable_spacemaps = B_TRUE;
+ libspl_set_assert_ok((dump_opt['A'] == 1) || (dump_opt['A'] > 2));
+ zfs_recover = (dump_opt['A'] > 1);
+
if (dump_all)
verbose = MAX(verbose, 1);
@@ -9592,9 +9595,6 @@ main(int argc, char **argv)
dump_opt[c] += verbose;
}
- libspl_set_assert_ok((dump_opt['A'] == 1) || (dump_opt['A'] > 2));
- zfs_recover = (dump_opt['A'] > 1);
-
argc -= optind;
argv += optind;
if (argc < 2 && dump_opt['R']) Or we can explicitly exclude 'A' from special treatment by diff --git cmd/zdb/zdb.c cmd/zdb/zdb.c
index 70a4ed46f2..340646a34a 100644
--- cmd/zdb/zdb.c
+++ cmd/zdb/zdb.c
@@ -9586,7 +9586,9 @@ main(int argc, char **argv)
verbose = MAX(verbose, 1);
for (c = 0; c < 256; c++) {
- if (dump_all && strchr("ABeEFkKlLNOPrRSXy", c) == NULL)
+ if (c == 'A')
+ continue;
+ if (dump_all && strchr("BeEFkKlLNOPrRSXy", c) == NULL)
dump_opt[c] = 1;
if (dump_opt[c])
dump_opt[c] += verbose; (The real problem, perhaps, is the chaotic nature of zdb's options setup and overall structure, but that's been a thing for 20+ years, so I won't suggest that you tackle that, unless you really want to! 😅) Both of those are untested, and there might be other options that would benefit from similar treatment. Feel free to take one or both of those patches, or do your own thing. And thanks for looking at this part of the code, its always appreciates some tender love and care! |
Thank you for the detailed comment! Of those two options, I prefer the first one. And I actually updated the PR to include that change after sending my first comment above. Let me know if you see any issues with what I currently have. |
Fixes #10544.
According to the manpage,
zdb -A
should ignore all assertions. But it currently does not do that. This PR fixes this bug.How Has This Been Tested?
Ran
./zdb -K 0 tank
,./zdb -A -K 0 tank
, and./zdb -AA -K 0 tank
locally.Types of changes
Checklist:
Signed-off-by
.