Skip to content

zpool/zfs: Add '-a|--all' option to scrub, trim, initialize. #17524

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

Merged
merged 1 commit into from
Jul 29, 2025

Conversation

akashb-22
Copy link
Contributor

@akashb-22 akashb-22 commented Jul 9, 2025

Add support for the '-a | --all' option to perform trim, scrub, and initialize operations on all pools.

Previously, specifying a pool name was mandatory for these operations. With this enhancement, users can now execute these operations across all pools at once, without needing to manually iterate over each pool from the command line.

Motivation and Context

It would be helpful to have the ability to initiate these operations (scrub, trim, initialize) on multiple pools simultaneously.

Description

Add support for commands like zpool scrub -a, zpool trim -a, and zpool initialize -a to run the respective operation on all pools present in the system. This enhancement allows users to perform these tasks across all pools with a single command, improving efficiency and convenience.

How Has This Been Tested?

Tested this manually.

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)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • 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:

Copy link
Contributor

@mcmilk mcmilk left a comment

Choose a reason for hiding this comment

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

Maybe some small tests which verifies that zpool trim|scrub|... -a does it for all pools would be nice. You can use zpool events -H pool for this.

@akashb-22 akashb-22 force-pushed the initialize_trim_a branch 2 times, most recently from 9dd8ee1 to 0d23aff Compare July 14, 2025 14:34
Copy link
Contributor

@mcmilk mcmilk left a comment

Choose a reason for hiding this comment

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

This looks good for me.
@behlendorf @tonyhutter - what do you think?

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Jul 14, 2025
@akashb-22 akashb-22 force-pushed the initialize_trim_a branch 3 times, most recently from 23fb2b4 to 9465189 Compare July 15, 2025 15:36
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 nice, thanks for adding this support. Just a couple comments.

@akashb-22 akashb-22 force-pushed the initialize_trim_a branch 3 times, most recently from 29ebe3a to 4472ba0 Compare July 26, 2025 15:19
@akashb-22 akashb-22 requested a review from amotin July 28, 2025 14:13
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.

I don't have major objections, but I am not sure this improves libzfs API, nor making it more stable.

Add support for the '-a | --all' option to perform trim,
scrub, and initialize operations on all pools.
Previously, specifying a pool name was mandatory for
these operations. With this enhancement, users can now
execute these operations across all pools at once,
without needing to manually iterate over each pool
from the command line.

Signed-off-by: Akash B <[email protected]>
@akashb-22 akashb-22 force-pushed the initialize_trim_a branch from 4472ba0 to 79fd0b5 Compare July 29, 2025 04:39
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jul 29, 2025
@behlendorf behlendorf merged commit b6e8db5 into openzfs:master Jul 29, 2025
39 of 41 checks passed
@akashb-22 akashb-22 deleted the initialize_trim_a branch July 30, 2025 03:59
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