Skip to content

Commit dfdb987

Browse files
committed
Rob's feedback
Signed-off-by: Paul Dagnelie <[email protected]>
1 parent 42819c3 commit dfdb987

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

include/sys/zio.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,37 @@ typedef struct zio_eck {
5959

6060
/*
6161
* Gang block headers are self-checksumming and contain an array
62-
* of block pointers.
62+
* of block pointers. The old gang block size has enough room for 3 blkptrs,
63+
* while new gang blocks can store more.
64+
*
65+
* Layout:
66+
* +--------+--------+--------+-----+---------+-----------+
67+
* | | | | | | |
68+
* | blkptr | blkptr | blkptr | ... | padding | zio_eck_t |
69+
* | 1 | 2 | 3 | | | |
70+
* +--------+--------+--------+-----+---------+-----------+
71+
* 128B 128B 128B 88B 40B
6372
*/
6473
#define SPA_OLD_GANGBLOCKSIZE SPA_MINBLOCKSIZE
6574
typedef void zio_gbh_phys_t;
6675

6776
static inline uint64_t
6877
gbh_nblkptrs(uint64_t size) {
78+
ASSERT(ISP2(size));
6979
return ((size - sizeof (zio_eck_t)) / sizeof (blkptr_t));
7080
}
7181

7282
static inline zio_eck_t *
7383
gbh_eck(zio_gbh_phys_t *gbh, uint64_t size) {
84+
ASSERT(ISP2(size));
7485
return ((zio_eck_t *)((uintptr_t)gbh + size - sizeof (zio_eck_t)));
7586
}
7687

88+
static inline blkptr_t *
89+
gbh_bp(zio_gbh_phys_t *gbh, int bp) {
90+
return (&((blkptr_t *)gbh)[bp]);
91+
}
92+
7793
enum zio_checksum {
7894
ZIO_CHECKSUM_INHERIT = 0,
7995
ZIO_CHECKSUM_ON,

module/zfs/zio.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,13 +2751,12 @@ zio_resume_wait(spa_t *spa)
27512751
*
27522752
* A gang block consists of a a gang header and up to gbh_nblkptrs(size)
27532753
* gang members. The gang header is like an indirect block: it's an array
2754-
* of block pointers, though the header has a small tail (zio_gb_tail_t)
2755-
* that stores a version number (for future compatibility) and an embedded
2756-
* checksum. It is allocated using only a single sector as the requested
2757-
* size, and hence is allocatable regardless of fragmentation. Its size
2758-
* is determined by the smallest allocatable asize of the vdevs it was
2759-
* allocated on. The gang header's bps point to its gang members,
2760-
* which hold the data.
2754+
* of block pointers, though the header has a small tail (a zio_eck_t)
2755+
* that stores an embedded checksum. It is allocated using only a single
2756+
* sector as the requested size, and hence is allocatable regardless of
2757+
* fragmentation. Its size is determined by the smallest allocatable
2758+
* asize of the vdevs it was allocated on. The gang header's bps point
2759+
* to its gang members, which hold the data.
27612760
*
27622761
* Gang blocks are self-checksumming, using the bp's <vdev, offset, txg>
27632762
* as the verifier to ensure uniqueness of the SHA256 checksum.
@@ -3010,7 +3009,7 @@ zio_gang_tree_assemble_done(zio_t *zio)
30103009
abd_free(zio->io_abd);
30113010

30123011
for (int g = 0; g < gbh_nblkptrs(gn->gn_gangblocksize); g++) {
3013-
blkptr_t *gbp = &((blkptr_t *)gn->gn_gbh)[g];
3012+
blkptr_t *gbp = gbh_bp(gn->gn_gbh, g);
30143013
if (!BP_IS_GANG(gbp))
30153014
continue;
30163015
zio_gang_tree_assemble(gio, gbp, &gn->gn_child[g]);
@@ -3039,7 +3038,7 @@ zio_gang_tree_issue(zio_t *pio, zio_gang_node_t *gn, blkptr_t *bp, abd_t *data,
30393038
gn->gn_gangblocksize)->zec_magic, ==, ZEC_MAGIC);
30403039

30413040
for (int g = 0; g < gbh_nblkptrs(gn->gn_gangblocksize); g++) {
3042-
blkptr_t *gbp = &((blkptr_t *)gn->gn_gbh)[g];
3041+
blkptr_t *gbp = gbh_bp(gn->gn_gbh, g);
30433042
if (BP_IS_HOLE(gbp))
30443043
continue;
30453044
zio_gang_tree_issue(zio, gn->gn_child[g], gbp, data,
@@ -4399,7 +4398,7 @@ zio_dva_unallocate(zio_t *zio, zio_gang_node_t *gn, blkptr_t *bp)
43994398
if (gn != NULL) {
44004399
for (int g = 0; g < gbh_nblkptrs(gn->gn_gangblocksize); g++) {
44014400
zio_dva_unallocate(zio, gn->gn_child[g],
4402-
&((blkptr_t *)gn->gn_gbh)[g]);
4401+
gbh_bp(gn->gn_gbh, g));
44034402
}
44044403
}
44054404
}
@@ -5344,6 +5343,7 @@ zio_dva_throttle_done(zio_t *zio)
53445343
* Parents of gang children can have two flavors -- ones that allocated
53455344
* the gang header (will have ZIO_FLAG_IO_REWRITE set) and ones that
53465345
* allocated the constituent blocks. The first use their parent as tag.
5346+
* We set the size to match the original allocation call for that case.
53475347
*/
53485348
if (pio->io_child_type == ZIO_CHILD_GANG &&
53495349
(pio->io_flags & ZIO_FLAG_IO_REWRITE)) {

0 commit comments

Comments
 (0)