From dce1bf99ecbcb6a82756329f4a87cea6c8284277 Mon Sep 17 00:00:00 2001 From: vermavipinkumar <75025470+vermavipinkumar@users.noreply.github.com> Date: Wed, 26 May 2021 00:02:07 +0530 Subject: [PATCH] Propagate vdev state due to invalid label corruption Propagate vdev child state to parents on invalid label Add VDEV_AUX_BAD_LABEL to print_import_config() Reviewed-by: Brian Behlendorf Reviewed-by: Mark Maybee Co-authored-by: Srikanth N S Signed-off-by: Vipin Kumar Verma Closes #12088 --- cmd/zpool/zpool_main.c | 9 +++++++++ module/zfs/vdev.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 8d809acb21..d7d93c4da3 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -32,6 +32,7 @@ * Copyright (c) 2017, Intel Corporation. * Copyright (c) 2019, loli10K * Copyright (c) 2021, Colm Buckley + * Copyright [2021] Hewlett Packard Enterprise Development LP */ #include @@ -2379,6 +2380,10 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name, (void) printf(gettext("all children offline")); break; + case VDEV_AUX_BAD_LABEL: + (void) printf(gettext("invalid label")); + break; + default: (void) printf(gettext("corrupted data")); break; @@ -2521,6 +2526,10 @@ print_import_config(status_cbdata_t *cb, const char *name, nvlist_t *nv, (void) printf(gettext("all children offline")); break; + case VDEV_AUX_BAD_LABEL: + (void) printf(gettext("invalid label")); + break; + default: (void) printf(gettext("corrupted data")); break; diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index d00782d934..5e14d71f19 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -28,6 +28,7 @@ * Copyright 2017 Joyent, Inc. * Copyright (c) 2017, Intel Corporation. * Copyright (c) 2019, Datto Inc. All rights reserved. + * Copyright [2021] Hewlett Packard Enterprise Development LP */ #include @@ -2222,7 +2223,7 @@ vdev_validate(vdev_t *vd) txg = spa_last_synced_txg(spa); if ((label = vdev_label_read_config(vd, txg)) == NULL) { - vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN, + vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN, VDEV_AUX_BAD_LABEL); vdev_dbgmsg(vd, "vdev_validate: failed reading config for " "txg %llu", (u_longlong_t)txg);