@@ -1117,8 +1117,9 @@ vdev_aux_label_generate(vdev_t *vd, boolean_t reason_spare)
11171117 * same leaf vdev in the vdev we're creating -- e.g. mirroring a disk with
11181118 * itself.
11191119 */
1120- int
1121- vdev_label_init (vdev_t * vd , uint64_t crtxg , vdev_labeltype_t reason )
1120+ static int
1121+ vdev_label_init_impl (vdev_t * vd , zio_t * pio , uint64_t crtxg ,
1122+ vdev_labeltype_t reason )
11221123{
11231124 spa_t * spa = vd -> vdev_spa ;
11241125 nvlist_t * label ;
@@ -1130,7 +1131,6 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
11301131 abd_t * sc_abd = NULL ;
11311132 abd_t * toc_abd = NULL ;
11321133 abd_t * ub_abd2 = NULL ;
1133- zio_t * zio ;
11341134 char * buf ;
11351135 size_t buflen ;
11361136 int error ;
@@ -1145,8 +1145,8 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
11451145 ASSERT (spa_config_held (spa , SCL_ALL , RW_WRITER ) == SCL_ALL );
11461146
11471147 for (int c = 0 ; c < vd -> vdev_children ; c ++ )
1148- if ((error = vdev_label_init (vd -> vdev_child [c ],
1149- crtxg , reason )) != 0 )
1148+ if ((error = vdev_label_init_impl (vd -> vdev_child [c ],
1149+ pio , crtxg , reason )) != 0 )
11501150 return (error );
11511151
11521152 /* Track the creation time for this vdev */
@@ -1279,9 +1279,9 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
12791279 abd_zero (bootenv , VDEV_PAD_SIZE );
12801280
12811281 /*
1282- * Write everything in parallel.
1282+ * Write pieces that we need immediately in parallel.
12831283 */
1284- zio = zio_root (spa , NULL , NULL , flags );
1284+ zio_t * zio = zio_root (spa , NULL , NULL , flags );
12851285
12861286 for (int l = 0 ; l < VDEV_LABELS ; l ++ ) {
12871287
@@ -1356,7 +1356,7 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
13561356 for (int u = 0 ;
13571357 u < VDEV_LARGE_UBERBLOCK_RING / SPA_MAXBLOCKSIZE ;
13581358 u ++ ) {
1359- vdev_label_write (zio , vd , l , B_TRUE , ub_abd2 ,
1359+ vdev_label_write (pio , vd , l , B_TRUE , ub_abd2 ,
13601360 VDEV_LARGE_UBERBLOCK_RING +
13611361 u * SPA_MAXBLOCKSIZE , SPA_MAXBLOCKSIZE ,
13621362 NULL , NULL , flags );
@@ -1397,6 +1397,19 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
13971397 return (error );
13981398}
13991399
1400+ int
1401+ vdev_label_init (vdev_t * vd , uint64_t crtxg , vdev_labeltype_t reason )
1402+ {
1403+ zio_t * zio = zio_root (vd -> vdev_spa , NULL , NULL ,
1404+ ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL | ZIO_FLAG_TRYHARD );
1405+ int error = vdev_label_init_impl (vd , zio , crtxg , reason );
1406+
1407+ int ioerr = zio_wait (zio );
1408+ if (error == 0 )
1409+ error = ioerr ;
1410+ return (error );
1411+ }
1412+
14001413/*
14011414 * Done callback for vdev_label_read_bootenv_impl. If this is the first
14021415 * callback to finish, store our abd in the callback pointer. Otherwise, we
0 commit comments