zfs icon indicating copy to clipboard operation
zfs copied to clipboard

Don't return an error when zpool scrub -w is called with a scrub already in progress

Open Haravikk opened this issue 1 year ago • 3 comments

Describe the feature would like to see added to OpenZFS

When a zpool scrub -w command is issued and a scrub is already underway, the command should wait until the scrub completes before returning, rather than immediately exiting with an error as it does now.

In the event the -e option (or similar future options) are provided the command should still return an error immediately if the command is asking to wait for the wrong type of scrub, i.e- zpool -we tank while a non-errors only scrub is already running on tank, would return the scrub already in progress error as normal, but zpool -w tank would not.

How will this feature improve OpenZFS?

It will make it easier to run a one-off command after a scrub completes; for example, if I want to add a new disk to a mirror, but a scheduled scrub is underway, I would usually rather the scrub finishes first unless it's only recently started.

While it's possible to set up zed event handles to do this, or poll the output from zpool status, these seem like overly complex ways to do it when we already have the -w option for scrubs we initiated ourselves.

Additional context

If there are concerns around changing the existing behaviour, the alternative I can think of would be to instead add an additional option; perhaps -W (uppercase w), which would trigger this new behaviour.

Haravikk avatar Apr 03 '24 22:04 Haravikk

The resilver_defer feature implements not restarting because you did a zpool attach.

I have various complaints about how it works, but it does.

rincebrain avatar Apr 04 '24 01:04 rincebrain

That said, you can also zpool wait -t scrub, at the moment.

rincebrain avatar Apr 04 '24 01:04 rincebrain

How have I been using ZFS for years and completely missed the zpool wait command? That's probably all I actually need, there's no particular benefit to adding redundancy to other commands (despite zfs being 100% all about redundancy 😂).

My inclination is to close this, but would it be worth tweaking the currently scrubbing error to mention zpool wait? Currently it reads:

cannot scrub <pool>: currently scrubbing; use 'zpool scrub -s' to cancel scrub

Would it be useful to rephrase it something like:

cannot scrub <pool>: currently scrubbing; use 'zpool scrub -s' to cancel scrub, or 'zpool wait -t scrub' to wait for it to finish

Either that or mention it in the description for man zpool-scrub alongside the -w option?

Probably hard to get statistics on how many users like me don't know something already exists. 🤦‍♂️

Haravikk avatar Apr 04 '24 08:04 Haravikk