aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/vdev_initialize.c
diff options
context:
space:
mode:
authornssrikanth <[email protected]>2021-03-02 23:57:27 +0530
committerGitHub <[email protected]>2021-03-02 10:27:27 -0800
commitbedbc13daa6dfe9e0221bfadb8d8db2378deaacc (patch)
tree2b54ce4a3d625d6ff31850bcdd1f6017a4981365 /module/zfs/vdev_initialize.c
parent2e160dee97a4badbc318561f76ea56451c916d2f (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/vdev_initialize.c')
-rw-r--r--module/zfs/vdev_initialize.c10
1 files changed, 8 insertions, 2 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);