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

Add ability to scrub from last scrubbed txg #16301

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

oshogbo
Copy link
Contributor

@oshogbo oshogbo commented Jun 26, 2024

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)
  • 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:

@oshogbo oshogbo force-pushed the zfs_scrub_last_scrubbed_txg branch from 68edb6e to 42d967f Compare June 26, 2024 15:29
man/man7/zpoolprops.7 Show resolved Hide resolved
man/man7/zpoolprops.7 Show resolved Hide resolved
man/man7/zpoolprops.7 Show resolved Hide resolved
man/man8/zpool-scrub.8 Show resolved Hide resolved
module/zfs/spa.c Show resolved Hide resolved
module/zfs/dsl_scan.c Show resolved Hide resolved
@oshogbo oshogbo force-pushed the zfs_scrub_last_scrubbed_txg branch from 42d967f to 8d59c2c Compare August 16, 2024 11:22
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Aug 16, 2024
@behlendorf behlendorf self-requested a review August 16, 2024 23:53
@tonyhutter
Copy link
Contributor

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?

@oshogbo
Copy link
Contributor Author

oshogbo commented Aug 29, 2024

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

Sponsored-By: Wasabi Technology, Inc.
Sponsored-By: Klara Inc.
Signed-off-by: Mariusz Zaborski <[email protected]>
The `last_scrubbed_txg` property indicates the transaction
group (TXG) up to which the most recent scrub operation has
checked and repaired the dataset. This provides administrators
with insight into the data integrity status of their pool at a
specific point in time.

Sponsored-By: Wasabi Technology, Inc.
Sponsored-By: Klara Inc.
Signed-off-by: Mariusz Zaborski <[email protected]>
@oshogbo oshogbo force-pushed the zfs_scrub_last_scrubbed_txg branch from 8d59c2c to cc72197 Compare August 29, 2024 10:07
@oshogbo
Copy link
Contributor Author

oshogbo commented Aug 29, 2024

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

@oshogbo oshogbo force-pushed the zfs_scrub_last_scrubbed_txg branch from cc72197 to 4823cc2 Compare August 29, 2024 10:22
Sponsored-By: Wasabi Technology, Inc.
Sponsored-By: Klara Inc.
Signed-off-by: Mariusz Zaborski <[email protected]>
cb.cb_scrub_cmd = POOL_SCRUB_PAUSE;
} else if (is_stop) {
cb.cb_type = POOL_SCAN_NONE;
} else if (is_txg_continue) {
cb.cb_scrub_cmd = POOL_SCRUB_FROM_LAST_TXG;
Copy link
Member

Choose a reason for hiding this comment

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

It looks like -C and -R should also be mutually exclusive.

@@ -506,7 +506,8 @@ get_usage(zpool_help_t idx)
return (gettext("\tinitialize [-c | -s | -u] [-w] <pool> "
"[<device> ...]\n"));
case HELP_SCRUB:
return (gettext("\tscrub [-s | -p] [-w] [-e] <pool> ...\n"));
return (gettext("\tscrub [-s | -p] [-w] [-e] [-C] [-R] "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return (gettext("\tscrub [-s | -p] [-w] [-e] [-C] [-R] "
return (gettext("\tscrub [-e | -p | -s | -C | -R] [-w] "

They all seem to be mutually exclusive.

@@ -8391,11 +8392,13 @@ wait_callback(zpool_handle_t *zhp, void *data)
}

/*
* zpool scrub [-s | -p] [-w] [-e] <pool> ...
* zpool scrub [-s | -p] [-w] [-e] [-C] <pool> ...
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* zpool scrub [-s | -p] [-w] [-e] [-C] <pool> ...
* zpool scrub [-e | -p | -s | -C | -R] [-w] <pool> ...

Comment on lines 39 to +43
.Op Fl s Ns | Ns Fl p
.Op Fl w
.Op Fl e
.Op Fl C
.Op Fl R
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.Op Fl s Ns | Ns Fl p
.Op Fl w
.Op Fl e
.Op Fl C
.Op Fl R
.Op Ns Fl e | Ns Fl p | Fl s Ns | Fl C Ns | Fl R Ns
.Op Fl w

Comment on lines +873 to +874
ASSERT(setup_sync_arg->func > POOL_SCAN_NONE &&
setup_sync_arg->func < POOL_SCAN_FUNCS);
Copy link
Member

Choose a reason for hiding this comment

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

Just cosmetics, but I would use two ASSERT3U() instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants