Skip to content

Commit

Permalink
Illumos 5176 - lock contention on godfather zio
Browse files Browse the repository at this point in the history
5176 lock contention on godfather zio
Reviewed by: Alex Reece [email protected]
Reviewed by: George Wilson [email protected]
Reviewed by: Christopher Siden [email protected]
Reviewed by: Adam Leventhal [email protected]

References:
  https://www.illumos.org/issues/5176
  https://reviews.csiden.org/r/103/

Ported by: Turbo Fredriksson <[email protected]>
  • Loading branch information
ahrens authored and FransUrbo committed Sep 17, 2014
1 parent 2d50158 commit 0c42b85
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
10 changes: 6 additions & 4 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2614,10 +2614,12 @@ dump_block_stats(spa_t *spa)
* all async I/Os to complete.
*/
if (dump_opt['c']) {
(void) zio_wait(spa->spa_async_zio_root);
spa->spa_async_zio_root = zio_root(spa, NULL, NULL,
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE |
ZIO_FLAG_GODFATHER);
for (int i = 0; i < max_ncpus; i++) {
(void) zio_wait(spa->spa_async_zio_root[i]);
spa->spa_async_zio_root[i] = zio_root(spa, NULL, NULL,
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE |
ZIO_FLAG_GODFATHER);
}
}

if (zcb.zcb_haderrors) {
Expand Down
3 changes: 2 additions & 1 deletion include/sys/spa_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ struct spa {
uint64_t spa_failmode; /* failure mode for the pool */
uint64_t spa_delegation; /* delegation on/off */
list_t spa_config_list; /* previous cache file(s) */
zio_t *spa_async_zio_root; /* root of all async I/O */
/* per-CPU array of root of async I/O: */
zio_t **spa_async_zio_root;
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 */
Expand Down
22 changes: 17 additions & 5 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,9 @@ spa_unload(spa_t *spa)
* Wait for any outstanding async I/O to complete.
*/
if (spa->spa_async_zio_root != NULL) {
(void) zio_wait(spa->spa_async_zio_root);
for (int i = 0; i < max_ncpus; i++)
(void) zio_wait(spa->spa_async_zio_root[i]);
kmem_free(spa->spa_async_zio_root, max_ncpus * sizeof (void *));
spa->spa_async_zio_root = NULL;
}

Expand Down Expand Up @@ -2189,8 +2191,13 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
/*
* Create "The Godfather" zio to hold all async IOs
*/
spa->spa_async_zio_root = zio_root(spa, NULL, NULL,
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE | ZIO_FLAG_GODFATHER);
spa->spa_async_zio_root = kmem_alloc(max_ncpus * sizeof (void *),
KM_SLEEP);
for (int i = 0; i < max_ncpus; i++) {
spa->spa_async_zio_root[i] = zio_root(spa, NULL, NULL,
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE |
ZIO_FLAG_GODFATHER);
}

/*
* Parse the configuration into a vdev tree. We explicitly set the
Expand Down Expand Up @@ -3542,8 +3549,13 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
/*
* Create "The Godfather" zio to hold all async IOs
*/
spa->spa_async_zio_root = zio_root(spa, NULL, NULL,
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE | ZIO_FLAG_GODFATHER);
spa->spa_async_zio_root = kmem_alloc(max_ncpus * sizeof (void *),
KM_SLEEP);
for (int i = 0; i < max_ncpus; i++) {
spa->spa_async_zio_root[i] = zio_root(spa, NULL, NULL,
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE |
ZIO_FLAG_GODFATHER);
}

/*
* Create the root vdev.
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ zio_nowait(zio_t *zio)
*/
spa_t *spa = zio->io_spa;

zio_add_child(spa->spa_async_zio_root, zio);
zio_add_child(spa->spa_async_zio_root[CPU_SEQID], zio);
}

__zio_execute(zio);
Expand Down

0 comments on commit 0c42b85

Please sign in to comment.