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

Misc libzfs sendrecv cleanup #12967

Closed
wants to merge 19 commits into from
Closed

Misc libzfs sendrecv cleanup #12967

wants to merge 19 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 12, 2022

Motivation and Context

I've been studying libzfs sendrecv code and cleaning up things as I go. This is far from complete, but I don't want to keep sitting on these patches.

Description

See individual commit messages for now.

How Has This Been Tested?

ZTS 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:

@ghost ghost added Component: Send/Recv "zfs send/recv" feature Status: Code Review Needed Ready for review and testing labels Jan 20, 2022
@ghost ghost marked this pull request as ready for review January 20, 2022 19:41
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like most of these commits are straight forward cleanup which should be easy to get integrated. If we could for the moment drop the WIP changes from this PR we could get the cleanup in sooner. The only additional thing I'd ask is to flesh out the individual commit comments so they contain more than just a subject.

lib/libzfs/libzfs_sendrecv.c Outdated Show resolved Hide resolved
lib/libzfs/libzfs_sendrecv.c Show resolved Hide resolved
lib/libzfs/libzfs_sendrecv.c Outdated Show resolved Hide resolved
Ryan Moeller added 19 commits January 26, 2022 14:18
We won't be passing a negative value here, so make it clear.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
De-clutter the clode and make it clear the guid is only used here.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
avl_add does avl_find internally, then avl_insert.  We're already doing
the avl_find, so using avl_insert directly avoids repeating the search.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
There is no need to allocate a holds nvlist.  lzc_get_holds does that
for us.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Add a high level comment.
* Use local variables to reduce line wrapping.
* Remove extra braces and insert space for clarity.
* Assert precondition that the dataset name contains '@' for sanity.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Add a high level comment.
* Move locals closer to point of use.
* Use fnv* routines rather than explicit verification of success.
* Factor out duplicated code by introducing isspacelimit to clarify
  behavior.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Capitalize and punctuate complete sentences in comments.
* Separate out a group of locals to add a comment on their purpose.
* Remove unnecessary line wrapping.
* Make it clear that dds_origin is a string by using explicit character
  comparison to check for an empty string, rather than implictly
  treating it as a boolean.
* Reorganize manipulation of props and holds nvlists to improve
  clarity.
* There's no need to initialize the snapname buffer with zeros, we're
  immediately overwriting it.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Reduce indentation.
