All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Christoph Hellwig <hch@infradead.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/4] repair: don't double check dir2 sf parent in phase 4
Date: Thu, 16 Jul 2020 06:39:40 -0400	[thread overview]
Message-ID: <20200716103940.GA26218@bfoster> (raw)
In-Reply-To: <20200715235414.GF3151642@magnolia>

On Wed, Jul 15, 2020 at 04:54:14PM -0700, Darrick J. Wong wrote:
> On Wed, Jul 15, 2020 at 07:43:50PM +0100, Christoph Hellwig wrote:
> > On Wed, Jul 15, 2020 at 10:08:34AM -0400, Brian Foster wrote:
> > > The shortform parent ino verification code runs once in phase 3
> > > (ino_discovery == true) and once in phase 4 (ino_discovery ==
> > > false). This is unnecessary and leads to duplicate error messages if
> > > repair replaces an invalid parent value with zero because zero is
> > > still an invalid value. Skip the check in phase 4.
> > 
> > This looks good,
> > 
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > 
> > As far as the existing code is concerned:  Does anyone else find the
> > ino_discovery booleand passed as int as annoying as I do?  An
> > "enum repair_phase phase" would be much more descriptive in my opinion.
> 
> I can never remember what "ino_discovery" actually means.  true means
> phase2 (looking at inodes for the first time) and false means phase4
> (looking for crosslinked data and whatnot)?
> 

Same.. I agree with Christoph on not just ino_discovery, but the various
boolean parameters to some of the common scanning functions that are
reused across multiple phases. It's confusing to track when reading the
code as well as to identify intent and whether certain hunks of
idempotent code are running multiple times, etc.

That said, I'm not necessarily convinced that replacing the booleans
with a phase enum is a huge benefit. That just changes the interface so
it's easier to determine what phase we're in vs. why certain bits of
logic are executed. I.e., 'if (ino_discovery) { do_discovery_stuff(); }'
confuses what phase we're in when reading the lower level code, but 'if
(phase == PHASE_3) { do_discovery_stuff() }' doesn't really clarify how
do_discovery_stuff() might interact with other behaviors that are part
of the same phase.

I'm not sure what the right answer is but if we're going to look at
refactoring things, I'd rather see us start with considering something
more fundamental. For example, could we perhaps factor out the the phase
specific functionality into phase specific functions via an approach
like Darrick's recent log recovery rework?  That way it might be easier
to read through each phase and understand the core repair logic vs.
having to troll through scanning infrastructure multiple times trying to
keep track of where you are in the grand scheme of things. Of course if
that is too much of a mess then perhaps the phase enum thing makes more
sense..

Brian

> --D
> 


  reply	other threads:[~2020-07-16 10:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15 14:08 [PATCH 0/4] xfsprogs: remove custom dir2 sf fork verifier from repair Brian Foster
2020-07-15 14:08 ` [PATCH 1/4] repair: set the in-core inode parent in phase 3 Brian Foster
2020-07-15 18:42   ` Christoph Hellwig
2020-07-21  0:57   ` Darrick J. Wong
2020-07-15 14:08 ` [PATCH 2/4] repair: don't double check dir2 sf parent in phase 4 Brian Foster
2020-07-15 18:43   ` Christoph Hellwig
2020-07-15 23:54     ` Darrick J. Wong
2020-07-16 10:39       ` Brian Foster [this message]
2020-07-21  0:55   ` Darrick J. Wong
2020-07-15 14:08 ` [PATCH 3/4] repair: use fs root ino for dummy parent value instead of zero Brian Foster
2020-07-15 18:44   ` Christoph Hellwig
2020-07-15 22:22   ` Dave Chinner
2020-07-16 10:41     ` Brian Foster
2020-07-16 22:06       ` Dave Chinner
2020-07-17 11:57         ` Brian Foster
2020-07-17 11:59   ` [PATCH v2] repair: use fs rootino " Brian Foster
2020-07-20  3:21     ` Dave Chinner
2020-07-21  0:47     ` Darrick J. Wong
2020-07-15 14:08 ` [PATCH 4/4] repair: remove custom dir2 sf fork verifier from phase6 Brian Foster
2020-07-15 18:44   ` Christoph Hellwig
2020-07-21  0:47   ` Darrick J. Wong

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=20200716103940.GA26218@bfoster \
    --to=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --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.