public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/3] xfs: mark dir corrupt when lookup-by-hash fails
Date: Tue, 3 Mar 2020 14:57:12 -0800	[thread overview]
Message-ID: <20200303225712.GG8045@magnolia> (raw)
In-Reply-To: <20200303222610.GV10776@dread.disaster.area>

On Wed, Mar 04, 2020 at 09:26:10AM +1100, Dave Chinner wrote:
> On Fri, Feb 28, 2020 at 05:49:09PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > In xchk_dir_actor, we attempt to validate the directory hash structures
> > by performing a directory entry lookup by (hashed) name.  If the lookup
> > returns ENOENT, that means that the hash information is corrupt.  The
> > _process_error functions don't catch this, so we have to add that
> > explicitly.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  fs/xfs/scrub/dir.c |    5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > 
> > diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
> > index 266da4e4bde6..54afa75c95d1 100644
> > --- a/fs/xfs/scrub/dir.c
> > +++ b/fs/xfs/scrub/dir.c
> > @@ -155,6 +155,11 @@ xchk_dir_actor(
> >  	xname.type = XFS_DIR3_FT_UNKNOWN;
> >  
> >  	error = xfs_dir_lookup(sdc->sc->tp, ip, &xname, &lookup_ino, NULL);
> > +	if (error == -ENOENT) {
> > +		/* ENOENT means the hash lookup failed and the dir is corrupt */
> > +		xchk_fblock_set_corrupt(sdc->sc, XFS_DATA_FORK, offset);
> > +		return -EFSCORRUPTED;
> > +	}
> >  	if (!xchk_fblock_process_error(sdc->sc, XFS_DATA_FORK, offset,
> >  			&error))
> >  		goto out;
> 
> So why is this error handling open coded rather than doing something
> like this to use the generic, pre-existing corruption handling:
> 
> 	if (error == -ENOENT) {
> 		/* ENOENT means the hash lookup failed and the dir is corrupt */
> 		error = -EFSCORRUPTED;
> 	}
> 	if (!xchk_fblock_process_error(sdc->sc, XFS_DATA_FORK, offset,
> 			&error))
> 		goto out;

No particular reason, I just figured that I might as well cut to setting
OFLAG_CORRUPT and bailing out.  I'll change it.

--D

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.co

  reply	other threads:[~2020-03-03 22:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-29  1:49 [PATCH 0/3] xfs: fix errors in attr/directory scrubbers Darrick J. Wong
2020-02-29  1:49 ` [PATCH 1/3] xfs: mark dir corrupt when lookup-by-hash fails Darrick J. Wong
2020-03-02 17:43   ` Allison Collins
2020-03-03 22:26   ` Dave Chinner
2020-03-03 22:57     ` Darrick J. Wong [this message]
2020-02-29  1:49 ` [PATCH 2/3] xfs: mark extended attr " Darrick J. Wong
2020-03-02 17:44   ` Allison Collins
2020-03-03 22:26   ` Dave Chinner
2020-03-03 22:58     ` Darrick J. Wong
2020-02-29  1:49 ` [PATCH 3/3] xfs: scrub should mark dir corrupt if entry points to unallocated inode Darrick J. Wong
2020-03-02 17:44   ` Allison Collins
2020-03-03 22:39   ` Dave Chinner
2020-03-03 23:06     ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2020-03-11  0:48 [PATCH v2 0/3] xfs: fix errors in attr/directory scrubbers Darrick J. Wong
2020-03-11  0:48 ` [PATCH 1/3] xfs: mark dir corrupt when lookup-by-hash fails Darrick J. Wong
2020-03-11  5:52   ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200303225712.GG8045@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox