summaryrefslogtreecommitdiffstats
path: root/module/zfs/vdev_trim.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_trim.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_trim.c')
-rw-r--r--module/zfs/vdev_trim.c15
1 files changed, 11 insertions, 4 deletions
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);