]> granicus.if.org Git - zfs/commitdiff
OpenZFS 9189 - Add debug to vdev_label_read_config when txg check fails
authorPavel Zakharov <pavel.zakharov@delphix.com>
Wed, 14 Sep 2016 15:01:40 +0000 (11:01 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 14 May 2018 18:32:49 +0000 (14:32 -0400)
These changes were added to help debug issue #9187.

Essentially, in the original bug, vdev_validate() seems to fails in
vdev_label_read_config() and prints "failed reading config". This could
happen because either:
1. The labels are actually corrupt and zio_wait() fails for all of them
2. The labels were discarded because they didn't pass the txg check.

Beyond 9187, having debug info when case 2 happens could be useful in
other scenarios, such as zpool import.

Authored by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Prashanth Sreenivasa <pks@delphix.com>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Approved by: Matt Ahrens <mahrens@delphix.com>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
OpenZFS-issue: https://illumos.org/issues/9189
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f6af1b7
Closes #7533

module/zfs/vdev.c
module/zfs/vdev_label.c

index cebac3bb90007e37971053750e3276369881550f..7bb27f0ec7e495417b4bbed849958a5b9b18cd55 100644 (file)
@@ -1704,7 +1704,8 @@ vdev_validate(vdev_t *vd)
        if ((label = vdev_label_read_config(vd, txg)) == NULL) {
                vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
                    VDEV_AUX_BAD_LABEL);
-               vdev_dbgmsg(vd, "vdev_validate: failed reading config");
+               vdev_dbgmsg(vd, "vdev_validate: failed reading config for "
+                   "txg %llu", (u_longlong_t)txg);
                return (0);
        }
 
index 85d133a5ac71c94bcbfd33e0e1c3166b61c0af1b..e5ba7cdc20f0f735fb27c3393f338e86d9a1969f 100644 (file)
@@ -673,6 +673,7 @@ vdev_label_read_config(vdev_t *vd, uint64_t txg)
        abd_t *vp_abd;
        zio_t *zio;
        uint64_t best_txg = 0;
+       uint64_t label_txg = 0;
        int error = 0;
        int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL |
            ZIO_FLAG_SPECULATIVE;
@@ -698,8 +699,6 @@ retry:
                if (zio_wait(zio) == 0 &&
                    nvlist_unpack(vp->vp_nvlist, sizeof (vp->vp_nvlist),
                    &label, 0) == 0) {
-                       uint64_t label_txg = 0;
-
                        /*
                         * Auxiliary vdevs won't have txg values in their
                         * labels and newly added vdevs may not have been
@@ -730,6 +729,15 @@ retry:
                goto retry;
        }
 
+       /*
+        * We found a valid label but it didn't pass txg restrictions.
+        */
+       if (config == NULL && label_txg != 0) {
+               vdev_dbgmsg(vd, "label discarded as txg is too large "
+                   "(%llu > %llu)", (u_longlong_t)label_txg,
+                   (u_longlong_t)txg);
+       }
+
        abd_free(vp_abd);
 
        return (config);