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 FreeBSD condvar semantics #10460

Merged
merged 1 commit into from
Jun 16, 2020
Merged

Conversation

ghost
Copy link

@ghost ghost commented Jun 15, 2020

Motivation and Context

FreeBSD's SPL cv_timedwait_* implementations returned deltas in all cases. The correct semantics are:

Return Value Description
0 For cv_wait_sig(), cv_timedwait_sig(), and cv_reltimedwait_sig() indicates that the condition was not necessarily signaled and the function returned because a signal (as in kill(2)) was pending.
-1 For cv_timedwait(), cv_timedwait_sig(), cv_reltimedwait(), and cv_reltimedwait_sig(), indicates that the condition was not necessarily signaled and the function returned because the timeout time was reached.
>0 For cv_wait_sig(), cv_timedwait(), cv_timedwait_sig(), cv_reltimedwait(), and cv_reltimedwait_sig(), indicates that the condition was met and the function returned due to a call to cv_signal() or cv_broadcast(), or due to a premature wakeup (see NOTES).

(Source: https://illumos.org/man/9F/cv_timedwait)

Description

Return -1 instead of negative deltas, and 0 if signaled.

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)
  • 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.

@ghost ghost added the Status: Code Review Needed Ready for review and testing label Jun 15, 2020
@amotin
Copy link
Member

amotin commented Jun 15, 2020

Otherwise it makes sense to me.

Copy link
Contributor

@lundman lundman left a comment

Choose a reason for hiding this comment

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

and with my apologies.

We should return -1 instead of negative deltas, and 0 if signaled.

Signed-off-by: Ryan Moeller <[email protected]>
@ghost ghost force-pushed the freebsd-condvars branch from 5d8449d to 65981d0 Compare June 15, 2020 21:34
@ghost
Copy link
Author

ghost commented Jun 15, 2020

  • Return -1 if delta is negative, as intended

Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

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

Thanks.

@adamdmoss
Copy link
Contributor

adamdmoss commented Jun 15, 2020

(I think it'd help if openzfs documented its internal APIs - even in a one-line comment - instead of relying on the implicit knowledge that they should match syscall semantics from the kernel of an operating system that's relatively obscure even by *nix standards...!)

@codecov
Copy link

codecov bot commented Jun 16, 2020

Codecov Report

Merging #10460 into master will decrease coverage by 0.81%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10460      +/-   ##
==========================================
- Coverage   80.24%   79.43%   -0.82%     
==========================================
  Files         293      393     +100     
  Lines       83882   123859   +39977     
==========================================
+ Hits        67313    98385   +31072     
- Misses      16569    25474    +8905     
Flag Coverage Δ
#kernel 80.05% <ø> (-0.20%) ⬇️
#user 65.32% <ø> (?)
Impacted Files Coverage Δ
module/zfs/zcp_set.c 87.09% <0.00%> (-12.91%) ⬇️
module/zfs/zfs_ratelimit.c 90.47% <0.00%> (-9.53%) ⬇️
module/zfs/dmu_redact.c 82.15% <0.00%> (-6.24%) ⬇️
module/zfs/zfs_byteswap.c 79.45% <0.00%> (-5.85%) ⬇️
module/zcommon/zfs_deleg.c 92.45% <0.00%> (-5.55%) ⬇️
module/zcommon/zfeature_common.c 92.85% <0.00%> (-4.82%) ⬇️
module/zfs/aggsum.c 95.34% <0.00%> (-4.66%) ⬇️
module/zfs/dsl_deleg.c 90.07% <0.00%> (-4.48%) ⬇️
module/zfs/zio_inject.c 75.80% <0.00%> (-4.41%) ⬇️
module/zfs/spa_checkpoint.c 93.78% <0.00%> (-4.26%) ⬇️
... and 278 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 883a40f...65981d0. Read the comment docs.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jun 16, 2020
@behlendorf behlendorf merged commit c13facb into openzfs:master Jun 16, 2020
@ghost ghost deleted the freebsd-condvars branch June 16, 2020 17:16
lundman referenced this pull request in openzfsonosx/openzfs Jun 19, 2020
We should return -1 instead of negative deltas, and 0 if signaled.

Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Jorgen Lundman <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #10460
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
We should return -1 instead of negative deltas, and 0 if signaled.

Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Jorgen Lundman <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#10460
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
We should return -1 instead of negative deltas, and 0 if signaled.

Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Jorgen Lundman <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#10460
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.

4 participants