mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
Teach zpool scrub to scrub only blocks in error log
Added a flag '-e' in zpool scrub to scrub only blocks in error log. A user can pause, resume and cancel the error scrub by passing additional command line arguments -p -s just like a regular scrub. This involves adding a new flag, creating new libzfs interfaces, a new ioctl, and the actual iteration and read-issuing logic. Error scrubbing is executed in multiple txg to make sure pool performance is not affected. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Co-authored-by: TulsiJain tulsi.jain@delphix.com Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes #8995 Closes #12355
This commit is contained in:
committed by
Brian Behlendorf
parent
e34e15ed6d
commit
482eeef804
@@ -1685,6 +1685,47 @@ zfs_ioc_pool_scan(zfs_cmd_t *zc)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* inputs:
|
||||
* poolname name of the pool
|
||||
* scan_type scan func (pool_scan_func_t)
|
||||
* scan_command scrub pause/resume flag (pool_scrub_cmd_t)
|
||||
*/
|
||||
static const zfs_ioc_key_t zfs_keys_pool_scrub[] = {
|
||||
{"scan_type", DATA_TYPE_UINT64, 0},
|
||||
{"scan_command", DATA_TYPE_UINT64, 0},
|
||||
};
|
||||
|
||||
static int
|
||||
zfs_ioc_pool_scrub(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
|
||||
{
|
||||
spa_t *spa;
|
||||
int error;
|
||||
uint64_t scan_type, scan_cmd;
|
||||
|
||||
if (nvlist_lookup_uint64(innvl, "scan_type", &scan_type) != 0)
|
||||
return (SET_ERROR(EINVAL));
|
||||
if (nvlist_lookup_uint64(innvl, "scan_command", &scan_cmd) != 0)
|
||||
return (SET_ERROR(EINVAL));
|
||||
|
||||
if (scan_cmd >= POOL_SCRUB_FLAGS_END)
|
||||
return (SET_ERROR(EINVAL));
|
||||
|
||||
if ((error = spa_open(poolname, &spa, FTAG)) != 0)
|
||||
return (error);
|
||||
|
||||
if (scan_cmd == POOL_SCRUB_PAUSE) {
|
||||
error = spa_scrub_pause_resume(spa, POOL_SCRUB_PAUSE);
|
||||
} else if (scan_type == POOL_SCAN_NONE) {
|
||||
error = spa_scan_stop(spa);
|
||||
} else {
|
||||
error = spa_scan(spa, scan_type);
|
||||
}
|
||||
|
||||
spa_close(spa, FTAG);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
zfs_ioc_pool_freeze(zfs_cmd_t *zc)
|
||||
{
|
||||
@@ -7218,6 +7259,11 @@ zfs_ioctl_init(void)
|
||||
POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_FALSE, B_FALSE,
|
||||
zfs_keys_vdev_set_props, ARRAY_SIZE(zfs_keys_vdev_set_props));
|
||||
|
||||
zfs_ioctl_register("scrub", ZFS_IOC_POOL_SCRUB,
|
||||
zfs_ioc_pool_scrub, zfs_secpolicy_config, POOL_NAME,
|
||||
POOL_CHECK_NONE, B_TRUE, B_TRUE,
|
||||
zfs_keys_pool_scrub, ARRAY_SIZE(zfs_keys_pool_scrub));
|
||||
|
||||
/* IOCTLS that use the legacy function signature */
|
||||
|
||||
zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze,
|
||||
|
||||
Reference in New Issue
Block a user