* Move locals closer to use.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Don't bother building a debug nvlist if we can't return it.
* Save errno after ioctl failure in case snprintf clobbers it.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
In zfs_send_progress, initialize \*bytes_written and \*blocks_visited
in case we have to return early due to ioctl failure.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
This makes the header print before the sleep as well, which is fine.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Add missing dgettext calls.
* Avoid unnecessary line wraps.
* Factor out duplicated parsable check.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Add a high level comment.
* Avoid unnecessary line wrapping.
* Simplify size accounting logic.
* Eliminate unnecessary buffer on the stack.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Add high level comments.
* Eliminate unnecessarily void arg.
* Avoid unnecessary line wrapping.
* Initialize sdd fields with the correct types.
* Remove extra whitespace.
* Refactor replication checks for clarity.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Add a high level comment.
* Eliminate unnecessarily void arg.
* Capitalize and punctuate complete sentences in comments.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Capitalize and punctuate complete sentences.
* Add a blank line between functions.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Factor out get_bookmarks, find_redact_pair, and get_redact_complete
helper functions to improve the readability of find_redact_book.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Improve the readability of zfs_send_resume_impl by moving resume nvl
decoding into a separate helper function.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
* Improve naming.
* Reduce indentation.
* Avoid boilerplate logic duplication.

Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
@ghost ghost force-pushed the fix-sendrecv branch from 331b03c to 49c50ac Compare January 26, 2022 15:54
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Feb 2, 2022
@behlendorf behlendorf closed this in 01a0039 Feb 2, 2022
behlendorf pushed a commit that referenced this pull request Feb 2, 2022
De-clutter the clode and make it clear the guid is only used here.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967
behlendorf pushed a commit that referenced this pull request Feb 2, 2022
avl_add does avl_find internally, then avl_insert.  We're already doing
the avl_find, so using avl_insert directly avoids repeating the search.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
This makes the header print before the sleep as well, which is fine.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add missing dgettext calls.
* Avoid unnecessary line wraps.
* Factor out duplicated parsable check.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add a high level comment.
* Avoid unnecessary line wrapping.
* Simplify size accounting logic.
* Eliminate unnecessary buffer on the stack.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add high level comments.
* Eliminate unnecessarily void arg.
* Avoid unnecessary line wrapping.
* Initialize sdd fields with the correct types.
* Remove extra whitespace.
* Refactor replication checks for clarity.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add a high level comment.
* Eliminate unnecessarily void arg.
* Capitalize and punctuate complete sentences in comments.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Capitalize and punctuate complete sentences.
* Add a blank line between functions.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
Factor out get_bookmarks, find_redact_pair, and get_redact_complete
helper functions to improve the readability of find_redact_book.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
Improve the readability of zfs_send_resume_impl by moving resume nvl
decoding into a separate helper function.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Improve naming.
* Reduce indentation.
* Avoid boilerplate logic duplication.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
We won't be passing a negative value here, so make it clear.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
De-clutter the clode and make it clear the guid is only used here.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
avl_add does avl_find internally, then avl_insert.  We're already doing
the avl_find, so using avl_insert directly avoids repeating the search.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
There is no need to allocate a holds nvlist.  lzc_get_holds does that
for us.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add a high level comment.
* Use local variables to reduce line wrapping.
* Remove extra braces and insert space for clarity.
* Assert precondition that the dataset name contains '@' for sanity.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add a high level comment.
* Move locals closer to point of use.
* Use fnv* routines rather than explicit verification of success.
* Factor out duplicated code by introducing isspacelimit to clarify
  behavior.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Capitalize and punctuate complete sentences in comments.
* Separate out a group of locals to add a comment on their purpose.
* Remove unnecessary line wrapping.
* Make it clear that dds_origin is a string by using explicit character
  comparison to check for an empty string, rather than implictly
  treating it as a boolean.
* Reorganize manipulation of props and holds nvlists to improve
  clarity.
* There's no need to initialize the snapname buffer with zeros, we're
  immediately overwriting it.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Reduce indentation.
* Move locals closer to use.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Don't bother building a debug nvlist if we can't return it.
* Save errno after ioctl failure in case snprintf clobbers it.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
In zfs_send_progress, initialize \*bytes_written and \*blocks_visited
in case we have to return early due to ioctl failure.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
This makes the header print before the sleep as well, which is fine.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add missing dgettext calls.
* Avoid unnecessary line wraps.
* Factor out duplicated parsable check.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add a high level comment.
* Avoid unnecessary line wrapping.
* Simplify size accounting logic.
* Eliminate unnecessary buffer on the stack.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add high level comments.
* Eliminate unnecessarily void arg.
* Avoid unnecessary line wrapping.
* Initialize sdd fields with the correct types.
* Remove extra whitespace.
* Refactor replication checks for clarity.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Add a high level comment.
* Eliminate unnecessarily void arg.
* Capitalize and punctuate complete sentences in comments.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Capitalize and punctuate complete sentences.
* Add a blank line between functions.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
Factor out get_bookmarks, find_redact_pair, and get_redact_complete
helper functions to improve the readability of find_redact_book.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
Improve the readability of zfs_send_resume_impl by moving resume nvl
decoding into a separate helper function.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
* Improve naming.
* Reduce indentation.
* Avoid boilerplate logic duplication.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes openzfs#12967
tonyhutter pushed a commit that referenced this pull request Feb 26, 2024
* Add missing dgettext calls.
* Avoid unnecessary line wraps.
* Factor out duplicated parsable check.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Send/Recv "zfs send/recv" feature Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant