xfs: introduce xfs_trans_cancel_error()

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
Carlos Maiolino 2026-09-24 17:16:29 +02:00
parent b3837dc0c7
commit f4922f6fb1
2 changed files with 13 additions and 4 deletions

View File

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

View File

@ -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__ */