Skip to content

Commit

Permalink
Allocate ABD buffer according to BUFC type in _cb functions
Browse files Browse the repository at this point in the history
In dsl_scan_scrub_cb and spa_load_verify_cb, we originally always allocated
linear ABD. Now we try to allocate scatter ABD according to the BUFC type of
the blkptr to reduce unnecessary spl slab allocation.

Also in zio_ddt_read_start, we match the parent zio->io_data ABD type for the
same reason.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
  • Loading branch information
tuxoko committed May 25, 2015
1 parent d43b5c0 commit 7d1482b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion module/zfs/dsl_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,12 @@ dsl_scan_scrub_cb(dsl_pool_t *dp,
if (needs_io && !zfs_no_scrub_io) {
vdev_t *rvd = spa->spa_root_vdev;
uint64_t maxinflight = rvd->vdev_children * zfs_top_maxinflight;
abd_t *data = abd_alloc_linear(size);
abd_t *data;

if (ARC_BUFC_IS_SCATTER(BP_GET_BUFC_TYPE(bp)))
data = abd_alloc_scatter(size);
else
data = abd_alloc_linear(size);

mutex_enter(&spa->spa_scrub_lock);
while (spa->spa_scrub_inflight >= maxinflight)
Expand Down
5 changes: 4 additions & 1 deletion module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,10 @@ spa_load_verify_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,

rio = arg;
size = BP_GET_PSIZE(bp);
data = abd_alloc_linear(size);
if (ARC_BUFC_IS_SCATTER(BP_GET_BUFC_TYPE(bp)))
data = abd_alloc_scatter(size);
else
data = abd_alloc_linear(size);

mutex_enter(&spa->spa_scrub_lock);
while (spa->spa_scrub_inflight >= spa_load_verify_maxinflight)
Expand Down
8 changes: 6 additions & 2 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2229,13 +2229,17 @@ zio_ddt_read_start(zio_t *zio)
return (ZIO_PIPELINE_CONTINUE);

for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
abd_t *tmp;
if (ddp->ddp_phys_birth == 0 || ddp == ddp_self)
continue;
ddt_bp_create(ddt->ddt_checksum, &dde->dde_key, ddp,
&blk);
if (ABD_IS_LINEAR(zio->io_data))
tmp = abd_alloc_linear(zio->io_size);
else
tmp = abd_alloc_scatter(zio->io_size);
zio_nowait(zio_read(zio, zio->io_spa, &blk,
abd_alloc_linear(zio->io_size),
zio->io_size, zio_ddt_child_read_done, dde,
tmp, zio->io_size, zio_ddt_child_read_done, dde,
zio->io_priority, ZIO_DDT_CHILD_FLAGS(zio) |
ZIO_FLAG_DONT_PROPAGATE, &zio->io_bookmark));
}
Expand Down

0 comments on commit 7d1482b

Please sign in to comment.