Skip to content

Commit 9cd52d9

Browse files
pcd1193182lundman
authored andcommitted
Fix dynamic gang block headers on raidz and mirror devices
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Paul Dagnelie <paul.dagnelie@klarasystems.com> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes openzfs#17587
1 parent 713010e commit 9cd52d9

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

include/sys/vdev.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ extern uint64_t vdev_asize_to_psize_txg(vdev_t *vd, uint64_t asize,
139139
extern uint64_t vdev_psize_to_asize_txg(vdev_t *vd, uint64_t psize,
140140
uint64_t txg);
141141
extern uint64_t vdev_psize_to_asize(vdev_t *vd, uint64_t psize);
142+
extern uint64_t vdev_get_min_alloc(vdev_t *vd);
142143

143144
/*
144145
* Return the amount of space allocated for a gang block header. Note that
@@ -151,6 +152,19 @@ vdev_gang_header_asize(vdev_t *vd)
151152
return (vdev_psize_to_asize_txg(vd, SPA_OLD_GANGBLOCKSIZE, 0));
152153
}
153154

155+
/*
156+
* Return the amount of data that can be stored in a gang header. Because we
157+
* need to ensure gang headers can always be allocated (as long as there is
158+
* space available), this is the minimum allocatable size on the vdev. Note that
159+
* since the physical birth txg is not provided, this must be constant for
160+
* a given vdev. (e.g. raidz expansion can't change this)
161+
*/
162+
static inline uint64_t
163+
vdev_gang_header_psize(vdev_t *vd)
164+
{
165+
return (vdev_get_min_alloc(vd));
166+
}
167+
154168
extern int vdev_fault(spa_t *spa, uint64_t guid, vdev_aux_t aux);
155169
extern int vdev_degrade(spa_t *spa, uint64_t guid, vdev_aux_t aux);
156170
extern int vdev_online(spa_t *spa, uint64_t guid, uint64_t flags,

include/sys/vdev_impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,6 @@ extern uint64_t vdev_default_asize(vdev_t *vd, uint64_t psize, uint64_t txg);
621621
extern uint64_t vdev_default_min_asize(vdev_t *vd);
622622
extern uint64_t vdev_get_min_asize(vdev_t *vd);
623623
extern void vdev_set_min_asize(vdev_t *vd);
624-
extern uint64_t vdev_get_min_alloc(vdev_t *vd);
625624
extern uint64_t vdev_get_nparity(vdev_t *vd);
626625
extern uint64_t vdev_get_ndisks(vdev_t *vd);
627626

module/zfs/zio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,8 +2956,8 @@ zio_gang_tree_assemble(zio_t *gio, blkptr_t *bp, zio_gang_node_t **gnpp)
29562956
for (int dva = 0; dva < BP_GET_NDVAS(bp); dva++) {
29572957
vdev_t *vd = vdev_lookup_top(gio->io_spa,
29582958
DVA_GET_VDEV(&bp->blk_dva[dva]));
2959-
uint64_t asize = vdev_gang_header_asize(vd);
2960-
gangblocksize = MIN(gangblocksize, asize);
2959+
uint64_t psize = vdev_gang_header_psize(vd);
2960+
gangblocksize = MIN(gangblocksize, psize);
29612961
}
29622962
spa_config_exit(gio->io_spa, SCL_VDEV, FTAG);
29632963
} else {

module/zfs/zio_checksum.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,11 @@ zio_checksum_error(zio_t *zio, zio_bad_cksum_t *info)
569569
SPA_OLD_GANGBLOCKSIZE, offset, info);
570570
if (error == 0) {
571571
ASSERT3U(zio->io_child_type, ==, ZIO_CHILD_VDEV);
572-
zio_t *pio = zio_unique_parent(zio);
572+
zio_t *pio;
573+
for (pio = zio_unique_parent(zio);
574+
pio->io_child_type != ZIO_CHILD_GANG;
575+
pio = zio_unique_parent(pio))
576+
;
573577
zio_gang_node_t *gn = pio->io_private;
574578
gn->gn_gangblocksize = SPA_OLD_GANGBLOCKSIZE;
575579
}

0 commit comments

Comments
 (0)