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

fix zfs send progress reporting #10216

Merged
merged 1 commit into from
Apr 20, 2020
Merged

Conversation

ahrens
Copy link
Member

@ahrens ahrens commented Apr 16, 2020

Motivation and Context

The progress of a send is supposed to be reported by zfs send -v, but
it is not. This works by creating a new user thread (with
pthread_create()) which does ZFS_IOC_SEND_PROGRESS ioctls to check how
much progress has been made. This IOCTL finds the specified send (since
there may be multiple concurrent sends in the system). The IOCTL also
checks that the specified send was started by the current process.

On Linux, different threads of the same process are represented as
different struct task_structs (and, confusingly, have different
PID's). To check if if two threads are in the same process, we need to
check if they have the same struct task_struct:group_leader.

We used to to this correctly, but it was inadvertently changed by
30af21b (Redacted Send) to simply check if the current
struct task_struct is the one that started the send.

Closes #10215

Description

This commit changes the code back to checking if the send was started by
a struct task_struct with the same group_leader as the calling
thread.

Note: this probably doesn't work on FreeBSD and I'll need to figure out the right way to abstract this out. Therefore marking this PR as Draft.

Note: Redacted Send is not in 0.8, so this bug only exists on master (AFAIK).

How Has This Been Tested?

Manual testing.

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)
  • Documentation (a change to man pages or other documentation)

Checklist:

  • My code follows the ZFS on Linux code style requirements.
  • 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.

@ahrens ahrens added Status: Code Review Needed Ready for review and testing Type: Defect Incorrect behavior (e.g. crash, hang) Component: Send/Recv "zfs send/recv" feature labels Apr 16, 2020
@ahrens ahrens requested review from pcd1193182 and a user April 16, 2020 20:37
@ghost
Copy link

ghost commented Apr 16, 2020

The existing code works for us, so yes some platform-dependent macro or inline function will be needed.

@ahrens ahrens force-pushed the send_progress branch 2 times, most recently from a3ea992 to 816e606 Compare April 17, 2020 05:42
The progress of a send is supposed to be reported by `zfs send -v`, but
it is not.  This works by creating a new user thread (with
pthread_create()) which does ZFS_IOC_SEND_PROGRESS ioctls to check how
much progress has been made.  This IOCTL finds the specified send (since
there may be multiple concurrent sends in the system).  The IOCTL also
checks that the specified send was started by the current process.

On Linux, different threads of the same process are represented as
different `struct task_struct`s (and, confusingly, have different
PID's).  To check if if two threads are in the same process, we need to
check if they have the same `struct task_struct:group_leader`.

We used to to this correctly, but it was inadvertently changed by
30af21b (Redacted Send) to simply check if the current
`struct task_struct` is the one that started the send.

This commit changes the code back to checking if the send was started by
a `struct task_struct` with the same `group_leader` as the calling
thread.

Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes openzfs#10215
Copy link
Contributor

@cwedgwood cwedgwood left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Thanks!

@ahrens ahrens marked this pull request as ready for review April 17, 2020 21:00
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Apr 20, 2020
@behlendorf behlendorf merged commit 1f043c8 into openzfs:master Apr 20, 2020
@gdevenyi gdevenyi mentioned this pull request Apr 20, 2020
12 tasks
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
The progress of a send is supposed to be reported by `zfs send -v`, but
it is not.  This works by creating a new user thread (with
pthread_create()) which does ZFS_IOC_SEND_PROGRESS ioctls to check how
much progress has been made.  This IOCTL finds the specified send (since
there may be multiple concurrent sends in the system).  The IOCTL also
checks that the specified send was started by the current process.

On Linux, different threads of the same process are represented as
different `struct task_struct`s (and, confusingly, have different
PID's).  To check if if two threads are in the same process, we need to
check if they have the same `struct task_struct:group_leader`.

We used to to this correctly, but it was inadvertently changed by
30af21b (Redacted Send) to simply check if the current
`struct task_struct` is the one that started the send.

This commit changes the code back to checking if the send was started by
a `struct task_struct` with the same `group_leader` as the calling
thread.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Chris Wedgwood <cw@f00f.org>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes openzfs#10215 
Closes openzfs#10216
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) Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZFS send no longer shows progress
4 participants