Add ability to scrub from last scrubbed txg
Motivation and Context
Sometimes it is useful to only scrub a particular range of txg. Some users might want to scrub only new data because they would like to know if the new write wasn't corrupted. This PR adds possiblity scrub only newly flushed data.
Description
Users who would like to scrub only new data, a new zpool property was introduced, that stores last scrubbed txg, so users can run scrub only from the last saved point. We use a scn_max_txg and scn_min_txg which are already built into scrub, to accomplish that.
How Has This Been Tested?
Via test cases.
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] 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)
- [ ] Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
- [ ] Documentation (a change to man pages or other documentation)
Checklist:
- [x] My code follows the OpenZFS code style requirements.
- [x] I have updated the documentation accordingly.
- [x] I have read the contributing document.
- [x] I have added tests to cover my changes.
- [ ] I have run the ZFS Test Suite with this change applied.
- [x] All commit messages are properly formatted and contain
Signed-off-by.
I noticed a cannot scrub tank: delegated administration is disabled on pool error when trying to continue (-C) on a paused scrub:
$ sudo ./zpool scrub tank && sleep 1 && sudo ./zpool scrub -p tank
$ sudo ./zpool status
pool: tank
state: ONLINE
scan: scrub paused since Tue Aug 27 16:02:26 2024
scrub started on Tue Aug 27 16:02:25 2024
14.7G / 14.7G scanned, 3.22G / 14.7G issued
0B repaired, 21.95% done
config:
NAME STATE READ WRITE CKSUM
tank ONLINE 0 0 0
vdb ONLINE 0 0 0
errors: No known data errors
$ sudo ./zpool scrub -C tank
cannot scrub tank: delegated administration is disabled on pool
$ echo $?
1
$ sudo ./zpool status
pool: tank
state: ONLINE
scan: scrub repaired 0B in 00:00:14 with 0 errors on Tue Aug 27 16:02:39 2024
config:
NAME STATE READ WRITE CKSUM
tank ONLINE 0 0 0
vdb ONLINE 0 0 0
errors: No known data errors
It returns an error code, but then the scrub seems to complete successfully. Any thoughts?
@tonyhutter This is after the applied patch, but without it, it works fine?
I have added another feature just to scrub "recent data".
@oshogbo Would you rebase and resolve the test failures?
@amotin Yes, let my try to fix that.
@behlendorf @allanjude @amotin Thank you for the review.
@oshogbo it looks like this change unexpectedly breaks ztest. I've resubmitted the ztest CI build multiple times now and haven't been able to get a clean pass. Can you take a look at the CI logs from the failures:
https://github.com/openzfs/zfs/actions/runs/11891031862?pr=16301
I think its fixed now.
Thanks. That looks much better, I'm rerunning the failed FreeBSD CI run and zloop again just to make sure. If everything looks good I'll get it merged.