Skip to content

Commit b58fa55

Browse files
Dave ChinnerBen Myers
authored andcommitted
xfs: btree block LSN escaping to disk uninitialised
When testing LSN ordering code for v5 superblocks, it was discovered that the the LSN embedded in the generic btree blocks was occasionally uninitialised. These values didn't get written to disk by metadata writeback - they got written by previous transactions in log recovery. The issue is here that the when the block is first allocated and initialised, the LSN field was not initialised - it gets overwritten before IO is issued on the buffer - but the value that is logged by transactions that modify the header before it is written to disk (and initialised) contain garbage. Hence the first recovery of the buffer will stamp garbage into the LSN field, and that can cause subsequent transactions to not replay correctly. The fix is simply to initialise the bb_lsn field to zero when we initialise the block for the first time. Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Mark Tinguely <[email protected]> Signed-off-by: Ben Myers <[email protected]>
1 parent 3780437 commit b58fa55

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/xfs/xfs_btree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ xfs_btree_init_block_int(
978978
buf->bb_u.l.bb_owner = cpu_to_be64(owner);
979979
uuid_copy(&buf->bb_u.l.bb_uuid, &mp->m_sb.sb_uuid);
980980
buf->bb_u.l.bb_pad = 0;
981+
buf->bb_u.l.bb_lsn = 0;
981982
}
982983
} else {
983984
/* owner is a 32 bit value on short blocks */
@@ -989,6 +990,7 @@ xfs_btree_init_block_int(
989990
buf->bb_u.s.bb_blkno = cpu_to_be64(blkno);
990991
buf->bb_u.s.bb_owner = cpu_to_be32(__owner);
991992
uuid_copy(&buf->bb_u.s.bb_uuid, &mp->m_sb.sb_uuid);
993+
buf->bb_u.s.bb_lsn = 0;
992994
}
993995
}
994996
}

0 commit comments

Comments
 (0)