]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Report pool suspended due to MMP
authorOlaf Faaland <faaland1@llnl.gov>
Thu, 15 Mar 2018 17:56:55 +0000 (10:56 -0700)
committerTony Hutter <hutter2@llnl.gov>
Tue, 8 May 2018 00:19:56 +0000 (17:19 -0700)
When the pool is suspended, record whether it was due to an I/O error or
due to MMP writes failing to succeed within the required time.

Change spa_suspended from uint8_t to zio_suspend_reason_t to store the
reason.

When userspace queries pool status via spa_tryimport(), report the
reason the pool was suspended in a new key,
ZPOOL_CONFIG_SUSPENDED_REASON.

In libzfs, when interpreting the returned config nvlist, report
suspension due to MMP with a new pool status enum value,
ZPOOL_STATUS_IO_FAILURE_MMP.

In status_callback(), which generates and emits the message when 'zpool
status' is executed, add a case to print an appropriate message for the
new pool status enum value.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #7296

cmd/zpool/zpool_main.c
include/libzfs.h
include/sys/fs/zfs.h
include/sys/spa_impl.h
include/sys/zio.h
lib/libzfs/libzfs_status.c
module/zfs/mmp.c
module/zfs/spa.c
module/zfs/spa_misc.c
module/zfs/zio.c

index 1cfff3ade36a29238a14d907678cab457e8c09ab..b07569389f825196b15739ce81e83889b48dbcbc 100644 (file)
@@ -6395,6 +6395,15 @@ status_callback(zpool_handle_t *zhp, void *data)
                    "to be recovered.\n"));
                break;
 
+       case ZPOOL_STATUS_IO_FAILURE_MMP:
+               (void) printf(gettext("status: The pool is suspended because "
+                   "multihost writes failed or were delayed;\n\tanother "
+                   "system could import the pool undetected.\n"));
+               (void) printf(gettext("action: Make sure the pool's devices "
+                   "are connected, then reboot your system and\n\timport the "
+                   "pool.\n"));
+               break;
+
        case ZPOOL_STATUS_IO_FAILURE_WAIT:
        case ZPOOL_STATUS_IO_FAILURE_CONTINUE:
                (void) printf(gettext("status: One or more devices are "
index 147589bbfdad3b8b4054d74f5a4c1ed99cf51dc5..945bd5b86064cb33ca9d207c99ac229b03d8b32c 100644 (file)
@@ -331,6 +331,7 @@ typedef enum {
        ZPOOL_STATUS_HOSTID_REQUIRED,   /* multihost=on and hostid=0 */
        ZPOOL_STATUS_IO_FAILURE_WAIT,   /* failed I/O, failmode 'wait' */
        ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */
+       ZPOOL_STATUS_IO_FAILURE_MMP,    /* failed MMP, failmode not 'panic' */
        ZPOOL_STATUS_BAD_LOG,           /* cannot read log chain(s) */
        ZPOOL_STATUS_ERRATA,            /* informational errata available */
 
index 13b25a6956394d49fa4ace44b9e63d245e097b0e..b7912313bd16236a5cb7b555eb08591fce2c7a4f 100644 (file)
@@ -638,6 +638,7 @@ typedef struct zpool_rewind_policy {
 #define        ZPOOL_CONFIG_RESILVER_TXG       "resilver_txg"
 #define        ZPOOL_CONFIG_COMMENT            "comment"
 #define        ZPOOL_CONFIG_SUSPENDED          "suspended"     /* not stored on disk */
+#define        ZPOOL_CONFIG_SUSPENDED_REASON   "suspended_reason"      /* not stored */
 #define        ZPOOL_CONFIG_TIMESTAMP          "timestamp"     /* not stored on disk */
 #define        ZPOOL_CONFIG_BOOTFS             "bootfs"        /* not stored on disk */
 #define        ZPOOL_CONFIG_MISSING_DEVICES    "missing_vdevs" /* not stored on disk */
index 06de244218f3ecd1665e063d62e5746a41ecee32..73ad1c60c5c6c4bc8c1304a927f67a897f02f159 100644 (file)
@@ -233,7 +233,7 @@ struct spa {
        zio_t           *spa_suspend_zio_root;  /* root of all suspended I/O */
        kmutex_t        spa_suspend_lock;       /* protects suspend_zio_root */
        kcondvar_t      spa_suspend_cv;         /* notification of resume */
-       uint8_t         spa_suspended;          /* pool is suspended */
+       zio_suspend_reason_t    spa_suspended;  /* pool is suspended */
        uint8_t         spa_claiming;           /* pool is doing zil_claim() */
        boolean_t       spa_debug;              /* debug enabled? */
        boolean_t       spa_is_root;            /* pool is root */
index 0d741f8e2ee467a5e85b7519663e35141d7a566f..4b0eecc2e4320b3321bd08213785ed0338fb171c 100644 (file)
@@ -144,6 +144,12 @@ enum zio_checksum {
 #define        ZIO_FAILURE_MODE_CONTINUE       1
 #define        ZIO_FAILURE_MODE_PANIC          2
 
+typedef enum zio_suspend_reason {
+       ZIO_SUSPEND_NONE = 0,
+       ZIO_SUSPEND_IOERR,
+       ZIO_SUSPEND_MMP,
+} zio_suspend_reason_t;
+
 enum zio_flag {
        /*
         * Flags inherited by gang, ddt, and vdev children,
@@ -577,7 +583,7 @@ extern enum zio_checksum zio_checksum_dedup_select(spa_t *spa,
 extern enum zio_compress zio_compress_select(spa_t *spa,
     enum zio_compress child, enum zio_compress parent);
 
-extern void zio_suspend(spa_t *spa, zio_t *zio);
+extern void zio_suspend(spa_t *spa, zio_t *zio, zio_suspend_reason_t);
 extern int zio_resume(spa_t *spa);
 extern void zio_resume_wait(spa_t *spa);
 
index 05a9afce8a8ab6b7f86121b556533759422d5ac2..6cdcd38272fd6032a4fc977088defd721ce4a735 100644 (file)
@@ -274,10 +274,16 @@ check_status(nvlist_t *config, boolean_t isimport, zpool_errata_t *erratap)
                return (ZPOOL_STATUS_BAD_GUID_SUM);
 
        /*
-        * Check whether the pool has suspended due to failed I/O.
+        * Check whether the pool has suspended.
         */
        if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_SUSPENDED,
            &suspended) == 0) {
+               uint64_t reason;
+
+               if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_SUSPENDED_REASON,
+                   &reason) == 0 && reason == ZIO_SUSPEND_MMP)
+                       return (ZPOOL_STATUS_IO_FAILURE_MMP);
+
                if (suspended == ZIO_FAILURE_MODE_CONTINUE)
                        return (ZPOOL_STATUS_IO_FAILURE_CONTINUE);
                return (ZPOOL_STATUS_IO_FAILURE_WAIT);
index a08e0864e65c8c8d1eb1a0ecf72bd28c0ea5bfb6..fc8346dc3af66583fe21bb19a5b0863729471cce 100644 (file)
@@ -519,7 +519,7 @@ mmp_thread(spa_t *spa)
                            "succeeded in over %llus; suspending pool",
                            spa_name(spa),
                            NSEC2SEC(start - mmp->mmp_last_write));
-                       zio_suspend(spa, NULL);
+                       zio_suspend(spa, NULL, ZIO_SUSPEND_MMP);
                }
 
                if (multihost && !suspended)
index a7a2f628174bf78543c115d8628f4273d28c418b..561f4d04bfc9c0a17354880e419157afb06126ed 100644 (file)
@@ -3778,10 +3778,14 @@ spa_get_stats(const char *name, nvlist_t **config,
                            ZPOOL_CONFIG_ERRCOUNT,
                            spa_get_errlog_size(spa)) == 0);
 
-                       if (spa_suspended(spa))
+                       if (spa_suspended(spa)) {
                                VERIFY(nvlist_add_uint64(*config,
                                    ZPOOL_CONFIG_SUSPENDED,
                                    spa->spa_failmode) == 0);
+                               VERIFY(nvlist_add_uint64(*config,
+                                   ZPOOL_CONFIG_SUSPENDED_REASON,
+                                   spa->spa_suspended) == 0);
+                       }
 
                        spa_add_spares(spa, *config);
                        spa_add_l2cache(spa, *config);
@@ -6969,7 +6973,7 @@ spa_sync(spa_t *spa, uint64_t txg)
 
                if (error == 0)
                        break;
-               zio_suspend(spa, NULL);
+               zio_suspend(spa, NULL, ZIO_SUSPEND_IOERR);
                zio_resume_wait(spa);
        }
        dmu_tx_commit(tx);
