* [PATCH v4 0/3] Enable xfs error reporting to print out error codes
@ 2026-09-24 15:16 cem
2026-09-24 15:16 ` [PATCH v4 1/3] xfs: add xfs_error_report the ability to display an error code cem
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: cem @ 2026-09-24 15:16 UTC (permalink / raw)
To: cem; +Cc: linux-xfs, hch, djwong, sandeen
From: Carlos Maiolino <cem@kernel.org>
This is the new version of the error code printing series.
The only modification here is on patch 2 which replaces the macros by
an inline function suggested by hch.
Darrick, I removed your RwB from patch 2 giving the way it implements
things now are considerable different
Carlos Maiolino (3):
xfs: add xfs_error_report the ability to display an error code
xfs: introduce xfs_trans_cancel_error()
xfs: make xfs_iomap_write_direct() report an error to xfs_trans_cancel
fs/xfs/xfs_error.c | 16 +++++++++++-----
fs/xfs/xfs_error.h | 9 +++++----
fs/xfs/xfs_exchmaps_item.c | 9 ++++++---
fs/xfs/xfs_inode_item.c | 3 ++-
fs/xfs/xfs_iomap.c | 2 +-
fs/xfs/xfs_log_recover.c | 3 ++-
fs/xfs/xfs_trans.c | 8 +++++---
fs/xfs/xfs_trans.h | 9 ++++++++-
8 files changed, 40 insertions(+), 19 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v4 1/3] xfs: add xfs_error_report the ability to display an error code 2026-09-24 15:16 [PATCH v4 0/3] Enable xfs error reporting to print out error codes cem @ 2026-09-24 15:16 ` cem 2026-09-24 15:16 ` [PATCH v4 2/3] xfs: introduce xfs_trans_cancel_error() cem ` (3 subsequent siblings) 4 siblings, 0 replies; 8+ messages in thread From: cem @ 2026-09-24 15:16 UTC (permalink / raw) To: cem; +Cc: linux-xfs, hch, djwong, sandeen From: Carlos Maiolino <cem@kernel.org> Users could opt to request an error code to be printed now. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> --- V3: - Remove stale description aboutt ERRNAME fs/xfs/xfs_error.c | 16 +++++++++++----- fs/xfs/xfs_error.h | 9 +++++---- fs/xfs/xfs_exchmaps_item.c | 9 ++++++--- fs/xfs/xfs_inode_item.c | 3 ++- fs/xfs/xfs_log_recover.c | 3 ++- fs/xfs/xfs_trans.c | 2 +- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 9ece70fd94ca..c943717f1dd7 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -241,16 +241,21 @@ void xfs_error_report( const char *tag, int level, + int error, struct xfs_mount *mp, const char *filename, int linenum, xfs_failaddr_t failaddr) { if (level <= xfs_error_level) { - xfs_alert_tag(mp, XFS_PTAG_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, +"Internal error %s (%d) at line %d of file %s. Caller %pS", + tag, error, linenum, filename, failaddr); + else + xfs_alert_tag(mp, XFS_PTAG_ERROR_REPORT, +"Internal error %s at line %d of file %s. Caller %pS", + tag, linenum, filename, failaddr); xfs_stack_trace(); } } @@ -268,7 +273,8 @@ 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, -EFSCORRUPTED, 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 05fc1d1cf521..3c76d0dad51c 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h @@ -8,8 +8,9 @@ struct xfs_mount; -void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, - const char *filename, int linenum, xfs_failaddr_t failaddr); +void xfs_error_report(const char *tag, int level, int error, + struct xfs_mount *mp, const char *filename, + int linenum, xfs_failaddr_t failaddr); void xfs_corruption_error(const char *tag, int level, struct xfs_mount *mp, const void *buf, size_t bufsize, const char *filename, int linenum, xfs_failaddr_t failaddr); @@ -20,8 +21,8 @@ void xfs_verifier_error(struct xfs_buf *bp, int error, xfs_failaddr_t failaddr); 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 dd5d92ca1010..9f499a80038c 100644 --- a/fs/xfs/xfs_exchmaps_item.c +++ b/fs/xfs/xfs_exchmaps_item.c @@ -573,13 +573,15 @@ xlog_recover_xmi_commit_pass2( len = sizeof(struct xfs_xmi_log_format); if (item->ri_buf[0].iov_len != len) { - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp); + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, + -EFSCORRUPTED, log->l_mp); return -EFSCORRUPTED; } xmi_formatp = item->ri_buf[0].iov_base; if (xmi_formatp->__pad != 0) { - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp); + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, + -EFSCORRUPTED, log->l_mp); return -EFSCORRUPTED; } @@ -614,7 +616,8 @@ xlog_recover_xmd_commit_pass2( xmd_formatp = item->ri_buf[0].iov_base; if (item->ri_buf[0].iov_len != sizeof(struct xfs_xmd_log_format)) { - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp); + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, + -EFSCORRUPTED, log->l_mp); return -EFSCORRUPTED; } diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 99d6ecccdaa7..a29c90f0650f 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -1229,7 +1229,8 @@ xfs_inode_item_format_convert( struct xfs_inode_log_format_32 *in_f32 = buf->iov_base; if (buf->iov_len != sizeof(*in_f32)) { - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL); + XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, + -EFSCORRUPTED, NULL); return -EFSCORRUPTED; } diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index cf0d610265fe..457617979668 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -2948,7 +2948,8 @@ 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, + -EFSCORRUPTED, log->l_mp); return -EFSCORRUPTED; } } diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 1b36cf12d4e3..5c522790e5be 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -971,7 +971,7 @@ xfs_trans_cancel( * here. */ if (dirty && !xfs_is_shutdown(mp)) { - XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, mp); + XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, 0, mp); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); } #ifdef DEBUG -- 2.55.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 2/3] xfs: introduce xfs_trans_cancel_error() 2026-09-24 15:16 [PATCH v4 0/3] Enable xfs error reporting to print out error codes cem 2026-09-24 15:16 ` [PATCH v4 1/3] xfs: add xfs_error_report the ability to display an error code cem @ 2026-09-24 15:16 ` cem 2026-09-24 18:57 ` Darrick J. Wong 2026-09-25 4:46 ` Christoph Hellwig 2026-09-24 15:16 ` [PATCH v4 3/3] xfs: make xfs_iomap_write_direct() report an error to xfs_trans_cancel cem ` (2 subsequent siblings) 4 siblings, 2 replies; 8+ messages in thread From: cem @ 2026-09-24 15:16 UTC (permalink / raw) To: cem; +Cc: linux-xfs, hch, djwong, sandeen From: Carlos Maiolino <cem@kernel.org> Once in a while it's useful to know exactly what kind of error caused a transaction to be cancelled. Currently xfs_trans_cancel() is unable to print out this information. So rename old xfs_trans_cancel to xfs_trans_cancel_error() which will accept an error code to be printed and add a new inline xfs_trans_cancel() to be used on places where an error number report is not explicitly needed (and also avoid dozens of file modifications to the new API). Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> --- V4: - Remove macros in lieu of an inline function - Rename patch to a better description V3: - Kill typedef from __xfs_trans_cancel - Remove uneeded wrap of parameter 0 fs/xfs/xfs_trans.c | 8 +++++--- fs/xfs/xfs_trans.h | 9 ++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 5c522790e5be..8f0c308f312f 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -943,8 +943,9 @@ xfs_trans_commit( * xfs_trans_commit(). */ void -xfs_trans_cancel( - struct xfs_trans *tp) +xfs_trans_cancel_error( + struct xfs_trans *tp, + int error) { struct xfs_mount *mp = tp->t_mountp; struct xlog *log = mp->m_log; @@ -971,7 +972,8 @@ xfs_trans_cancel( * here. */ if (dirty && !xfs_is_shutdown(mp)) { - XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, 0, mp); + XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, + error, mp); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); } #ifdef DEBUG diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index eb83c5dac032..edb0cfff4d3c 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -237,7 +237,7 @@ void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint); int xfs_trans_commit(struct xfs_trans *); int xfs_trans_roll(struct xfs_trans **); int xfs_trans_roll_inode(struct xfs_trans **, struct xfs_inode *); -void xfs_trans_cancel(xfs_trans_t *); +void xfs_trans_cancel_error(struct xfs_trans *, int); int xfs_trans_ail_init(struct xfs_mount *); void xfs_trans_ail_destroy(struct xfs_mount *); @@ -280,4 +280,11 @@ xfs_trans_clear_context( memalloc_nofs_restore(tp->t_pflags); } +static inline void +xfs_trans_cancel( + struct xfs_trans *tp) +{ + return xfs_trans_cancel_error(tp, 0); +} + #endif /* __XFS_TRANS_H__ */ -- 2.55.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/3] xfs: introduce xfs_trans_cancel_error() 2026-09-24 15:16 ` [PATCH v4 2/3] xfs: introduce xfs_trans_cancel_error() cem @ 2026-09-24 18:57 ` Darrick J. Wong 2026-09-25 4:46 ` Christoph Hellwig 1 sibling, 0 replies; 8+ messages in thread From: Darrick J. Wong @ 2026-09-24 18:57 UTC (permalink / raw) To: cem; +Cc: linux-xfs, hch, sandeen On Thu, Sep 24, 2026 at 05:16:29PM +0200, cem@kernel.org wrote: > From: Carlos Maiolino <cem@kernel.org> > > Once in a while it's useful to know exactly what kind of error caused a > transaction to be cancelled. Currently xfs_trans_cancel() is unable to > print out this information. So rename old xfs_trans_cancel to > xfs_trans_cancel_error() which will accept an error code to be printed > and add a new inline xfs_trans_cancel() to be used on places where an > error number report is not explicitly needed (and also avoid dozens of > file modifications to the new API). > > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> > --- > V4: > - Remove macros in lieu of an inline function > - Rename patch to a better description Looks good still; thanks to hch for pointing out a more sensible way to do the cancel function. Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > V3: > - Kill typedef from __xfs_trans_cancel > - Remove uneeded wrap of parameter 0 > > fs/xfs/xfs_trans.c | 8 +++++--- > fs/xfs/xfs_trans.h | 9 ++++++++- > 2 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c > index 5c522790e5be..8f0c308f312f 100644 > --- a/fs/xfs/xfs_trans.c > +++ b/fs/xfs/xfs_trans.c > @@ -943,8 +943,9 @@ xfs_trans_commit( > * xfs_trans_commit(). > */ > void > -xfs_trans_cancel( > - struct xfs_trans *tp) > +xfs_trans_cancel_error( > + struct xfs_trans *tp, > + int error) > { > struct xfs_mount *mp = tp->t_mountp; > struct xlog *log = mp->m_log; > @@ -971,7 +972,8 @@ xfs_trans_cancel( > * here. > */ > if (dirty && !xfs_is_shutdown(mp)) { > - XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, 0, mp); > + XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, > + error, mp); > xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); > } > #ifdef DEBUG > diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h > index eb83c5dac032..edb0cfff4d3c 100644 > --- a/fs/xfs/xfs_trans.h > +++ b/fs/xfs/xfs_trans.h > @@ -237,7 +237,7 @@ void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint); > int xfs_trans_commit(struct xfs_trans *); > int xfs_trans_roll(struct xfs_trans **); > int xfs_trans_roll_inode(struct xfs_trans **, struct xfs_inode *); > -void xfs_trans_cancel(xfs_trans_t *); > +void xfs_trans_cancel_error(struct xfs_trans *, int); > int xfs_trans_ail_init(struct xfs_mount *); > void xfs_trans_ail_destroy(struct xfs_mount *); > > @@ -280,4 +280,11 @@ xfs_trans_clear_context( > memalloc_nofs_restore(tp->t_pflags); > } > > +static inline void > +xfs_trans_cancel( > + struct xfs_trans *tp) > +{ > + return xfs_trans_cancel_error(tp, 0); > +} > + > #endif /* __XFS_TRANS_H__ */ > -- > 2.55.0 > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/3] xfs: introduce xfs_trans_cancel_error() 2026-09-24 15:16 ` [PATCH v4 2/3] xfs: introduce xfs_trans_cancel_error() cem 2026-09-24 18:57 ` Darrick J. Wong @ 2026-09-25 4:46 ` Christoph Hellwig 1 sibling, 0 replies; 8+ messages in thread From: Christoph Hellwig @ 2026-09-25 4:46 UTC (permalink / raw) To: cem; +Cc: linux-xfs, hch, djwong, sandeen Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 3/3] xfs: make xfs_iomap_write_direct() report an error to xfs_trans_cancel 2026-09-24 15:16 [PATCH v4 0/3] Enable xfs error reporting to print out error codes cem 2026-09-24 15:16 ` [PATCH v4 1/3] xfs: add xfs_error_report the ability to display an error code cem 2026-09-24 15:16 ` [PATCH v4 2/3] xfs: introduce xfs_trans_cancel_error() cem @ 2026-09-24 15:16 ` cem 2026-10-05 18:06 ` [PATCH v4 0/3] Enable xfs error reporting to print out error codes Carlos Maiolino 2026-10-08 13:32 ` Carlos Maiolino 4 siblings, 0 replies; 8+ messages in thread From: cem @ 2026-09-24 15:16 UTC (permalink / raw) To: cem; +Cc: linux-xfs, hch, djwong, sandeen From: Carlos Maiolino <cem@kernel.org> I've been in the situation a few times where the transaction got cancelled by some reason. Most of time because bmapi_write failed and I start a guessing game trying to understand why. So if xfs_iomap_write_direct fails and it causes the transaction to be cancelled, send the error to xfs_trans_cancel so the error gets logged into the kernel log buffer. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> --- fs/xfs/xfs_iomap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 7c6238fed61e..4906a4828d11 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -358,7 +358,7 @@ xfs_iomap_write_direct( return error; out_trans_cancel: - xfs_trans_cancel(tp); + xfs_trans_cancel_error(tp, error); goto out_unlock; } -- 2.55.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4 0/3] Enable xfs error reporting to print out error codes 2026-09-24 15:16 [PATCH v4 0/3] Enable xfs error reporting to print out error codes cem ` (2 preceding siblings ...) 2026-09-24 15:16 ` [PATCH v4 3/3] xfs: make xfs_iomap_write_direct() report an error to xfs_trans_cancel cem @ 2026-10-05 18:06 ` Carlos Maiolino 2026-10-08 13:32 ` Carlos Maiolino 4 siblings, 0 replies; 8+ messages in thread From: Carlos Maiolino @ 2026-10-05 18:06 UTC (permalink / raw) To: cem; +Cc: linux-xfs, hch, djwong, sandeen On Thu, 24 Sep 2026 17:16:27 +0200, cem@kernel.org wrote: > From: Carlos Maiolino <cem@kernel.org> > > This is the new version of the error code printing series. > > The only modification here is on patch 2 which replaces the macros by > an inline function suggested by hch. > > [...] Applied to for-next, thanks! [1/3] xfs: add xfs_error_report the ability to display an error code commit: b3837dc0c73143f86549c3808e0323a47fe739ad [2/3] xfs: introduce xfs_trans_cancel_error() commit: f4922f6fb12b18ff1efe7cf5a46c187a07b7f9ea [3/3] xfs: make xfs_iomap_write_direct() report an error to xfs_trans_cancel commit: 90c4dd2fa8fc3485551023e855c093bd9b675256 Best regards, -- Carlos Maiolino <cem@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 0/3] Enable xfs error reporting to print out error codes 2026-09-24 15:16 [PATCH v4 0/3] Enable xfs error reporting to print out error codes cem ` (3 preceding siblings ...) 2026-10-05 18:06 ` [PATCH v4 0/3] Enable xfs error reporting to print out error codes Carlos Maiolino @ 2026-10-08 13:32 ` Carlos Maiolino 4 siblings, 0 replies; 8+ messages in thread From: Carlos Maiolino @ 2026-10-08 13:32 UTC (permalink / raw) To: cem; +Cc: linux-xfs, hch, djwong, sandeen On Thu, 24 Sep 2026 17:16:27 +0200, cem@kernel.org wrote: > From: Carlos Maiolino <cem@kernel.org> > > This is the new version of the error code printing series. > > The only modification here is on patch 2 which replaces the macros by > an inline function suggested by hch. > > [...] Applied to for-next, thanks! [1/3] xfs: add xfs_error_report the ability to display an error code commit: b3837dc0c73143f86549c3808e0323a47fe739ad [2/3] xfs: introduce xfs_trans_cancel_error() commit: f4922f6fb12b18ff1efe7cf5a46c187a07b7f9ea [3/3] xfs: make xfs_iomap_write_direct() report an error to xfs_trans_cancel commit: 90c4dd2fa8fc3485551023e855c093bd9b675256 Best regards, -- Carlos Maiolino <cem@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-10-08 13:32 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-09-24 15:16 [PATCH v4 0/3] Enable xfs error reporting to print out error codes cem 2026-09-24 15:16 ` [PATCH v4 1/3] xfs: add xfs_error_report the ability to display an error code cem 2026-09-24 15:16 ` [PATCH v4 2/3] xfs: introduce xfs_trans_cancel_error() cem 2026-09-24 18:57 ` Darrick J. Wong 2026-09-25 4:46 ` Christoph Hellwig 2026-09-24 15:16 ` [PATCH v4 3/3] xfs: make xfs_iomap_write_direct() report an error to xfs_trans_cancel cem 2026-10-05 18:06 ` [PATCH v4 0/3] Enable xfs error reporting to print out error codes Carlos Maiolino 2026-10-08 13:32 ` Carlos Maiolino
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).