Skip to content

FreeBSD: Use new py-sysctl features, fix some issues in Python commands #11318

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

Closed
wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 9, 2020

Motivation and Context

FreeBSD and py-sysctl have been enhanced with new features for working with sysctls.
FreeBSD now has a mode of iterating through all nodes in the sysctl tree, even hidden ones and nodes, and py-sysctl now uses that mode to build its list of sysctls.
py-sysctl also is able to fetch the description string for a sysctl now.

When the FreeBSD platform glue was implemented for the Python-based commands arcstat, arc_summary, and dbufstat, these features did not exist in py-sysctl.

I found one tunable that was being formatted incorrectly as a bytearray rather than an integer in the arc_summary output while testing these updates. This was identified to be caused by an incorrect format string in the declaration of the sysctl.

Description

Due to the lack of descriptions in py-sysctl at the time, we had to shell out to the sysctl command for the descriptions of tunables. Now we can avoid all that and access the .description field on a sysctl object instead.

Filter out CTLTYPE_NODE type sysctls so we avoid listing nodes as tunables with None as the value on FreeBSD head.

Match the type of the vfs.zfs.arc_no_grow_shift sysctl to the corresponding variable and use a valid format string so the tunable is correctly formatted as an integer instead of a bytearray in the output of arc_summary3.

How Has This Been Tested?

Manual testing to confirm output, and ZTS sanity checked on FreeBSD.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

Ryan Moeller added 2 commits December 8, 2020 17:02
py-sysctl now includes the CTLTYPE_NODE type nodes in the list returned
by sysctl.filter() on FreeBSD head.  It also provides descriptions now.

Eliminate the subprocess call to get descriptions, and filter out the
nodes so we only deal with values.

Signed-off-by: Ryan Moeller <[email protected]>
vfs.zfs.arc_no_grow_shift has an invalid type (15) and this causes
py-sysctl to format it as a bytearray when it should be an integer.

"U" is not a valid format, it should be "I" and the type should match
the variable type, int.  We can return EINVAL if the value is set below
zero.

Signed-off-by: Ryan Moeller <[email protected]>
@ghost ghost added the Status: Code Review Needed Ready for review and testing label Dec 9, 2020
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Dec 10, 2020
behlendorf pushed a commit that referenced this pull request Dec 10, 2020
vfs.zfs.arc_no_grow_shift has an invalid type (15) and this causes
py-sysctl to format it as a bytearray when it should be an integer.

"U" is not a valid format, it should be "I" and the type should match
the variable type, int.  We can return EINVAL if the value is set below
zero.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #11318
@ghost ghost deleted the py-sysctl branch December 11, 2020 18:01
ghost pushed a commit to zfsonfreebsd/ZoF that referenced this pull request Dec 23, 2020
py-sysctl now includes the CTLTYPE_NODE type nodes in the list returned
by sysctl.filter() on FreeBSD head.  It also provides descriptions now.

Eliminate the subprocess call to get descriptions, and filter out the
nodes so we only deal with values.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#11318
ghost pushed a commit to zfsonfreebsd/ZoF that referenced this pull request Dec 23, 2020
vfs.zfs.arc_no_grow_shift has an invalid type (15) and this causes
py-sysctl to format it as a bytearray when it should be an integer.

"U" is not a valid format, it should be "I" and the type should match
the variable type, int.  We can return EINVAL if the value is set below
zero.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#11318
behlendorf pushed a commit that referenced this pull request Dec 23, 2020
py-sysctl now includes the CTLTYPE_NODE type nodes in the list returned
by sysctl.filter() on FreeBSD head.  It also provides descriptions now.

Eliminate the subprocess call to get descriptions, and filter out the
nodes so we only deal with values.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #11318
behlendorf pushed a commit that referenced this pull request Dec 23, 2020
vfs.zfs.arc_no_grow_shift has an invalid type (15) and this causes
py-sysctl to format it as a bytearray when it should be an integer.

"U" is not a valid format, it should be "I" and the type should match
the variable type, int.  We can return EINVAL if the value is set below
zero.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #11318
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
py-sysctl now includes the CTLTYPE_NODE type nodes in the list returned
by sysctl.filter() on FreeBSD head.  It also provides descriptions now.

Eliminate the subprocess call to get descriptions, and filter out the
nodes so we only deal with values.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#11318
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
vfs.zfs.arc_no_grow_shift has an invalid type (15) and this causes
py-sysctl to format it as a bytearray when it should be an integer.

"U" is not a valid format, it should be "I" and the type should match
the variable type, int.  We can return EINVAL if the value is set below
zero.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#11318
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
py-sysctl now includes the CTLTYPE_NODE type nodes in the list returned
by sysctl.filter() on FreeBSD head.  It also provides descriptions now.

Eliminate the subprocess call to get descriptions, and filter out the
nodes so we only deal with values.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#11318
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
vfs.zfs.arc_no_grow_shift has an invalid type (15) and this causes
py-sysctl to format it as a bytearray when it should be an integer.

"U" is not a valid format, it should be "I" and the type should match
the variable type, int.  We can return EINVAL if the value is set below
zero.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#11318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant