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

send_iterate_snap : doall send without fromsnap #11608

Merged
merged 17 commits into from
Feb 24, 2021

Conversation

cedricmaunoury
Copy link
Contributor

@cedricmaunoury cedricmaunoury commented Feb 16, 2021

doall send without fromsnap were working properly on FreeBSD12. It's not working on FreeBSD13 with OpenZFS.

Motivation and Context

My tool ZFSync (https://github.com/cedricmaunoury/zfsync) is not working on FreeBSD 13 (with OpenZFS because of changes made on libzfs_sendrecv.c, especially on function send_iterate_snap.

Description

 if (sd->doall && sd->fromsnap == NULL && sd->seenfrom == B_FALSE) {
  sd->seenfrom = B_TRUE;
}

send_iterate_snap function is used to create a nvlist with all the snapshots that will be stored in the stream. If you want to send a full stream with all the snapshots of a dataset without its children (so replicate=false), the nvlist built is broken (only the last snapshot appears) which make the recv function fail with an ASSERT (0 == nvlist_lookup_nvlist(lookup, snapname, &snapprops_nvlist)

How Has This Been Tested?

On a FreeBSD13 server with the sources, I applied this patch and then rebuild the ZFS library
root@freebsd13_BETA2:/usr/src/cddl/lib/libzfs # make
root@freebsd13_BETA2:/usr/src/cddl/lib/libzfs # make install
root@freebsd13_BETA2:/usr/src/cddl/lib/libzfs

OS : FreeBSD 13 BETA 2

This patch is here to handle a "race condition" wich is not available from zfs client

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:

  • My code follows the OpenZFS code style requirements.
  • [x ] I have updated the documentation accordingly.
  • I have read the contributing document.
  • I have added tests to cover my changes.
  • I have run the ZFS Test Suite with this change applied.
  • All commit messages are properly formatted and contain Signed-off-by.

doall send without fromsnap were working properly on FreeBSD12. It's not working on FreeBSD13 with OpenZFS.
@cedricmaunoury
Copy link
Contributor Author

This is my first contribution. It is not perfect at all (sorry for that). I hope this contribution won't be the last one, and I will do better next time (i was not aware of the checklist before posting this PR)

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Feb 16, 2021
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.

Thanks, I'm sure this regressed since we didn't have a test case for it. As part of this change can you also add a simple one to the tests/zfs-tests/tests/functional/rsend/ directory and reference it from the tests/runfiles/common.run file.

nit: please also address the make checkstyle warnings about the comment style.

cc: @problame can you also take a look at this.

@problame
Copy link
Contributor

I added a review comment asking for more assertions to be done in the the .ksh test.

zrepl only uses zfs send -$LZC_FLAGS -i; it re-implements most of the -I and -R functionality itself albeit with live-knowledge about the receiving side. So I'm actually not familiar with the user-space part of send-recv code at all :D

Regardless, at a glance, the fix seems reasonable.

@cedricmaunoury
Copy link
Contributor Author

Patch pushed. I hope tests are going to work 🤞

I think that it may be interesting to allow users to be able to launch zfs send -I @ @tosnap (with an "empty" fromsnap) to get the same result as the one expected from send_doall in the tests. Feedbacks welcome of course.

@cedricmaunoury
Copy link
Contributor Author

It seems that I have still a lot to learn 👶
I haven't found my mistake... I've tried to copy what has been done for badsend :(

@cedricmaunoury
Copy link
Contributor Author

I'm kind of stuck here. @behlendorf @problame : Your previous feedbacks were very helpful :)

I've tried to copy the "badsend" example but something is still going wrong. I didn't find a clue in the logs of the automatic checks to correct my patch.

Thank you in advance

@cedricmaunoury
Copy link
Contributor Author

/tests-functional-ubuntu (18.04)/

2021-02-19T18:10:26.8188354Z Test: /usr/share/zfs/zfs-tests/tests/functional/rsend/send_invalid (run as root) [00:00] [PASS]
2021-02-19T18:10:28.2080777Z Test: /usr/share/zfs/zfs-tests/tests/functional/rsend/send_doall (run as root) [00:01] [PASS]
2021-02-19T18:10:28.8065106Z Test: /usr/share/zfs/zfs-tests/tests/functional/rsend/cleanup (run as root) [00:00] [PASS]

Everything seems fine on send_doall... I don't know why the functional tests have been cancelled...

@cedricmaunoury
Copy link
Contributor Author

zfs-tests-functional / tests-functional-ubuntu (20.04) (pull_request) Cancelled after 360m — tests-functional-ubuntu (20.04)
😢

We have never been that close 👍

@cedricmaunoury
Copy link
Contributor Author

Do you think that my changes make ZFS slower ?

@behlendorf
Copy link
Contributor

Do you think that my changes make ZFS slower?

No I don't think so. But we do seem to have bumped in to the 6 hour test limit for GitHub actions. It's not entirely clear why this test run took longer than usual, but I don't think it needs to hold up this PR.

@behlendorf behlendorf merged commit b9c07ec into openzfs:master Feb 24, 2021
behlendorf pushed a commit that referenced this pull request Mar 5, 2021
The behavior of a NULL fromsnap was inadvertently changed for a doall
send when the send/recv logic in libzfs was updated.  Restore the
previous behavior by correcting send_iterate_snap() to include all
the snapshots in the nvlist for this case. 

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Cedric Maunoury <[email protected]>
Closes #11608
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
The behavior of a NULL fromsnap was inadvertently changed for a doall
send when the send/recv logic in libzfs was updated.  Restore the
previous behavior by correcting send_iterate_snap() to include all
the snapshots in the nvlist for this case. 

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Cedric Maunoury <[email protected]>
Closes openzfs#11608
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
The behavior of a NULL fromsnap was inadvertently changed for a doall
send when the send/recv logic in libzfs was updated.  Restore the
previous behavior by correcting send_iterate_snap() to include all
the snapshots in the nvlist for this case. 

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Cedric Maunoury <[email protected]>
Closes openzfs#11608
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants