diff mbox series

[2/2] xfs: fix finobt btree block recovery ordering

Message ID 20200930063532.142256-3-david@fromorbit.com (mailing list archive)
State Superseded, archived
Headers show
Series xfs: a couple of small fixes | expand

Commit Message

Dave Chinner Sept. 30, 2020, 6:35 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

Nathan popped up on #xfs and pointed out that we fail to handle
finobt btree blocks in xlog_recover_get_buf_lsn(). This means they
always fall through the entire magic number matching code to "recover
immediately". Whilst most of the time this is the correct behaviour,
occasionally it will be incorrect and could potentially overwrite
more recent metadata because we don't check the LSN in the on disk
metadata at all.

This bug has been present since the finobt was first introduced, and
is a potential cause of the occasional xfs_iget_check_free_state()
failures we see that indicate that the inode btree state does not
match the on disk inode state.

Fixes: aafc3c246529 ("xfs: support the XFS_BTNUM_FINOBT free inode btree type")
Reported-by: Nathan Scott <nathans@redhat.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_buf_item_recover.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Darrick J. Wong Sept. 30, 2020, 2:28 p.m. UTC | #1
On Wed, Sep 30, 2020 at 04:35:32PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Nathan popped up on #xfs and pointed out that we fail to handle
> finobt btree blocks in xlog_recover_get_buf_lsn(). This means they
> always fall through the entire magic number matching code to "recover
> immediately". Whilst most of the time this is the correct behaviour,
> occasionally it will be incorrect and could potentially overwrite
> more recent metadata because we don't check the LSN in the on disk
> metadata at all.
> 
> This bug has been present since the finobt was first introduced, and
> is a potential cause of the occasional xfs_iget_check_free_state()
> failures we see that indicate that the inode btree state does not
> match the on disk inode state.
> 
> Fixes: aafc3c246529 ("xfs: support the XFS_BTNUM_FINOBT free inode btree type")
> Reported-by: Nathan Scott <nathans@redhat.com>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Aha, I saw that once...
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

Hmmm, zooming out a bit, what kinds of buffers get logged that don't
have magics?  Realtime bitmap and summary?  Can anyone else think of
something? ;)

--D

> ---
>  fs/xfs/xfs_buf_item_recover.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c
> index 24c7a8d11e1a..d44e8b4a3391 100644
> --- a/fs/xfs/xfs_buf_item_recover.c
> +++ b/fs/xfs/xfs_buf_item_recover.c
> @@ -719,6 +719,8 @@ xlog_recover_get_buf_lsn(
>  	case XFS_ABTC_MAGIC:
>  	case XFS_RMAP_CRC_MAGIC:
>  	case XFS_REFC_CRC_MAGIC:
> +	case XFS_FIBT_CRC_MAGIC:
> +	case XFS_FIBT_MAGIC:
>  	case XFS_IBT_CRC_MAGIC:
>  	case XFS_IBT_MAGIC: {
>  		struct xfs_btree_block *btb = blk;
> -- 
> 2.28.0
>
Brian Foster Sept. 30, 2020, 2:51 p.m. UTC | #2
On Wed, Sep 30, 2020 at 04:35:32PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Nathan popped up on #xfs and pointed out that we fail to handle
> finobt btree blocks in xlog_recover_get_buf_lsn(). This means they
> always fall through the entire magic number matching code to "recover
> immediately". Whilst most of the time this is the correct behaviour,
> occasionally it will be incorrect and could potentially overwrite
> more recent metadata because we don't check the LSN in the on disk
> metadata at all.
> 
> This bug has been present since the finobt was first introduced, and
> is a potential cause of the occasional xfs_iget_check_free_state()
> failures we see that indicate that the inode btree state does not
> match the on disk inode state.
> 
> Fixes: aafc3c246529 ("xfs: support the XFS_BTNUM_FINOBT free inode btree type")
> Reported-by: Nathan Scott <nathans@redhat.com>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_buf_item_recover.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c
> index 24c7a8d11e1a..d44e8b4a3391 100644
> --- a/fs/xfs/xfs_buf_item_recover.c
> +++ b/fs/xfs/xfs_buf_item_recover.c
> @@ -719,6 +719,8 @@ xlog_recover_get_buf_lsn(
>  	case XFS_ABTC_MAGIC:
>  	case XFS_RMAP_CRC_MAGIC:
>  	case XFS_REFC_CRC_MAGIC:
> +	case XFS_FIBT_CRC_MAGIC:
> +	case XFS_FIBT_MAGIC:
>  	case XFS_IBT_CRC_MAGIC:
>  	case XFS_IBT_MAGIC: {
>  		struct xfs_btree_block *btb = blk;
> -- 
> 2.28.0
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c
index 24c7a8d11e1a..d44e8b4a3391 100644
--- a/fs/xfs/xfs_buf_item_recover.c
+++ b/fs/xfs/xfs_buf_item_recover.c
@@ -719,6 +719,8 @@  xlog_recover_get_buf_lsn(
 	case XFS_ABTC_MAGIC:
 	case XFS_RMAP_CRC_MAGIC:
 	case XFS_REFC_CRC_MAGIC:
+	case XFS_FIBT_CRC_MAGIC:
+	case XFS_FIBT_MAGIC:
 	case XFS_IBT_CRC_MAGIC:
 	case XFS_IBT_MAGIC: {
 		struct xfs_btree_block *btb = blk;