public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Brian Foster <bfoster@redhat.com>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>,
	xfs <linux-xfs@vger.kernel.org>
Subject: Re: [RFC PATCH] xfs: consolidate local format inode fork verifiers
Date: Mon, 24 Jul 2017 15:26:38 +1000	[thread overview]
Message-ID: <20170724052638.GD17762@dastard> (raw)
In-Reply-To: <20170722122944.GA4783@bfoster.bfoster>

On Sat, Jul 22, 2017 at 08:29:44AM -0400, Brian Foster wrote:
> On Sat, Jul 22, 2017 at 09:00:58AM +1000, Dave Chinner wrote:
> > On Fri, Jul 21, 2017 at 09:54:05AM -0400, Brian Foster wrote:
> > > On Fri, Jul 21, 2017 at 08:49:34AM +1000, Dave Chinner wrote:
> > > but I'm also not against crafting a new, verifier
> > > specific one to accomplish that. Technically, it doesn't have to be
> > > shouty :), but IMO, the diagnostic/usability benefit outweighs the
> > > aesthetic cost.
> > 
> > I disagree - there are so many verifier checks (and we only grow
> > more as time goes on) so whatever we do needs them to be
> > easily maintainable and not compromise the readabilty of the verifer
> > code.
> > 
> 
> I agree. ;) But I disagree that using a macro somehow automatically
> negatively affects the readability of verifers. Anybody who can make
> sense of this:
> 
>         if (!xfs_sb_version_hascrc(&mp->m_sb))
>                 return __line__;
>         if (dsl->sl_magic != cpu_to_be32(XFS_SYMLINK_MAGIC))
>                 return __line__;
>         if (!uuid_equal(&dsl->sl_uuid, &mp->m_sb.sb_meta_uuid))
>                 return __line__;
> 
> ... could just as easily make sense of something like this:
> 
> 	xfs_verify_assert(xfs_sb_version_hascrc(&mp->m_sb));
> 	xfs_verify_assert(dsl->sl_magic == cpu_to_be32(XFS_SYMLINK_MAGIC));
> 	xfs_verify_assert(uuid_equal(&dsl->sl_uuid, &mp->m_sb.sb_meta_uuid));

Still needs branches to return on error so the verifier code
functions correctly. So it simply isn't as clean as your example
suggests. And, no hiding goto/return/errno variables inside a macro
is not an option - that makes for horrible code and we should not
repeat those past mistakes we inherited from the old Irix
codebase.

And we need to be really careful here - making the code more complex
for pretty errors blows out the size of the code. That means it runs
slower, even though we never execute most of the pretty error print
stuff.  This is an important consideration as verifiers are a
performance critical fast path, both in the kernel and in userspace.

> There is a simple solution to this problem: just include all of the
> readily accessible state information in the error report. If the
> messages above looked something like the following:
> 
>   XFS (...): Metadata corruption detected at xfs_symlink_read_verify [xfs], xfs_symlink block 0x58
>   XFS (...): Read verifier failed: xfs_log_check_lsn(mp, be64_to_cpu(dsl->sl_lsn)), xfs_symlink_remote.c:114
>
> ... we wouldn't have to decode what the error means for every possible
> kernel. The error report is self contained like most of the other
> errors/assert reports in XFS and throughout the kernel.

Just like an assert/warning, we've still got to go match it to the
exact kernel source tree to determine the context in which the
message was emitted and what it actually means.  Making it pretty
doesn't change the amount of work a developer needs to do to
classify or analyse errors in log files, all it does is change the
amount of overhead needed to generate the error message,

Really, verifiers are performance critical fast paths, so the code
that runs inside them needs to be implemented with this in mind. I'm
not against making messages pretty, but let's not do it based on the
on the premise that pretty error messages are more important than
runtime performance when there are no errors...

Cheers,

Dave.

-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2017-07-24  5:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 16:03 [RFC PATCH] xfs: consolidate local format inode fork verifiers Darrick J. Wong
2017-07-20  2:26 ` Dave Chinner
2017-07-20  5:50   ` Darrick J. Wong
2017-07-20 22:49     ` Dave Chinner
2017-07-21 13:54       ` Brian Foster
2017-07-21 23:00         ` Dave Chinner
2017-07-22 12:29           ` Brian Foster
2017-07-24  5:26             ` Dave Chinner [this message]
2017-07-24 13:07               ` Brian Foster
2017-07-24 18:36                 ` Brian Foster
2017-07-24 18:44                 ` Darrick J. Wong
2017-07-24 19:34                   ` Brian Foster
2017-07-24 17:15       ` Darrick J. Wong
2017-07-20 11:51 ` Brian Foster
2017-07-20 20:20   ` Darrick J. Wong
2017-07-21 12:58     ` Brian Foster

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=20170724052638.GD17762@dastard \
    --to=david@fromorbit.com \
    --cc=bfoster@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox