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

Don't attempt trimming "hole" vdevs #10227

Merged
merged 1 commit into from
Apr 21, 2020
Merged

Conversation

haasn
Copy link
Contributor

@haasn haasn commented Apr 18, 2020

Motivation and Context

I noticed that my zpool trim <poolname> command fails with:

cannot trim 'hole': no such device in pool

I've never seen such "hole" devices before, but I suspect the reason I have one now was that I added and removed a log device for testing purposes. (One of the commends in zpool_vdev.c suggests something similar: that "hole" represents added and removed aux devices)

Obviously a command like zpool trim should therefore ignore hole devices.

Description

The easiest place to make this change is in zpool_collect_leaves. This has only one other user (zpool initialize), which I therefore assume has the same bug.

How Has This Been Tested?

I rebuilt zpool and ran zpool trim on my pool, which worked successfully. I have not tested the effects of the change on zpool initialize.

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.

On zpools containig hole vdevs (e.g. removed log devices), the `zpool
trim` (and presumably `zpool initialize`) commands will attempt calling
their respective functions on "hole", which fails, as this is not a real
vdev.

Avoid this by removing HOLE vdevs in zpool_collect_leaves.

Signed-off-by: Niklas Haas <[email protected]>
@codecov-io
Copy link

codecov-io commented Apr 18, 2020

Codecov Report

Merging #10227 into master will decrease coverage by 0.23%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10227      +/-   ##
==========================================
- Coverage   79.48%   79.25%   -0.24%     
==========================================
  Files         388      388              
  Lines      123390   123391       +1     
==========================================
- Hits        98077    97791     -286     
- Misses      25313    25600     +287     
Flag Coverage Δ
#kernel 79.88% <ø> (-0.06%) ⬇️
#user 65.22% <100.00%> (-0.89%) ⬇️
Impacted Files Coverage Δ
cmd/zpool/zpool_main.c 80.43% <100.00%> (-0.18%) ⬇️
module/zcommon/zfs_fletcher.c 68.09% <0.00%> (-10.20%) ⬇️
module/os/linux/spl/spl-kmem-cache.c 75.58% <0.00%> (-8.50%) ⬇️
cmd/ztest/ztest.c 75.36% <0.00%> (-6.38%) ⬇️
module/zfs/space_map.c 93.31% <0.00%> (-4.71%) ⬇️
module/zfs/spa_checkpoint.c 93.78% <0.00%> (-4.35%) ⬇️
module/zcommon/zfs_fletcher_superscalar.c 97.05% <0.00%> (-2.95%) ⬇️
module/zcommon/zfs_uio.c 86.73% <0.00%> (-2.05%) ⬇️
module/zcommon/zfs_fletcher_superscalar4.c 98.43% <0.00%> (-1.57%) ⬇️
module/zfs/vdev_mirror.c 94.77% <0.00%> (-1.50%) ⬇️
... and 57 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 c614fd6...6c287fc. Read the comment docs.

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.

Looks good. Thanks for catching this.

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Apr 20, 2020
@behlendorf behlendorf merged commit a84c92f into openzfs:master Apr 21, 2020
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Apr 21, 2020
as-com pushed a commit to as-com/zfs that referenced this pull request Jun 20, 2020
On zpools containing hole vdevs (e.g. removed log devices), the `zpool
trim` (and presumably `zpool initialize`) commands will attempt calling
their respective functions on "hole", which fails, as this is not a real
vdev.

Avoid this by removing HOLE vdevs in zpool_collect_leaves.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by: Niklas Haas <[email protected]>
Closes openzfs#10227 
(cherry picked from commit a84c92f)
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
On zpools containing hole vdevs (e.g. removed log devices), the `zpool
trim` (and presumably `zpool initialize`) commands will attempt calling
their respective functions on "hole", which fails, as this is not a real
vdev.

Avoid this by removing HOLE vdevs in zpool_collect_leaves.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by: Niklas Haas <[email protected]>
Closes openzfs#10227
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