summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub/bmap.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-04-12 05:00:25 +0300
committerDarrick J. Wong <djwong@kernel.org>2023-04-12 05:00:25 +0300
commit336642f79283715e4535bfaa05f5593dd91da6e8 (patch)
tree46d9157cbce314dcc2d8fabf8273a80ba7248d9d /fs/xfs/scrub/bmap.c
parentc0d5a92f7aaf41b1ab70869358d534757b569a1f (diff)
downloadlinux-336642f79283715e4535bfaa05f5593dd91da6e8.tar.xz
xfs: alert the user about data/attr fork mappings that could be merged
If the data or attr forks have mappings that could be merged, let the user know that the structure could be optimized. This isn't a filesystem corruption since the regular filesystem does not try to be smart about merging bmbt records. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/scrub/bmap.c')
-rw-r--r--fs/xfs/scrub/bmap.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
index 912b67d2321b..a2edcf8cc779 100644
--- a/fs/xfs/scrub/bmap.c
+++ b/fs/xfs/scrub/bmap.c
@@ -764,6 +764,7 @@ xchk_bmap_iext_iter(
{
struct xfs_bmbt_irec got;
struct xfs_ifork *ifp;
+ xfs_filblks_t prev_len;
ifp = xfs_ifork_ptr(info->sc->ip, info->whichfork);
@@ -782,6 +783,7 @@ xchk_bmap_iext_iter(
* Iterate subsequent iextent records and merge them with the one
* that we just read, if possible.
*/
+ prev_len = irec->br_blockcount;
while (xfs_iext_peek_next_extent(ifp, &info->icur, &got)) {
if (!xchk_are_bmaps_contiguous(irec, &got))
break;
@@ -792,7 +794,16 @@ xchk_bmap_iext_iter(
return false;
}
+ /*
+ * Notify the user of mergeable records in the data or attr
+ * forks. CoW forks only exist in memory so we ignore them.
+ */
+ if (info->whichfork != XFS_COW_FORK &&
+ prev_len + got.br_blockcount > BMBT_BLOCKCOUNT_MASK)
+ xchk_ino_set_preen(info->sc, info->sc->ip->i_ino);
+
irec->br_blockcount += got.br_blockcount;
+ prev_len = got.br_blockcount;
xfs_iext_next(ifp, &info->icur);
}