xfs
[Top] [All Lists]

[PATCH 2/4] libxfs: buffers aren't stale once written

To: xfs@xxxxxxxxxxx
Subject: [PATCH 2/4] libxfs: buffers aren't stale once written
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Tue, 1 Jul 2014 22:54:54 +1000
Cc: arekm@xxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1404219296-29302-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1404219296-29302-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

When rebuilding a bad directory, repair first truncates away all the
blocks in the directory. This removes blocks from the bmap btree,
and when those blocks are freed the bmap btree code invalidates
them. This marks the buffers LIBXFS_B_STALE so that we don't try to
write stale data from that buffer at a later time.

However, when rebuilding the directory, the block gets reallocated
and new metadata gets written into it. however, it is still marked
stale and hence the new, corrected metadata is never written. Hence
if we write new metadata to a stale buffer, we have to clear the
LIBXFS_B_STALE flag to ensure that the new data gets written.

Note that this can affect more than just bmap btree buffers - there
are several different places in the libxfs code that mark buffers
stale via xfs_trans_binval() during repair operations.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 libxfs/rdwr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 981f2ba..28f8f36 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -928,6 +928,7 @@ libxfs_writebuf_int(xfs_buf_t *bp, int flags)
         * subsequent reads after this write from seeing stale errors.
         */
        bp->b_error = 0;
+       bp->b_flags &= ~LIBXFS_B_STALE;
        bp->b_flags |= (LIBXFS_B_DIRTY | flags);
        return 0;
 }
@@ -946,6 +947,7 @@ libxfs_writebuf(xfs_buf_t *bp, int flags)
         * subsequent reads after this write from seeing stale errors.
         */
        bp->b_error = 0;
+       bp->b_flags &= ~LIBXFS_B_STALE;
        bp->b_flags |= (LIBXFS_B_DIRTY | flags);
        libxfs_putbuf(bp);
        return 0;
-- 
2.0.0

<Prev in Thread] Current Thread [Next in Thread>