mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 22:52:19 +02:00
xfs: scrub inode core when checking metadata files
Running the online fsck QA fuzz tests, I noticed that we were consistently missing fuzzed records in the inode cores of the realtime freespace files and the quota files. This patch adds the ability to check inode cores in xchk_metadata_inode_forks. Signed-off-by: Darrick J. Wong <djwong@kernel.org> -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEUzaAxoMeQq6m2jMV+H93GTRKtOsFAmN1fwwACgkQ+H93GTRK tOuqAw/+JLnoGvDkkWfLHqFqroINQp29ZEuk2Zgcn9E1Lk+7xfZimqRNdlJI47J3 Dz9ob5gO/GZfZoPtfmxQegJggaHnjRb1LLQGphb5EDhB7ezo23JQt8lM7A4iPVx9 KHhb/+7IIJLNt07p2RpyTxPjdmxk1s0vYpnjchnSrxUR1Lqzq5LU1CLVEbwfHyRI PJX3OCG57fbk5jOFo/KgkKXP/cf6//PP/pGT56ytzveBMZt77D3dWtRSEiQGlUc2 QFlR77CR4KuLhkRjr69B1X2RVEopj4/sRItSMpFB/EoPpfDsYrGw27Pm8fgdVyTo VLUzCS8NlhkVikoEO8EBawLidRT1QlgluqNVUUKx/+NSA5DsroymkEj8+BzL7mJO vsHEGZw/IeTn9ATqapQtjHc6ZnbZFHCaf0b+eaJhuoMjyOI+guleYjIHQcaLTK73 pivmCoj6VE6V1IZNZAnFEAohNPCxpfzu85Sg7mVUcrL24QReOIuy21m207Tj3q94 6ytXENkOdJJ3ZJq1MoIIhAvOJPmzJvGEEpv+auSdu+OfeYK/kXbtcCPFIwtcI0p5 1fnKKq/y9mZyr+37Ifx74DBAiCeO+GHikkYOIP70Lkw0YQ3AVnU7PQBy1xmJCzYG AlAebztXXED+uJbhvNICOrxuSXzVynKpN6Br3VYT7qfgCGjS8L8= =mvcx -----END PGP SIGNATURE----- Merge tag 'scrub-check-metadata-inode-records-6.2_2022-11-16' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.2-mergeA xfs: scrub inode core when checking metadata files Running the online fsck QA fuzz tests, I noticed that we were consistently missing fuzzed records in the inode cores of the realtime freespace files and the quota files. This patch adds the ability to check inode cores in xchk_metadata_inode_forks. Signed-off-by: Darrick J. Wong <djwong@kernel.org> * tag 'scrub-check-metadata-inode-records-6.2_2022-11-16' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux: xfs: check inode core when scrubbing metadata files xfs: don't warn about files that are exactly s_maxbytes long
This commit is contained in:
commit
7b082b5e8a
|
|
@ -781,6 +781,33 @@ xchk_buffer_recheck(
|
|||
trace_xchk_block_error(sc, xfs_buf_daddr(bp), fa);
|
||||
}
|
||||
|
||||
static inline int
|
||||
xchk_metadata_inode_subtype(
|
||||
struct xfs_scrub *sc,
|
||||
unsigned int scrub_type)
|
||||
{
|
||||
__u32 smtype = sc->sm->sm_type;
|
||||
int error;
|
||||
|
||||
sc->sm->sm_type = scrub_type;
|
||||
|
||||
switch (scrub_type) {
|
||||
case XFS_SCRUB_TYPE_INODE:
|
||||
error = xchk_inode(sc);
|
||||
break;
|
||||
case XFS_SCRUB_TYPE_BMBTD:
|
||||
error = xchk_bmap_data(sc);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
error = -EFSCORRUPTED;
|
||||
break;
|
||||
}
|
||||
|
||||
sc->sm->sm_type = smtype;
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Scrub the attr/data forks of a metadata inode. The metadata inode must be
|
||||
* pointed to by sc->ip and the ILOCK must be held.
|
||||
|
|
@ -789,13 +816,17 @@ int
|
|||
xchk_metadata_inode_forks(
|
||||
struct xfs_scrub *sc)
|
||||
{
|
||||
__u32 smtype;
|
||||
bool shared;
|
||||
int error;
|
||||
|
||||
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
|
||||
return 0;
|
||||
|
||||
/* Check the inode record. */
|
||||
error = xchk_metadata_inode_subtype(sc, XFS_SCRUB_TYPE_INODE);
|
||||
if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
|
||||
return error;
|
||||
|
||||
/* Metadata inodes don't live on the rt device. */
|
||||
if (sc->ip->i_diflags & XFS_DIFLAG_REALTIME) {
|
||||
xchk_ino_set_corrupt(sc, sc->ip->i_ino);
|
||||
|
|
@ -815,10 +846,7 @@ xchk_metadata_inode_forks(
|
|||
}
|
||||
|
||||
/* Invoke the data fork scrubber. */
|
||||
smtype = sc->sm->sm_type;
|
||||
sc->sm->sm_type = XFS_SCRUB_TYPE_BMBTD;
|
||||
error = xchk_bmap_data(sc);
|
||||
sc->sm->sm_type = smtype;
|
||||
error = xchk_metadata_inode_subtype(sc, XFS_SCRUB_TYPE_BMBTD);
|
||||
if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
|
||||
return error;
|
||||
|
||||
|
|
@ -833,7 +861,7 @@ xchk_metadata_inode_forks(
|
|||
xchk_ino_set_corrupt(sc, sc->ip->i_ino);
|
||||
}
|
||||
|
||||
return error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ xchk_dinode(
|
|||
* pagecache can't cache all the blocks in this file due to
|
||||
* overly large offsets, flag the inode for admin review.
|
||||
*/
|
||||
if (isize >= mp->m_super->s_maxbytes)
|
||||
if (isize > mp->m_super->s_maxbytes)
|
||||
xchk_ino_set_warning(sc, ino);
|
||||
|
||||
/* di_nblocks */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user