Skip to content

Commit 018448a

Browse files
committed
write all disks in parallel
Signed-off-by: Paul Dagnelie <paul.dagnelie@klarasystems.com>
1 parent 4629f50 commit 018448a

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

module/zfs/spa.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6742,8 +6742,12 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
67426742
if (error == 0 && !zfs_allocatable_devs(nvroot))
67436743
error = SET_ERROR(EINVAL);
67446744

6745+
if (error == 0) {
6746+
spa->spa_is_initializing = B_TRUE;
6747+
error = vdev_create(rvd, txg, B_FALSE);
6748+
spa->spa_is_initializing = B_FALSE;
6749+
}
67456750
if (error == 0 &&
6746-
(error = vdev_create(rvd, txg, B_FALSE)) == 0 &&
67476751
(error = vdev_draid_spare_create(nvroot, rvd, &ndraid, 0)) == 0 &&
67486752
(error = spa_validate_aux(spa, nvroot, txg, VDEV_ALLOC_ADD)) == 0) {
67496753
/*

module/zfs/vdev_label.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

module/zfs/zio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,8 @@ zio_taskq_dispatch(zio_t *zio, zio_taskq_type_t q, boolean_t cutinline)
21622162
* interrupt threads may all be blocked waiting for the config lock.
21632163
* In this case, select the otherwise-unused taskq for ZIO_TYPE_NULL.
21642164
*/
2165-
if (zio->io_flags & (ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_PROBE))
2165+
if (zio->io_flags & (ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_PROBE) &&
2166+
!spa_is_initializing(spa))
21662167
t = ZIO_TYPE_NULL;
21672168

21682169
/*

0 commit comments

Comments
 (0)