]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Illumos 6414 - vdev_config_sync could be simpler
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 27 Jan 2016 01:27:46 +0000 (17:27 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 28 Jan 2016 17:44:39 +0000 (12:44 -0500)
6414 vdev_config_sync could be simpler
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>

References:
  https://www.illumos.org/issues/6414
  https://github.com/illumos/illumos-gate/commit/eb5bb58

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
include/sys/vdev.h
module/zfs/spa.c
module/zfs/vdev_label.c

index 365789e524d6d3375f831f253a7bee20cc1bb65c..7d64cf6bceab025d820379b38c6ff84c3196097b 100644 (file)
@@ -121,8 +121,7 @@ extern void vdev_queue_io_done(zio_t *zio);
 
 extern void vdev_config_dirty(vdev_t *vd);
 extern void vdev_config_clean(vdev_t *vd);
-extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg,
-    boolean_t);
+extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg);
 
 extern void vdev_state_dirty(vdev_t *vd);
 extern void vdev_state_clean(vdev_t *vd);
index 787b03d2991ef1db59fc8d03824681533235a9c7..ea4eb9f9a8200ce01ade36de1a633af1fcc9642c 100644 (file)
@@ -6518,16 +6518,10 @@ spa_sync(spa_t *spa, uint64_t txg)
                                if (svdcount == SPA_DVAS_PER_BP)
                                        break;
                        }
-                       error = vdev_config_sync(svd, svdcount, txg, B_FALSE);
-                       if (error != 0)
-                               error = vdev_config_sync(svd, svdcount, txg,
-                                   B_TRUE);
+                       error = vdev_config_sync(svd, svdcount, txg);
                } else {
                        error = vdev_config_sync(rvd->vdev_child,
-                           rvd->vdev_children, txg, B_FALSE);
-                       if (error != 0)
-                               error = vdev_config_sync(rvd->vdev_child,
-                                   rvd->vdev_children, txg, B_TRUE);
+                           rvd->vdev_children, txg);
                }
 
                if (error == 0)
index 419cbc1a0ebe8412986dc79823e19813603e357d..9d4229ac89ead0f9d18a7f3a2d27345a4ed83380 100644 (file)
@@ -1187,15 +1187,16 @@ vdev_label_sync_list(spa_t *spa, int l, uint64_t txg, int flags)
  * at any time, you can just call it again, and it will resume its work.
  */
 int
-vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
+vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
 {
        spa_t *spa = svd[0]->vdev_spa;
        uberblock_t *ub = &spa->spa_uberblock;
        vdev_t *vd;
        zio_t *zio;
-       int error;
+       int error = 0;
        int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL;
 
+retry:
        /*
         * Normally, we don't want to try too hard to write every label and
         * uberblock.  If there is a flaky disk, we don't want the rest of the
@@ -1203,8 +1204,11 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
         * single label out, we should retry with ZIO_FLAG_TRYHARD before
         * bailing out and declaring the pool faulted.
         */
-       if (tryhard)
+       if (error != 0) {
+               if ((flags & ZIO_FLAG_TRYHARD) != 0)
+                       return (error);
                flags |= ZIO_FLAG_TRYHARD;
+       }
 
        ASSERT(ub->ub_txg <= txg);
 
@@ -1248,7 +1252,7 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
         * are committed to stable storage before the uberblock update.
         */
        if ((error = vdev_label_sync_list(spa, 0, txg, flags)) != 0)
-               return (error);
+               goto retry;
 
        /*
         * Sync the uberblocks to all vdevs in svd[].
@@ -1266,7 +1270,7 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
         *      to the new uberblocks.
         */
        if ((error = vdev_uberblock_sync_list(svd, svdcount, ub, flags)) != 0)
-               return (error);
+               goto retry;
 
        /*
         * Sync out odd labels for every dirty vdev.  If the system dies
@@ -1278,5 +1282,8 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
         * to disk to ensure that all odd-label updates are committed to
         * stable storage before the next transaction group begins.
         */
-       return (vdev_label_sync_list(spa, 1, txg, flags));
+       if ((error = vdev_label_sync_list(spa, 1, txg, flags)) != 0)
+               goto retry;
+
+       return (0);
 }