Skip to content

Commit 30f8ee5

Browse files
author
Darrick J. Wong
committed
xfs: ensure that single-owner file blocks are not owned by others
For any file fork mapping that can only have a single owner, make sure that there are no other rmap owners for that mapping. This patch requires the more detailed checking provided by xfs_rmap_count_owners so that we can know how many rmap records for a given range of space had a matching owner, how many had a non-matching owner, and how many conflicted with the records that have a matching owner. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 69115f7 commit 30f8ee5

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

fs/xfs/scrub/bmap.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ xchk_bmap_iextent_xref(
308308
struct xchk_bmap_info *info,
309309
struct xfs_bmbt_irec *irec)
310310
{
311+
struct xfs_owner_info oinfo;
311312
struct xfs_mount *mp = info->sc->mp;
312313
xfs_agnumber_t agno;
313314
xfs_agblock_t agbno;
@@ -328,19 +329,30 @@ xchk_bmap_iextent_xref(
328329
xchk_bmap_xref_rmap(info, irec, agbno);
329330
switch (info->whichfork) {
330331
case XFS_DATA_FORK:
331-
if (!xfs_is_reflink_inode(info->sc->ip))
332+
if (!xfs_is_reflink_inode(info->sc->ip)) {
333+
xfs_rmap_ino_owner(&oinfo, info->sc->ip->i_ino,
334+
info->whichfork, irec->br_startoff);
335+
xchk_xref_is_only_owned_by(info->sc, agbno,
336+
irec->br_blockcount, &oinfo);
332337
xchk_xref_is_not_shared(info->sc, agbno,
333338
irec->br_blockcount);
339+
}
334340
xchk_xref_is_not_cow_staging(info->sc, agbno,
335341
irec->br_blockcount);
336342
break;
337343
case XFS_ATTR_FORK:
344+
xfs_rmap_ino_owner(&oinfo, info->sc->ip->i_ino,
345+
info->whichfork, irec->br_startoff);
346+
xchk_xref_is_only_owned_by(info->sc, agbno, irec->br_blockcount,
347+
&oinfo);
338348
xchk_xref_is_not_shared(info->sc, agbno,
339349
irec->br_blockcount);
340350
xchk_xref_is_not_cow_staging(info->sc, agbno,
341351
irec->br_blockcount);
342352
break;
343353
case XFS_COW_FORK:
354+
xchk_xref_is_only_owned_by(info->sc, agbno, irec->br_blockcount,
355+
&XFS_RMAP_OINFO_COW);
344356
xchk_xref_is_cow_staging(info->sc, agbno,
345357
irec->br_blockcount);
346358
xchk_xref_is_not_shared(info->sc, agbno,

0 commit comments

Comments
 (0)