diff mbox series

[1/8] xfs: never try to scrub more than 64 inodes per inobt record

Message ID 154630851366.14372.14057534574140159776.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfs: inode scrubber fixes | expand

Commit Message

Darrick J. Wong Jan. 1, 2019, 2:08 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Make sure we never check more than XFS_INODES_PER_CHUNK inodes for any
given inobt record since there can be more than one inobt record mapped
to an inode cluster.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/scrub/ialloc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Carlos Maiolino Jan. 2, 2019, 12:39 p.m. UTC | #1
On Mon, Dec 31, 2018 at 06:08:33PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Make sure we never check more than XFS_INODES_PER_CHUNK inodes for any
> given inobt record since there can be more than one inobt record mapped
> to an inode cluster.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/scrub/ialloc.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c
> index 882dc56c5c21..fd431682db0b 100644
> --- a/fs/xfs/scrub/ialloc.c
> +++ b/fs/xfs/scrub/ialloc.c
> @@ -203,7 +203,8 @@ xchk_iallocbt_check_freemask(
>  	int				error = 0;
>  
>  	/* Make sure the freemask matches the inode records. */
> -	nr_inodes = mp->m_inodes_per_cluster;
> +	nr_inodes = min_t(unsigned int, XFS_INODES_PER_CHUNK,
> +			mp->m_inodes_per_cluster);

Pardon me if this doesn't make sense, but, this looks like a good time to catch
a possible corruption?! If mp->m_inodes_per_cluster is > XFS_INODES_PER_CHUNK
something is terribly wrong and we could report it here instead of max it out to
XFS_INODES_PER_CHUNK, but I haven't studied the scrub code that deep yet to see
if my suggestion makes sense or not :)


>  
>  	for (agino = irec->ir_startino;
>  	     agino < irec->ir_startino + XFS_INODES_PER_CHUNK;
>
Chandan Rajendra Jan. 2, 2019, 1:30 p.m. UTC | #2
On Wednesday, January 2, 2019 6:09:29 PM IST Carlos Maiolino wrote:
> On Mon, Dec 31, 2018 at 06:08:33PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Make sure we never check more than XFS_INODES_PER_CHUNK inodes for any
> > given inobt record since there can be more than one inobt record mapped
> > to an inode cluster.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  fs/xfs/scrub/ialloc.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > 
> > diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c
> > index 882dc56c5c21..fd431682db0b 100644
> > --- a/fs/xfs/scrub/ialloc.c
> > +++ b/fs/xfs/scrub/ialloc.c
> > @@ -203,7 +203,8 @@ xchk_iallocbt_check_freemask(
> >  	int				error = 0;
> >  
> >  	/* Make sure the freemask matches the inode records. */
> > -	nr_inodes = mp->m_inodes_per_cluster;
> > +	nr_inodes = min_t(unsigned int, XFS_INODES_PER_CHUNK,
> > +			mp->m_inodes_per_cluster);
> 
> Pardon me if this doesn't make sense, but, this looks like a good time to catch
> a possible corruption?! If mp->m_inodes_per_cluster is > XFS_INODES_PER_CHUNK
> something is terribly wrong and we could report it here instead of max it out to
> XFS_INODES_PER_CHUNK, but I haven't studied the scrub code that deep yet to see
> if my suggestion makes sense or not :)

With 64k block size, we would have 128 inodes per cluster i.e. more than one
chunk can be accommodated within a cluster.
Brian Foster Jan. 4, 2019, 6:30 p.m. UTC | #3
On Mon, Dec 31, 2018 at 06:08:33PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Make sure we never check more than XFS_INODES_PER_CHUNK inodes for any
> given inobt record since there can be more than one inobt record mapped
> to an inode cluster.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/scrub/ialloc.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c
> index 882dc56c5c21..fd431682db0b 100644
> --- a/fs/xfs/scrub/ialloc.c
> +++ b/fs/xfs/scrub/ialloc.c
> @@ -203,7 +203,8 @@ xchk_iallocbt_check_freemask(
>  	int				error = 0;
>  
>  	/* Make sure the freemask matches the inode records. */
> -	nr_inodes = mp->m_inodes_per_cluster;
> +	nr_inodes = min_t(unsigned int, XFS_INODES_PER_CHUNK,
> +			mp->m_inodes_per_cluster);
>  

I'm wondering why we wouldn't also use nr_inodes in the loop immediately
below instead of ->m_inodes_per_cluster, but it looks like this all
changes in the following patches.

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  	for (agino = irec->ir_startino;
>  	     agino < irec->ir_startino + XFS_INODES_PER_CHUNK;
>
diff mbox series

Patch

diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c
index 882dc56c5c21..fd431682db0b 100644
--- a/fs/xfs/scrub/ialloc.c
+++ b/fs/xfs/scrub/ialloc.c
@@ -203,7 +203,8 @@  xchk_iallocbt_check_freemask(
 	int				error = 0;
 
 	/* Make sure the freemask matches the inode records. */
-	nr_inodes = mp->m_inodes_per_cluster;
+	nr_inodes = min_t(unsigned int, XFS_INODES_PER_CHUNK,
+			mp->m_inodes_per_cluster);
 
 	for (agino = irec->ir_startino;
 	     agino < irec->ir_startino + XFS_INODES_PER_CHUNK;