All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bill O'Donnell <billodo@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: xchk_xattr_listent() fix context->seen_enough to -ECANCELED
Date: Thu, 6 Feb 2020 17:51:25 -0600	[thread overview]
Message-ID: <20200206235125.GA3570914@redhat.com> (raw)
In-Reply-To: <20200206230731.GH6870@magnolia>

On Thu, Feb 06, 2020 at 03:07:31PM -0800, Darrick J. Wong wrote:
> On Wed, Feb 05, 2020 at 01:04:55PM -0600, Bill O'Donnell wrote:
> > Commit e7ee96dfb8c (xfs: remove all *_ITER_ABORT values)
> > replaced *_ITER_ABORT values with -ECANCELED. The replacement
> > in the case of scrub/attr.c xchk_xattr_listent() is in
> > error (context->seen_enough = 1;). Instead of '1', use
> > the intended -ECANCELED.
> > 
> > Fixes: e7ee96dfb8c (xfs: remove all *_ITER_ABORT values)
> > Signed-off-by: Bill O'Donnell <billodo@redhat.com>
> > ---
> >  fs/xfs/scrub/attr.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
> > index d9f0dd444b80..5d0590f78973 100644
> > --- a/fs/xfs/scrub/attr.c
> > +++ b/fs/xfs/scrub/attr.c
> > @@ -171,7 +171,7 @@ xchk_xattr_listent(
> >  					     args.blkno);
> >  fail_xref:
> >  	if (sx->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
> > -		context->seen_enough = 1;
> 
> Hmm.  The attr list functions do:
> 
> 	if (context->seen_enough)
> 		break;
> 
> to stop iteration of the attributes.  Any nonzero value will work,
> positive or negative.  Further down in the scrub/attr.c, xchk_xattr
> does:
> 
> 	/* Did our listent function try to return any errors? */
> 	if (sx.context.seen_enough < 0)
> 		error = sx.context.seen_enough;
> 
> Which means that if seen_enough is set to a negative value, we'll return
> that negative value all the way back to userspace, which means that the
> userspace buffer is not updated and xfs_scrub will think there was a
> runtime error.
> 
> > +		context->seen_enough = -ECANCELED;
> 
> So this will cause xfs_scrub to abort with "Operation Canceled" if it
> found a corruption error.  The patch I sent to the list had -ECANCELED,
> but then I noticed the scrub breakage and changed it to 1 before
> committing.  Other parts of the attr code use 1 to stop an attr walk
> without returning errors to userspace.

That is what had me confused. 

> 
> Perhaps it's time to replace that novel use of "1" (and audit all the
> branching and whatnot) with -ECANCELED so that we can go on cargoculting
> negative int errors in peace.
> 
> (*UGH* I remembered that I was the one who applied negative int error
> semantics to seen_enough in the first place; before that, its meaning
> was purely boolean.  It's still screaming for a cleanup though...)

Agreed.
Thanks-
Bill

> --D
> 
> >  	return;
> >  }
> >  
> > -- 
> > 2.24.1
> > 
> 


      reply	other threads:[~2020-02-06 23:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 19:04 [PATCH] xfs: xchk_xattr_listent() fix context->seen_enough to -ECANCELED Bill O'Donnell
2020-02-06 23:07 ` Darrick J. Wong
2020-02-06 23:51   ` Bill O'Donnell [this message]

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=20200206235125.GA3570914@redhat.com \
    --to=billodo@redhat.com \
    --cc=darrick.wong@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.