Skip to content
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

log: Introduce nvme_get_logging_level() #782

Closed
wants to merge 2 commits into from

Conversation

tbzatek
Copy link
Contributor

@tbzatek tbzatek commented Feb 14, 2024

This is essentially a getter for nvme_init_logging() since nvme_root_t is an opaque struct. Takes optional pointer to bool args to retrieve PID and timestamp logging values.

@tbzatek
Copy link
Contributor Author

tbzatek commented Feb 14, 2024

The idea behind this is to temporarily pause logging (save-override-restore) for operations that are expected to fail.

This is essentially a getter for nvme_init_logging() since
nvme_root_t is an opaque struct. Takes optional pointer
to bool args to retrieve PID and timestamp logging values.

Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
When logging has not been initialized and no root available,
logging via nvme_msg() would just print everything. Better
to check against DEFAULT_LOGLEVEL in such cases.

Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
@tbzatek
Copy link
Contributor Author

tbzatek commented Feb 15, 2024

Added one more change to fix the scenario where e.g. nvme-cli plugins have not initialized logging (since there's no root available) and debugging clutter is being printed on stderr.

# nvme nbft show -o json
file /sys/firmware/acpi/tables/NBFT: SSNS 1 skipping duplicate HFI index 1
file /sys/firmware/acpi/tables/NBFT: SSNS 2 skipping duplicate HFI index 1
file /sys/firmware/acpi/tables/NBFT: SSNS 3 skipping duplicate HFI index 1
file /sys/firmware/acpi/tables/NBFT: SSNS 4 skipping duplicate HFI index 1
file /sys/firmware/acpi/tables/NBFT: SSNS 5 skipping duplicate HFI index 1
file /sys/firmware/acpi/tables/NBFT: SSNS 6 skipping duplicate HFI index 1
file /sys/firmware/acpi/tables/NBFT: SSNS 7 skipping duplicate HFI index 1
file /sys/firmware/acpi/tables/NBFT: SSNS 8 skipping duplicate HFI index 1
file /sys/firmware/acpi/tables/NBFT: SSNS 9 skipping duplicate HFI index 2
file /sys/firmware/acpi/tables/NBFT: SSNS 10 skipping duplicate HFI index 2
file /sys/firmware/acpi/tables/NBFT: SSNS 11 skipping duplicate HFI index 2
file /sys/firmware/acpi/tables/NBFT: SSNS 12 skipping duplicate HFI index 2
file /sys/firmware/acpi/tables/NBFT: SSNS 13 skipping duplicate HFI index 2
file /sys/firmware/acpi/tables/NBFT: SSNS 14 skipping duplicate HFI index 2
... <JSON follows>

@igaw
Copy link
Collaborator

igaw commented Feb 16, 2024

TBH, I think we creating a big mess with the logging. It's getting messier with every commit. Why should the default log level be checked when the root object exists? And what about disabling it on global level, what happens with any existing root object?

These are just small 'smells' which tell me that this is going wrong. It's not this particular change. I don't have a good idea what to do. Maybe all function which don't take a root object not print anything at all.

@tbzatek
Copy link
Contributor Author

tbzatek commented Feb 17, 2024

Both of my commits are rather nice-to-have hacks trying to sneak in an existing infrastructure. On a second thought, you're right, there's more weirdness going on.

For start, the symbol naming is inconsistent: nvme_init_logging(), nvme_set_root() and my nvme_get_logging_level(). Would be nice to have a common namespace. Then you have nvme_set_debug() and nvme_get_debug() for ioctls that are somewhat related as well.

Another issue is that while you may call nvme_msg(root=NULL), you can't init logging without a root object. This is e.g. the case for stateless nvme-cli plugins.

Maybe all function which don't take a root object not print anything at all.

We would still like to have e.g. the nbft parser high-severity messages printed. The global static root (nvme_set_root()) doesn't really help this use case either.

@igaw
Copy link
Collaborator

igaw commented Mar 5, 2024

I'll have a stab if we can improve this. Anyway, your changes itself look okay but as we discussed there is a bit of a mess around the logging infra. I guess we can't avoid having a global variable for the logging, because there is too much code which wants to print debug/error stuff.

@igaw
Copy link
Collaborator

igaw commented Mar 6, 2024

The situation in libnvme wasn't that bad I had in memory. Just the recently debug code was not good. I've dropped this and picked up these changes in #788.

@igaw igaw closed this Mar 6, 2024
@tbzatek
Copy link
Contributor Author

tbzatek commented Mar 6, 2024

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants