[Top] [All Lists]

[PATCH 1/3] xfs: ensure buffer types are set correctly

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/3] xfs: ensure buffer types are set correctly
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Wed, 21 Jan 2015 11:39:38 +1100
Cc: jack@xxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1421800780-26008-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1421800780-26008-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

Jan Kara reported that log recovery was finding buffers with invalid
types in them. This should not happen, and indicates a bug in the
logging of buffers. To catch this, add asserts to the buffer
formatting code to ensure that the buffer type is in range when the
transaction is committed.

We don't set a type on buffers being marked stale - they are not
going to get replayed, the format item exists only for recovery to
be able to prevent replay of the buffer, so the type does not
matter. Hence that needs special casing here.

Reported-by: Jan Kara <jack@xxxxxxx>
Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
 fs/xfs/xfs_buf_item.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 925ead2..507d96a 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -319,6 +319,10 @@ xfs_buf_item_format(
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
        ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
               (bip->bli_flags & XFS_BLI_STALE));
+       ASSERT((bip->bli_flags & XFS_BLI_STALE) ||
+              (xfs_blft_from_flags(&bip->__bli_format) > XFS_BLFT_UNKNOWN_BUF
+               && xfs_blft_from_flags(&bip->__bli_format) < XFS_BLFT_MAX_BUF));
         * If it is an inode buffer, transfer the in-memory state to the

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