]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: btree block LSN escaping to disk uninitialised
authorDave Chinner <dchinner@redhat.com>
Wed, 4 Sep 2013 22:05:56 +0000 (22:05 +0000)
committerRich Johnston <rjohnston@sgi.com>
Mon, 16 Sep 2013 20:16:51 +0000 (15:16 -0500)
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 <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
libxfs/xfs_btree.c

index 3ac333074f2b8f302992b2a92e9af7aec8f872e8..009992650300e5653b27101aefae631ffb4fc594 100644 (file)
@@ -921,6 +921,7 @@ xfs_btree_init_block_int(
                        buf->bb_u.l.bb_owner = cpu_to_be64(owner);
                        uuid_copy(&buf->bb_u.l.bb_uuid, &mp->m_sb.sb_uuid);
                        buf->bb_u.l.bb_pad = 0;
+                       buf->bb_u.l.bb_lsn = 0;
                }
        } else {
                /* owner is a 32 bit value on short blocks */
@@ -932,6 +933,7 @@ xfs_btree_init_block_int(
                        buf->bb_u.s.bb_blkno = cpu_to_be64(blkno);
                        buf->bb_u.s.bb_owner = cpu_to_be32(__owner);
                        uuid_copy(&buf->bb_u.s.bb_uuid, &mp->m_sb.sb_uuid);
+                       buf->bb_u.s.bb_lsn = 0;
                }
        }
 }