zfs icon indicating copy to clipboard operation
zfs copied to clipboard

Add ability to scrub from last scrubbed txg

Open oshogbo opened this issue 1 year ago • 3 comments

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.

oshogbo avatar Jun 26 '24 15:06 oshogbo

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 avatar Aug 27 '24 23:08 tonyhutter

@tonyhutter This is after the applied patch, but without it, it works fine?

oshogbo avatar Aug 29 '24 10:08 oshogbo

I have added another feature just to scrub "recent data".

oshogbo avatar Aug 29 '24 10:08 oshogbo

@oshogbo Would you rebase and resolve the test failures?

amotin avatar Oct 31 '24 01:10 amotin

@amotin Yes, let my try to fix that.

oshogbo avatar Oct 31 '24 12:10 oshogbo

@behlendorf @allanjude @amotin Thank you for the review.

oshogbo avatar Nov 18 '24 11:11 oshogbo

@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

behlendorf avatar Nov 23 '24 22:11 behlendorf

I think its fixed now.

oshogbo avatar Dec 01 '24 17:12 oshogbo

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.

behlendorf avatar Dec 03 '24 01:12 behlendorf