mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
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 <behlendorf1@llnl.gov> Co-authored-by: Brian Behlendorf <behlendorf1@llnl.gov> Co-authored-by: Vipin Kumar Verma <vipin.verma@hpe.com> Signed-off-by: Srikanth N S <srikanth.nagasubbaraoseetharaman@hpe.com> Closes #11588
This commit is contained in:
@@ -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);
|
||||
|
||||
+11
-4
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user