Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: cem@kernel.org
Cc: linux-xfs@vger.kernel.org, hch@lst.de, sandeen@sandeen.net
Subject: Re: [PATCH v4 2/3] xfs: introduce xfs_trans_cancel_error()
Date: Thu, 24 Sep 2026 11:57:16 -0700	[thread overview]
Message-ID: <20260924185716.GN2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <20260924151638.38535-3-cem@kernel.org>

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
> 
> 

  reply	other threads:[~2026-09-24 18:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20260924185716.GN2705364@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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