Skip to content

Commit fbecd73

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: fix zoned GC data corruption due to wrong bv_offset
xfs_zone_gc_write_chunk writes out the data buffer read in earlier using the same bio, and currenly looks at bv_offset for the offset into the scratch folio for that. But commit 26064d3 ("block: fix adding folio to bio") changed how bv_page and bv_offset are calculated for adding larger folios, breaking this fragile logic. Switch to extracting the full physical address from the old bio_vec, and calculate the offset into the folio from that instead. This fixes data corruption during garbage collection with heavy rockdsb workloads. Thanks to Hans for tracking down the culprit commit during long bisection sessions. Fixes: 26064d3 ("block: fix adding folio to bio") Fixes: 080d01c ("xfs: implement zoned garbage collection") Reported-by: Hans Holmberg <Hans.Holmberg@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hans Holmberg <Hans.Holmberg@wdc.com> Tested-by: Hans Holmberg <Hans.Holmberg@wdc.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 09dab6c commit fbecd73

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/xfs/xfs_zone_gc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,8 @@ xfs_zone_gc_write_chunk(
807807
{
808808
struct xfs_zone_gc_data *data = chunk->data;
809809
struct xfs_mount *mp = chunk->ip->i_mount;
810-
unsigned int folio_offset = chunk->bio.bi_io_vec->bv_offset;
810+
phys_addr_t bvec_paddr =
811+
bvec_phys(bio_first_bvec_all(&chunk->bio));
811812
struct xfs_gc_bio *split_chunk;
812813

813814
if (chunk->bio.bi_status)
@@ -822,7 +823,7 @@ xfs_zone_gc_write_chunk(
822823

823824
bio_reset(&chunk->bio, mp->m_rtdev_targp->bt_bdev, REQ_OP_WRITE);
824825
bio_add_folio_nofail(&chunk->bio, chunk->scratch->folio, chunk->len,
825-
folio_offset);
826+
offset_in_folio(chunk->scratch->folio, bvec_paddr));
826827

827828
while ((split_chunk = xfs_zone_gc_split_write(data, chunk)))
828829
xfs_zone_gc_submit_write(data, split_chunk);

0 commit comments

Comments
 (0)