Skip to content

Commit 7d7d6d2

Browse files
author
Darrick J. Wong
committed
xfs: hoist rmap record flag checks from scrub
Move the rmap record flag checks from xchk_rmapbt_rec into xfs_rmap_check_irec so that they are applied everywhere. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 6a3bd8f commit 7d7d6d2

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

fs/xfs/libxfs/xfs_rmap.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ xfs_rmap_check_irec(
212212
const struct xfs_rmap_irec *irec)
213213
{
214214
struct xfs_mount *mp = cur->bc_mp;
215+
bool is_inode;
216+
bool is_unwritten;
217+
bool is_bmbt;
218+
bool is_attr;
215219

216220
if (irec->rm_blockcount == 0)
217221
return __this_address;
@@ -232,6 +236,24 @@ xfs_rmap_check_irec(
232236
irec->rm_owner >= XFS_RMAP_OWN_MIN)))
233237
return __this_address;
234238

239+
/* Check flags. */
240+
is_inode = !XFS_RMAP_NON_INODE_OWNER(irec->rm_owner);
241+
is_bmbt = irec->rm_flags & XFS_RMAP_BMBT_BLOCK;
242+
is_attr = irec->rm_flags & XFS_RMAP_ATTR_FORK;
243+
is_unwritten = irec->rm_flags & XFS_RMAP_UNWRITTEN;
244+
245+
if (is_bmbt && irec->rm_offset != 0)
246+
return __this_address;
247+
248+
if (!is_inode && irec->rm_offset != 0)
249+
return __this_address;
250+
251+
if (is_unwritten && (is_bmbt || !is_inode || is_attr))
252+
return __this_address;
253+
254+
if (!is_inode && (is_bmbt || is_unwritten || is_attr))
255+
return __this_address;
256+
235257
return NULL;
236258
}
237259

fs/xfs/scrub/rmap.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,35 +94,13 @@ xchk_rmapbt_rec(
9494
const union xfs_btree_rec *rec)
9595
{
9696
struct xfs_rmap_irec irec;
97-
bool non_inode;
98-
bool is_unwritten;
99-
bool is_bmbt;
100-
bool is_attr;
10197

10298
if (xfs_rmap_btrec_to_irec(rec, &irec) != NULL ||
10399
xfs_rmap_check_irec(bs->cur, &irec) != NULL) {
104100
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
105101
return 0;
106102
}
107103

108-
/* Check flags. */
109-
non_inode = XFS_RMAP_NON_INODE_OWNER(irec.rm_owner);
110-
is_bmbt = irec.rm_flags & XFS_RMAP_BMBT_BLOCK;
111-
is_attr = irec.rm_flags & XFS_RMAP_ATTR_FORK;
112-
is_unwritten = irec.rm_flags & XFS_RMAP_UNWRITTEN;
113-
114-
if (is_bmbt && irec.rm_offset != 0)
115-
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
116-
117-
if (non_inode && irec.rm_offset != 0)
118-
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
119-
120-
if (is_unwritten && (is_bmbt || non_inode || is_attr))
121-
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
122-
123-
if (non_inode && (is_bmbt || is_unwritten || is_attr))
124-
xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
125-
126104
xchk_rmapbt_xref(bs->sc, &irec);
127105
return 0;
128106
}

0 commit comments

Comments
 (0)