index 3787e010f60acb3f7bfe275a8018f8bef19060d7..e92c39482455f211e3829cce7798e78dff6391d6 100644 (file)
@@ -1691,7 +1691,7 @@ spa_get_failmode(spa_t *spa)
 boolean_t
 spa_suspended(spa_t *spa)
 {
-       return (spa->spa_suspended);
+       return (spa->spa_suspended != ZIO_SUSPEND_NONE);
 }
 
 uint64_t
index cd0a473e0e13d298e7197547e00c2507c73bfe4e..9a465e1be66759a8da1aae21bfee972bd979a440 100644 (file)
@@ -1864,7 +1864,7 @@ zio_reexecute(zio_t *pio)
 }
 
 void
-zio_suspend(spa_t *spa, zio_t *zio)
+zio_suspend(spa_t *spa, zio_t *zio, zio_suspend_reason_t reason)
 {
        if (spa_get_failmode(spa) == ZIO_FAILURE_MODE_PANIC)
                fm_panic("Pool '%s' has encountered an uncorrectable I/O "
@@ -1883,7 +1883,7 @@ zio_suspend(spa_t *spa, zio_t *zio)
                    ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE |
                    ZIO_FLAG_GODFATHER);
 
-       spa->spa_suspended = B_TRUE;
+       spa->spa_suspended = reason;
 
        if (zio != NULL) {
                ASSERT(!(zio->io_flags & ZIO_FLAG_GODFATHER));
@@ -1906,7 +1906,7 @@ zio_resume(spa_t *spa)
         * Reexecute all previously suspended i/o.
         */
        mutex_enter(&spa->spa_suspend_lock);
-       spa->spa_suspended = B_FALSE;
+       spa->spa_suspended = ZIO_SUSPEND_NONE;
        cv_broadcast(&spa->spa_suspend_cv);
        pio = spa->spa_suspend_zio_root;
        spa->spa_suspend_zio_root = NULL;
@@ -3975,7 +3975,7 @@ zio_done(zio_t *zio)
                         * We'd fail again if we reexecuted now, so suspend
                         * until conditions improve (e.g. device comes online).
                         */
-                       zio_suspend(zio->io_spa, zio);
+                       zio_suspend(zio->io_spa, zio, ZIO_SUSPEND_IOERR);
                } else {
                        /*
                         * Reexecution is potentially a huge amount of work.