]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: add a b_iodone callback to struct xfs_buf xfs-buf-cleanups
authorChristoph Hellwig <hch@lst.de>
Tue, 31 Dec 2024 06:41:40 +0000 (06:41 +0000)
committerChristoph Hellwig <hch@lst.de>
Sat, 11 Jan 2025 05:21:43 +0000 (06:21 +0100)
Stop open coding the log item completions and instead add a callback
into back into the submitter.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
fs/xfs/xfs_buf.c
fs/xfs/xfs_buf.h
fs/xfs/xfs_dquot.c
fs/xfs/xfs_inode_item.c
fs/xfs/xfs_trans_buf.c

index d5e23c4c76748c7187cc4e95cbca737200fed410..d9636bff16ce47be6ac760890afffde5730ac3f0 100644 (file)
@@ -1392,11 +1392,8 @@ xfs_buf_ioend(
                if (bp->b_log_item)
                        xfs_buf_item_done(bp);
 
-               if (bp->b_flags & _XBF_INODES)
-                       xfs_buf_inode_iodone(bp);
-               else if (bp->b_flags & _XBF_DQUOTS)
-                       xfs_buf_dquot_iodone(bp);
-
+               if (bp->b_iodone)
+                       bp->b_iodone(bp);
        }
 
        bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD |
index c53d27439ff2762777df6a4a10decc2fc6c27838..10bf66e074a0f40677773373ed05cc82c000d7eb 100644 (file)
@@ -34,8 +34,6 @@ struct xfs_buf;
 #define XBF_WRITE_FAIL  (1u << 7) /* async writes have failed on this buffer */
 
 /* buffer type flags for write callbacks */
-#define _XBF_INODES     (1u << 16)/* inode buffer */
-#define _XBF_DQUOTS     (1u << 17)/* dquot buffer */
 #define _XBF_LOGRECOVERY (1u << 18)/* log recovery buffer */
 
 /* flags used only internally */
@@ -65,8 +63,6 @@ typedef unsigned int xfs_buf_flags_t;
        { XBF_DONE,             "DONE" }, \
        { XBF_STALE,            "STALE" }, \
        { XBF_WRITE_FAIL,       "WRITE_FAIL" }, \
-       { _XBF_INODES,          "INODES" }, \
-       { _XBF_DQUOTS,          "DQUOTS" }, \
        { _XBF_LOGRECOVERY,     "LOG_RECOVERY" }, \
        { _XBF_PAGES,           "PAGES" }, \
        { _XBF_KMEM,            "KMEM" }, \
@@ -205,6 +201,7 @@ struct xfs_buf {
        unsigned int            b_offset;       /* page offset of b_addr,
                                                   only for _XBF_KMEM buffers */
        int                     b_error;        /* error code on I/O */
+       void                    (*b_iodone)(struct xfs_buf *bp);
 
        /*
         * async write failure retry count. Initialised to zero on the first
index 1082c5d980c85f40f2ada4e110a34aca8b3b1ca9..edbc521870a10a1086098dd7bd105d510275a88b 100644 (file)
@@ -1451,7 +1451,7 @@ xfs_qm_dqflush(
         * Attach the dquot to the buffer so that we can remove this dquot from
         * the AIL and release the flush lock once the dquot is synced to disk.
         */
-       bp->b_flags |= _XBF_DQUOTS;
+       bp->b_iodone = xfs_buf_dquot_iodone;
        list_add_tail(&lip->li_bio_list, &bp->b_li_list);
 
        /*
index 9b3dac5b2a3332e3def9b7ff9f108e0e1f23bb4a..35803fcf0bebddc86489c570df219c8b900c0e11 100644 (file)
@@ -199,7 +199,7 @@ xfs_inode_item_precommit(
                xfs_buf_hold(bp);
                spin_lock(&iip->ili_lock);
                iip->ili_item.li_buf = bp;
-               bp->b_flags |= _XBF_INODES;
+               bp->b_iodone = xfs_buf_inode_iodone;
                list_add_tail(&iip->ili_item.li_bio_list, &bp->b_li_list);
                xfs_trans_brelse(tp, bp);
        }
index 8e886ecfd69a3b6cf4e4566a846da9024472d7d3..53af546c0b2354fb756f82656ddacab5d23d7b04 100644 (file)
@@ -659,7 +659,7 @@ xfs_trans_inode_buf(
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
 
        bip->bli_flags |= XFS_BLI_INODE_BUF;
-       bp->b_flags |= _XBF_INODES;
+       bp->b_iodone = xfs_buf_inode_iodone;
        xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF);
 }
 
@@ -684,7 +684,7 @@ xfs_trans_stale_inode_buf(
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
 
        bip->bli_flags |= XFS_BLI_STALE_INODE;
-       bp->b_flags |= _XBF_INODES;
+       bp->b_iodone = xfs_buf_inode_iodone;
        xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF);
 }
 
@@ -709,7 +709,7 @@ xfs_trans_inode_alloc_buf(
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
 
        bip->bli_flags |= XFS_BLI_INODE_ALLOC_BUF;
-       bp->b_flags |= _XBF_INODES;
+       bp->b_iodone = xfs_buf_inode_iodone;
        xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF);
 }
 
@@ -820,6 +820,6 @@ xfs_trans_dquot_buf(
                break;
        }
 
-       bp->b_flags |= _XBF_DQUOTS;
+       bp->b_iodone = xfs_buf_dquot_iodone;
        xfs_trans_buf_set_type(tp, bp, type);
 }