]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: improve the xfs_buf_ioend_fail calling convention
authorChristoph Hellwig <hch@lst.de>
Thu, 25 Jun 2026 13:58:33 +0000 (15:58 +0200)
committerCarlos Maiolino <cem@kernel.org>
Wed, 1 Jul 2026 10:29:50 +0000 (12:29 +0200)
Move setting the ASYNC flag into xfs_buf_ioend_fail, assert that the
buffer is locked as expected, and drop the confusing _ioend in the
name.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_buf.c
fs/xfs/xfs_buf.h
fs/xfs/xfs_buf_item.c
fs/xfs/xfs_inode.c

index 0061abffcbb5ca690abbe56836e90c1c599aebfb..aa4317793c574fd4da139310a55108c6d39190d9 100644 (file)
@@ -1192,17 +1192,18 @@ xfs_buf_ioerror_alert(
 }
 
 /*
- * To simulate an I/O failure, the buffer must be locked and held with at least
- * two references.
+ * Fail a locked and referenced buffer outside the I/O path.
  *
- * The buf item reference is dropped via ioend processing. The second reference
- * is owned by the caller and is dropped on I/O completion if the buffer is
- * XBF_ASYNC.
+ * The caller transfers a reference which will be released after processing the
+ * error.
  */
 void
-xfs_buf_ioend_fail(
+xfs_buf_fail(
        struct xfs_buf  *bp)
 {
+       ASSERT(xfs_buf_islocked(bp));
+
+       bp->b_flags |= XBF_ASYNC;
        bp->b_flags &= ~XBF_DONE;
        xfs_buf_stale(bp);
        xfs_buf_ioerror(bp, -EIO);
index b3cd1c7029f142bc6bb324d2cb986a7a77ff84b9..79cc9c3f0254e32b9a78fa6d5fd08fd91d60e001 100644 (file)
@@ -290,7 +290,7 @@ extern void __xfs_buf_ioerror(struct xfs_buf *bp, int error,
                xfs_failaddr_t failaddr);
 #define xfs_buf_ioerror(bp, err) __xfs_buf_ioerror((bp), (err), __this_address)
 extern void xfs_buf_ioerror_alert(struct xfs_buf *bp, xfs_failaddr_t fa);
-void xfs_buf_ioend_fail(struct xfs_buf *);
+void xfs_buf_fail(struct xfs_buf *bp);
 void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa);
 #define xfs_buf_mark_corrupt(bp) __xfs_buf_mark_corrupt((bp), __this_address)
 
index 8487635579e59e01f13ee01270b359161f4c3968..1f055cd6732e6bd76488afac64f6d221099021dd 100644 (file)
@@ -549,8 +549,7 @@ xfs_buf_item_unpin(
                 * wait for the lock and then run the IO failure completion.
                 */
                xfs_buf_lock(bp);
-               bp->b_flags |= XBF_ASYNC;
-               xfs_buf_ioend_fail(bp);
+               xfs_buf_fail(bp);
                return;
        }
 
index 317eb57f989f208a8d4f013931a3cec00976ea5b..15279d22a894fad23270b138ef2b369247a315a3 100644 (file)
@@ -2646,8 +2646,7 @@ xfs_iflush_cluster(
                 * inode cluster buffers.
                 */
                xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
-               bp->b_flags |= XBF_ASYNC;
-               xfs_buf_ioend_fail(bp);
+               xfs_buf_fail(bp);
                return error;
        }