From: "Darrick J. Wong" <djwong@kernel.org>
To: cem@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: Re: [RFC PATCH 2/3] xfs: enable xfs_trans_cancel() to report and error code
Date: Fri, 4 Sep 2026 18:10:54 -0700 [thread overview]
Message-ID: <20260905011054.GF1933798@frogsfrogsfrogs> (raw)
In-Reply-To: <20260904113231.1408890-3-cem@kernel.org>
On Fri, Sep 04, 2026 at 01:32:22PM +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.
> Enable xfs_trans_cancel() to receive an error code to be reported.
Stylistically I think I'd rather have an explicit @error and some macros
to avoid the va_args machinery.
void __xfs_trans_cancel(struct xfs_trans *tp, int error) {...}
#define xfs_trans_cancel(tp) __xfs_trans_cancel(tp, 0)
#define xfs_trans_cancel_with(tp, error) __xfs_trans_cancel(tp, error)
--D
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> Signed-off-by: Carlos Maiolino <cem@kernel.org>
> ---
> fs/xfs/xfs_trans.c | 12 +++++++++---
> fs/xfs/xfs_trans.h | 8 +++++++-
> 2 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index c6657072361a..f6004590565b 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -971,12 +971,18 @@ xfs_trans_commit(
> * xfs_trans_commit().
> */
> void
> -xfs_trans_cancel(
> - struct xfs_trans *tp)
> +_xfs_trans_cancel(
> + struct xfs_trans *tp, ...)
> {
> struct xfs_mount *mp = tp->t_mountp;
> struct xlog *log = mp->m_log;
> bool dirty = (tp->t_flags & XFS_TRANS_DIRTY);
> + int error = 0;
> + va_list args;
> +
> + va_start(args, tp);
> + error = va_arg(args, int);
> + va_end(args);
>
> trace_xfs_trans_cancel(tp, _RET_IP_);
>
> @@ -999,7 +1005,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, 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 2b366851e9a4..05cc7464eb3b 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -213,6 +213,13 @@ xfs_trans_read_buf(
> flags, bpp, ops);
> }
>
> +void _xfs_trans_cancel(xfs_trans_t *, ...);
> +
> +#define xfs_trans_cancel(tp, ...) \
> +({ \
> + _xfs_trans_cancel(tp, ##__VA_ARGS__); \
> +})
> +
> struct xfs_buf *xfs_trans_getsb(struct xfs_trans *);
> struct xfs_buf *xfs_trans_getrtsb(struct xfs_trans *tp);
>
> @@ -237,7 +244,6 @@ 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 *);
> int xfs_trans_ail_init(struct xfs_mount *);
> void xfs_trans_ail_destroy(struct xfs_mount *);
>
> --
> 2.55.0
>
>
next prev parent reply other threads:[~2026-09-05 1:10 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
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 [this message]
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=20260905011054.GF1933798@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox