Skip to content

Commit

Permalink
Make sure free ZIO sizes are correct for gang blocks.
Browse files Browse the repository at this point in the history
Currently, the PSIZE of the block pointer is used as the I/O size for
all free ZIOs. This is incorrect for gang header blocks, for which
PSIZE is the logical size of the gang block data.

This patch fixes the issue by using SPA_GANGBLOCKSIZE as the I/O size
for "free gang header block" ZIOs.
  • Loading branch information
dechamps committed Sep 12, 2012
1 parent 51c1a59 commit 19afab1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/sys/zio.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
boolean_t labels);

extern zio_t *zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg,
const blkptr_t *bp, enum zio_flag flags);
const blkptr_t *bp, uint64_t size, enum zio_flag flags);

extern int zio_alloc_zil(spa_t *spa, uint64_t txg, blkptr_t *new_bp,
blkptr_t *old_bp, uint64_t size, boolean_t use_slog);
Expand Down
5 changes: 3 additions & 2 deletions module/zfs/dsl_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ void
dsl_free_sync(zio_t *pio, dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp)
{
ASSERT(dsl_pool_sync_context(dp));
zio_nowait(zio_free_sync(pio, dp->dp_spa, txg, bpp, pio->io_flags));
zio_nowait(zio_free_sync(pio, dp->dp_spa, txg, bpp, BP_GET_PSIZE(bpp),
pio->io_flags));
}

int
Expand Down Expand Up @@ -1431,7 +1432,7 @@ dsl_scan_free_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
return (ERESTART);

zio_nowait(zio_free_sync(scn->scn_zio_root, scn->scn_dp->dp_spa,
dmu_tx_get_txg(tx), bp, 0));
dmu_tx_get_txg(tx), bp, BP_GET_PSIZE(bp), 0));
dsl_dir_diduse_space(tx->tx_pool->dp_free_dir, DD_USED_HEAD,
-bp_get_dsize_sync(scn->scn_dp->dp_spa, bp),
-BP_GET_PSIZE(bp), -BP_GET_UCSIZE(bp), tx);
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -5288,7 +5288,7 @@ spa_free_sync_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
zio_t *zio = arg;

zio_nowait(zio_free_sync(zio, zio->io_spa, dmu_tx_get_txg(tx), bp,
zio->io_flags));
BP_GET_PSIZE(bp), zio->io_flags));
return (0);
}

Expand Down
8 changes: 4 additions & 4 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ zio_free(spa_t *spa, uint64_t txg, const blkptr_t *bp)

zio_t *
zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
enum zio_flag flags)
uint64_t size, enum zio_flag flags)
{
zio_t *zio;

Expand All @@ -768,7 +768,7 @@ zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
ASSERT(spa_syncing_txg(spa) == txg);
ASSERT(spa_sync_pass(spa) <= SYNC_PASS_DEFERRED_FREE);

zio = zio_create(pio, spa, txg, bp, NULL, BP_GET_PSIZE(bp),
zio = zio_create(pio, spa, txg, bp, NULL, size,
NULL, NULL, ZIO_TYPE_FREE, ZIO_PRIORITY_FREE, flags,
NULL, 0, NULL, ZIO_STAGE_OPEN, ZIO_FREE_PIPELINE);

Expand Down Expand Up @@ -1594,7 +1594,7 @@ zio_t *
zio_free_gang(zio_t *pio, blkptr_t *bp, zio_gang_node_t *gn, void *data)
{
return (zio_free_sync(pio, pio->io_spa, pio->io_txg, bp,
ZIO_GANG_CHILD_FLAGS(pio)));
SPA_GANGBLOCKSIZE, ZIO_GANG_CHILD_FLAGS(pio)));
}

/* ARGSUSED */
Expand Down Expand Up @@ -1730,7 +1730,7 @@ zio_gang_tree_issue(zio_t *pio, zio_gang_node_t *gn, blkptr_t *bp, void *data)
}
}

if (gn == gio->io_gang_tree)
if (gn == gio->io_gang_tree && gio->io_data != NULL)
ASSERT3P((char *)gio->io_data + gio->io_size, ==, data);

if (zio != pio)
Expand Down

0 comments on commit 19afab1

Please sign in to comment.