diff options
author | nssrikanth <[email protected]> | 2021-03-02 23:57:27 +0530 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-02 10:27:27 -0800 |
commit | bedbc13daa6dfe9e0221bfadb8d8db2378deaacc (patch) | |
tree | 2b54ce4a3d625d6ff31850bcdd1f6017a4981365 /module/zfs | |
parent | 2e160dee97a4badbc318561f76ea56451c916d2f (diff) |
Cancel TRIM / initialize on FAULTED non-writeable vdevs
When a device which is actively trimming or initializing becomes
FAULTED, and therefore no longer writable, cancel the active
TRIM or initialization. When the device is merely taken offline
with `zpool offline` then stop the operation but do not cancel it.
When the device is brought back online the operation will be
resumed if possible.
Reviewed-by: Brian Behlendorf <[email protected]>
Co-authored-by: Brian Behlendorf <[email protected]>
Co-authored-by: Vipin Kumar Verma <[email protected]>
Signed-off-by: Srikanth N S <[email protected]>
Closes #11588
Diffstat (limited to 'module/zfs')
-rw-r--r-- | module/zfs/vdev_initialize.c | 10 | ||||
-rw-r--r-- | module/zfs/vdev_trim.c | 15 |
2 files changed, 19 insertions, 6 deletions
diff --git a/module/zfs/vdev_initialize.c b/module/zfs/vdev_initialize.c index 083ad2861..e9156c32f 100644 --- a/module/zfs/vdev_initialize.c +++ b/module/zfs/vdev_initialize.c @@ -553,8 +553,14 @@ vdev_initialize_thread(void *arg) vd->vdev_initialize_tree = NULL; mutex_enter(&vd->vdev_initialize_lock); - if (!vd->vdev_initialize_exit_wanted && vdev_writeable(vd)) { - vdev_initialize_change_state(vd, VDEV_INITIALIZE_COMPLETE); + if (!vd->vdev_initialize_exit_wanted) { + if (vdev_writeable(vd)) { + vdev_initialize_change_state(vd, + VDEV_INITIALIZE_COMPLETE); + } else if (vd->vdev_faulted) { + vdev_initialize_change_state(vd, + VDEV_INITIALIZE_CANCELED); + } } ASSERT(vd->vdev_initialize_thread != NULL || vd->vdev_initialize_inflight == 0); diff --git a/module/zfs/vdev_trim.c b/module/zfs/vdev_trim.c index 895957bda..deea7fedd 100644 --- a/module/zfs/vdev_trim.c +++ b/module/zfs/vdev_trim.c @@ -22,6 +22,7 @@ /* * Copyright (c) 2016 by Delphix. All rights reserved. * Copyright (c) 2019 by Lawrence Livermore National Security, LLC. + * Copyright (c) 2021 Hewlett Packard Enterprise Development LP */ #include <sys/spa.h> @@ -930,10 +931,16 @@ vdev_trim_thread(void *arg) range_tree_destroy(ta.trim_tree); mutex_enter(&vd->vdev_trim_lock); - if (!vd->vdev_trim_exit_wanted && vdev_writeable(vd)) { - vdev_trim_change_state(vd, VDEV_TRIM_COMPLETE, - vd->vdev_trim_rate, vd->vdev_trim_partial, - vd->vdev_trim_secure); + if (!vd->vdev_trim_exit_wanted) { + if (vdev_writeable(vd)) { + vdev_trim_change_state(vd, VDEV_TRIM_COMPLETE, + vd->vdev_trim_rate, vd->vdev_trim_partial, + vd->vdev_trim_secure); + } else if (vd->vdev_faulted) { + vdev_trim_change_state(vd, VDEV_TRIM_CANCELED, + vd->vdev_trim_rate, vd->vdev_trim_partial, + vd->vdev_trim_secure); + } } ASSERT(vd->vdev_trim_thread != NULL || vd->vdev_trim_inflight[0] == 0); |