From: "Darrick J. Wong" <djwong@kernel.org>
To: Carlos Maiolino <cem@kernel.org>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [RFC PATCH 1/3] xfs: add xfs_error_report the ability to display an error code
Date: Tue, 8 Sep 2026 07:54:28 -0700 [thread overview]
Message-ID: <20260908145428.GD2619314@frogsfrogsfrogs> (raw)
In-Reply-To: <ap-ecIJjpOrN5jsZ@andromeda.toxiclabs.cc>
On Tue, Sep 08, 2026 at 07:36:34AM +0200, Carlos Maiolino wrote:
> On Fri, Sep 04, 2026 at 06:08:51PM -0700, Darrick J. Wong wrote:
> > On Fri, Sep 04, 2026 at 01:32:21PM +0200, cem@kernel.org wrote:
> > > From: Carlos Maiolino <cem@kernel.org>
> > >
> > > Users could opt to request an error code to be printed
> > >
> > > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> > > Signed-off-by: Carlos Maiolino <cem@kernel.org>
> > > ---
> > > fs/xfs/xfs_error.c | 7 ++++++-
> > > fs/xfs/xfs_error.h | 10 +++++-----
> > > fs/xfs/xfs_exchmaps_item.c | 6 +++---
> > > fs/xfs/xfs_inode_item.c | 2 +-
> > > fs/xfs/xfs_log_recover.c | 2 +-
> > > 5 files changed, 16 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> > > index dbd87e137694..1c882b910ffd 100644
> > > --- a/fs/xfs/xfs_error.c
> > > +++ b/fs/xfs/xfs_error.c
> > > @@ -377,6 +377,7 @@ void
> > > xfs_error_report(
> > > const char *tag,
> > > int level,
> > > + int error,
> > > struct xfs_mount *mp,
> > > const char *filename,
> > > int linenum,
> > > @@ -387,6 +388,10 @@ xfs_error_report(
> > > "Internal error %s at line %d of file %s. Caller %pS",
> > > tag, linenum, filename, failaddr);
> > >
> > > + if (error)
> > > + xfs_alert_tag(mp, XFS_PTAG_ERROR_REPORT,
> > > + "Error Code: %d", error);
> >
> > /me wonders, should the error erport just go in the "Internal error..."
> > message above?
> >
> > "Internal error $tag ($error) at line..."
>
> Sure, I initially didn't want a longer line, but I'd rather have a
> single line here too.
>
> >
> > > +
> > > xfs_stack_trace();
> > > }
> > > }
> > > @@ -404,7 +409,7 @@ xfs_corruption_error(
> > > {
> > > if (buf && level <= xfs_error_level)
> > > xfs_hex_dump(buf, bufsize);
> > > - xfs_error_report(tag, level, mp, filename, linenum, failaddr);
> > > + xfs_error_report(tag, level, 0, mp, filename, linenum, failaddr);
> > > xfs_alert(mp, "Corruption detected. Unmount and run xfs_repair");
> > > }
> > >
> > > diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
> > > index 0b9c5ba8a598..1a1aa60e92f2 100644
> > > --- a/fs/xfs/xfs_error.h
> > > +++ b/fs/xfs/xfs_error.h
> > > @@ -8,9 +8,9 @@
> > >
> > > struct xfs_mount;
> > >
> > > -extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
> > > - const char *filename, int linenum,
> > > - xfs_failaddr_t failaddr);
> > > +extern void xfs_error_report(const char *tag, int level, int error,
> > > + struct xfs_mount *mp, const char *filename,
> > > + int linenum, xfs_failaddr_t failaddr);
> > > extern void xfs_corruption_error(const char *tag, int level,
> > > struct xfs_mount *mp, const void *buf, size_t bufsize,
> > > const char *filename, int linenum,
> > > @@ -25,8 +25,8 @@ extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
> > > const char *name, const void *buf, size_t bufsz,
> > > xfs_failaddr_t failaddr);
> > >
> > > -#define XFS_ERROR_REPORT(e, lvl, mp) \
> > > - xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
> > > +#define XFS_ERROR_REPORT(e, lvl, error, mp) \
> > > + xfs_error_report(e, lvl, error, mp, __FILE__, __LINE__, __return_address)
> > > #define XFS_CORRUPTION_ERROR(e, lvl, mp, buf, bufsize) \
> > > xfs_corruption_error(e, lvl, mp, buf, bufsize, \
> > > __FILE__, __LINE__, __return_address)
> > > diff --git a/fs/xfs/xfs_exchmaps_item.c b/fs/xfs/xfs_exchmaps_item.c
> > > index 264a121c5e16..b94c5e5e6549 100644
> > > --- a/fs/xfs/xfs_exchmaps_item.c
> > > +++ b/fs/xfs/xfs_exchmaps_item.c
> > > @@ -559,13 +559,13 @@ xlog_recover_xmi_commit_pass2(
> > >
> > > len = sizeof(struct xfs_xmi_log_format);
> > > if (item->ri_buf[0].i_len != len) {
> > > - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
> > > + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, 0, log->l_mp);
> >
> > These should be -EFSCORRUPTED, not 0, right?
>
> This was a RFC and my goal here was just leave the messages unchanged by
> now, I'll change it for a formal patch.
Oh, ok. On some level it would be fun to wrap all that crap in a macro
so that all -EFSCORRUPTED returns could be a logging site:
#define XFS_EFSCORRUPTED(mp) \
(XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, -EFSCORRUPTED, (mp)),
-EFSCORRUPTED)
return XFS_EFSCORRUPTED(mp);
Eh. I hate preprocessor macros. I'll just call the above a bad idea
and press <Send>.
--D
>
> >
> > --D
> >
> > > return -EFSCORRUPTED;
> > > }
> > >
> > > xmi_formatp = item->ri_buf[0].i_addr;
> > > if (xmi_formatp->__pad != 0) {
> > > - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
> > > + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, 0, log->l_mp);
> > > return -EFSCORRUPTED;
> > > }
> > >
> > > @@ -600,7 +600,7 @@ xlog_recover_xmd_commit_pass2(
> > >
> > > xmd_formatp = item->ri_buf[0].i_addr;
> > > if (item->ri_buf[0].i_len != sizeof(struct xfs_xmd_log_format)) {
> > > - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
> > > + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, 0, log->l_mp);
> > > return -EFSCORRUPTED;
> > > }
> > >
> > > diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> > > index c6cb0b6b9e46..862b7d7d3ce4 100644
> > > --- a/fs/xfs/xfs_inode_item.c
> > > +++ b/fs/xfs/xfs_inode_item.c
> > > @@ -1185,7 +1185,7 @@ xfs_inode_item_format_convert(
> > > struct xfs_inode_log_format_32 *in_f32 = buf->i_addr;
> > >
> > > if (buf->i_len != sizeof(*in_f32)) {
> > > - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL);
> > > + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, 0, NULL);
> > > return -EFSCORRUPTED;
> > > }
> > >
> > > diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> > > index 2f76531842f8..083e4bf61e2b 100644
> > > --- a/fs/xfs/xfs_log_recover.c
> > > +++ b/fs/xfs/xfs_log_recover.c
> > > @@ -2932,7 +2932,7 @@ xlog_recover_process(
> > > * fatal log corruption failure.
> > > */
> > > if (xfs_has_crc(log->l_mp)) {
> > > - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
> > > + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, 0, log->l_mp);
> > > return -EFSCORRUPTED;
> > > }
> > > }
> > > --
> > > 2.55.0
> > >
> > >
> >
>
next prev parent reply other threads:[~2026-09-08 14:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 11:32 [RFC PATCH 0/3] Log transaction cancel error codes in the kernel log buffer cem
2026-09-04 11:32 ` [RFC PATCH 1/3] xfs: add xfs_error_report the ability to display an error code cem
2026-09-05 1:08 ` Darrick J. Wong
2026-09-07 6:04 ` Christoph Hellwig
2026-09-07 6:39 ` Carlos Maiolino
2026-09-08 5:36 ` Carlos Maiolino
2026-09-08 14:54 ` Darrick J. Wong [this message]
2026-09-04 11:32 ` [RFC PATCH 2/3] xfs: enable xfs_trans_cancel() to report and " cem
2026-09-05 1:10 ` Darrick J. Wong
2026-09-07 6:05 ` Christoph Hellwig
2026-09-08 6:36 ` Carlos Maiolino
2026-09-04 11:32 ` [RFC PATCH 3/3] xfs: make xfs_iomap_write_direct() report an error to xfs_trans_cancel cem
2026-09-05 1:11 ` 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=20260908145428.GD2619314@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.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.