From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 5/9] xfs: make forced shutdown processing atomic
Date: Tue, 13 Jul 2021 22:02:46 -0700 [thread overview]
Message-ID: <20210714050246.GG22402@magnolia> (raw)
In-Reply-To: <20210714031524.GV664593@dread.disaster.area>
On Wed, Jul 14, 2021 at 01:15:24PM +1000, Dave Chinner wrote:
> On Thu, Jul 08, 2021 at 09:40:20PM -0700, Darrick J. Wong wrote:
> > On Wed, Jun 30, 2021 at 04:38:09PM +1000, Dave Chinner wrote:
> > > From: Dave Chinner <dchinner@redhat.com>
> > >
> > > The running of a forced shutdown is a bit of a mess. It does racy
> > > checks for XFS_MOUNT_SHUTDOWN in xfs_do_force_shutdown(), then
> > > does more racy checks in xfs_log_force_unmount() before finally
> > > setting XFS_MOUNT_SHUTDOWN and XLOG_IO_ERROR under the
> > > log->icloglock.
> > >
> > > Move the checking and setting of XFS_MOUNT_SHUTDOWN into
> > > xfs_do_force_shutdown() so we only process a shutdown once and once
> > > only. Serialise this with the mp->m_sb_lock spinlock so that the
> > > state change is atomic and won't race. Move all the mount specific
> >
> > Assuming you're working on cleaning /that/ up too, I'll let that go...
>
> Yes, a forward ported patch set that does this will be posted soon.
Ok.
> > > + xfs_alert_tag(mp, tag,
> > > +"%s (0x%x) detected at %pS (%s:%d). Shutting down filesystem.",
> > > + why, flags, __return_address, fname, lnnum);
> > > xfs_alert(mp,
> > > "Please unmount the filesystem and rectify the problem(s)");
> > > + if (xfs_error_level >= XFS_ERRLEVEL_HIGH)
> > > + xfs_stack_trace();
> >
> > Doesn't xfs_alert already drop a stack trace for xfs_error_level >=
> > XFS_ERRLEVEL_HIGH ?
>
> It does? I've never seen it do that, and the existing code implies
> it doesn't do this, either, and that's the logic was looking at
> here:
>
> if (flags & SHUTDOWN_CORRUPT_INCORE) {
> xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_CORRUPT,
> "Corruption of in-memory data (0x%x) detected at %pS (%s:%d). Shutting down filesystem",
> flags, __return_address, fname, lnnum);
> if (XFS_ERRLEVEL_HIGH <= xfs_error_level)
> xfs_stack_trace();
> } else if (....)
>
> Yes, xfs_alert_tag() does not trigger a stack trace at all, but
> there's an unconditional xfs_alert() call after this so if that
> issues stack traces then we'd get a double stack trace on all
> SHUTDOWN_CORRUPT_INCORE incidents. AFAICT, that doesn't actually
> happen....
>
> This pattern is repeated in several places - look at
> xfs_inode_verifier_error(), xfs_buf_verifier_error(), and
> xfs_buf_corruption_error(). They all have xfs_alert() calls, then
> follow it up with a specific error level check for a stack dump.
>
> Hmmm, it looks like xfs_alert() was intended to dump stacks, but I
> don't think it works:
>
> if (!kstrtoint(kern_level, 0, &level) && \
> level <= LOGLEVEL_ERR && \
> xfs_error_level >= XFS_ERRLEVEL_HIGH) \
> xfs_stack_trace(); \
>
> And kern_level is KERN_ALERT, which is:
>
> #define KERN_SOH "\001"
> ....
> #define KERN_ALERT KERN_SOH "1"
>
> And:
>
> #define LOGLEVEL_ERR 3 /* error conditions */
>
> So what does kstrtoint() return when passed the string "\0011"? It's
> not actually an integer string...
>
> Hmmm, I think it returns -EINVAL, which means it then uses level
> uninitialised, and the result is .... unpredictable it is likely
> no stack trace is emitted....
>
> Fixing this mess is out of scope for this patchset. The changes in
> this patchset don't change the existing pattern of the function of
> unconditionally calling xfs_alert() and conditionally and explicitly
> dumping stack traces manually. I'll add it to my ever growing list
> of cleanups that need to be done...
AHA! That's why that's never seemed to work right for me.
Well, at least the good news is that we each have enough outstanding
patchsets to keep the other busy reviewing until 2028 or so. ;)
--D
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com
next prev parent reply other threads:[~2021-07-14 5:02 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-30 6:38 [PATCH 0/9] xfs: shutdown is a racy mess Dave Chinner
2021-06-30 6:38 ` [PATCH 1/9] xfs: convert XLOG_FORCED_SHUTDOWN() to xlog_is_shutdown() Dave Chinner
2021-06-30 16:10 ` Darrick J. Wong
2021-07-02 7:48 ` Christoph Hellwig
2021-07-02 8:45 ` Dave Chinner
2021-07-02 9:27 ` Christoph Hellwig
2021-06-30 6:38 ` [PATCH 2/9] xfs: XLOG_STATE_IOERROR must die Dave Chinner
2021-06-30 15:22 ` kernel test robot
2021-06-30 15:22 ` [PATCH] xfs: fix semicolon.cocci warnings kernel test robot
2021-07-02 8:00 ` [PATCH 2/9] xfs: XLOG_STATE_IOERROR must die Christoph Hellwig
2021-07-02 8:55 ` Dave Chinner
2021-06-30 6:38 ` [PATCH 3/9] xfs: move recovery needed state updates to xfs_log_mount_finish Dave Chinner
2021-07-02 8:10 ` Christoph Hellwig
2021-06-30 6:38 ` [PATCH 4/9] xfs: convert log flags to an operational state field Dave Chinner
2021-07-02 8:15 ` Christoph Hellwig
2021-07-09 4:33 ` Darrick J. Wong
2021-06-30 6:38 ` [PATCH 5/9] xfs: make forced shutdown processing atomic Dave Chinner
2021-07-02 8:24 ` Christoph Hellwig
2021-07-05 1:28 ` Dave Chinner
2021-07-09 4:40 ` Darrick J. Wong
2021-07-14 3:15 ` Dave Chinner
2021-07-14 5:02 ` Darrick J. Wong [this message]
2021-06-30 6:38 ` [PATCH 6/9] xfs: reowrk up xlog_state_do_callback Dave Chinner
2021-07-02 8:28 ` Christoph Hellwig
2021-07-09 4:42 ` Darrick J. Wong
2021-06-30 6:38 ` [PATCH 7/9] xfs: separate out log shutdown callback processing Dave Chinner
2021-07-02 8:36 ` Christoph Hellwig
2021-07-05 1:46 ` Dave Chinner
2021-06-30 6:38 ` [PATCH 8/9] xfs: don't run shutdown callbacks on active iclogs Dave Chinner
2021-07-02 8:48 ` Christoph Hellwig
2021-07-05 2:04 ` Dave Chinner
2021-06-30 6:38 ` [PATCH 9/9] xfs: log head and tail aren't reliable during shutdown Dave Chinner
2021-07-02 8:53 ` Christoph Hellwig
2021-07-05 2:22 ` Dave Chinner
-- strict thread matches above, loose matches on Subject: below --
2021-07-14 3:19 [PATCH 0/9 v2] xfs: shutdown is a racy mess Dave Chinner
2021-07-14 3:19 ` [PATCH 5/9] xfs: make forced shutdown processing atomic Dave Chinner
2021-07-14 6:15 ` Christoph Hellwig
2021-07-14 21:57 ` Darrick J. Wong
2021-08-10 5:18 [PATCH 0/9 v3] xfs: shutdown is a racy mess Dave Chinner
2021-08-10 5:18 ` [PATCH 5/9] xfs: make forced shutdown processing atomic 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=20210714050246.GG22402@magnolia \
--to=djwong@kernel.org \
--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