]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
xfs: fix imprecise logic in xchk_btree_check_block_owner
authorDarrick J. Wong <djwong@kernel.org>
Mon, 17 Jun 2024 23:03:48 +0000 (16:03 -0700)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Fri, 2 Aug 2024 14:27:02 +0000 (16:27 +0200)
commit33a5d93ca7fce6663240beb7b52257ca9c4228e3
tree83ef7d38bc9b620c5106407a5797e49ec9db68f7
parentd8a3a0944c69940319c87e152e4eaa91d436985d
xfs: fix imprecise logic in xchk_btree_check_block_owner

BugLink: https://bugs.launchpad.net/bugs/2074091
commit c0afba9a8363f17d4efed22a8764df33389aebe8 upstream.

A reviewer was confused by the init_sa logic in this function.  Upon
checking the logic, I discovered that the code is imprecise.  What we
want to do here is check that there is an ownership record in the rmap
btree for the AG that contains a btree block.

For an inode-rooted btree (e.g. the bmbt) the per-AG btree cursors have
not been initialized because inode btrees can span multiple AGs.
Therefore, we must initialize the per-AG btree cursors in sc->sa before
proceeding.  That is what init_sa controls, and hence the logic should
be gated on XFS_BTREE_ROOT_IN_INODE, not XFS_BTREE_LONG_PTRS.

In practice, ROOT_IN_INODE and LONG_PTRS are coincident so this hasn't
mattered.  However, we're about to refactor both of those flags into
separate btree_ops fields so we want this the logic to make sense
afterwards.

Fixes: 858333dcf021a ("xfs: check btree block ownership with bnobt/rmapbt when scrubbing btree")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Portia Stephens <portia.stephens@canonical.com>
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
fs/xfs/scrub/btree.c