Skip to content

Commit 4e35be6

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: add a b_iodone callback to struct xfs_buf
Stop open coding the log item completions and instead add a callback into back into the submitter. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Acked-by: Dave Chinner <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 4f1aefd commit 4e35be6

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

fs/xfs/xfs_buf.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,11 +1392,8 @@ xfs_buf_ioend(
13921392
if (bp->b_log_item)
13931393
xfs_buf_item_done(bp);
13941394

1395-
if (bp->b_flags & _XBF_INODES)
1396-
xfs_buf_inode_iodone(bp);
1397-
else if (bp->b_flags & _XBF_DQUOTS)
1398-
xfs_buf_dquot_iodone(bp);
1399-
1395+
if (bp->b_iodone)
1396+
bp->b_iodone(bp);
14001397
}
14011398

14021399
bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD |

fs/xfs/xfs_buf.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ struct xfs_buf;
3434
#define XBF_WRITE_FAIL (1u << 7) /* async writes have failed on this buffer */
3535

3636
/* buffer type flags for write callbacks */
37-
#define _XBF_INODES (1u << 16)/* inode buffer */
38-
#define _XBF_DQUOTS (1u << 17)/* dquot buffer */
3937
#define _XBF_LOGRECOVERY (1u << 18)/* log recovery buffer */
4038

4139
/* flags used only internally */
@@ -65,8 +63,6 @@ typedef unsigned int xfs_buf_flags_t;
6563
{ XBF_DONE, "DONE" }, \
6664
{ XBF_STALE, "STALE" }, \
6765
{ XBF_WRITE_FAIL, "WRITE_FAIL" }, \
68-
{ _XBF_INODES, "INODES" }, \
69-
{ _XBF_DQUOTS, "DQUOTS" }, \
7066
{ _XBF_LOGRECOVERY, "LOG_RECOVERY" }, \
7167
{ _XBF_PAGES, "PAGES" }, \
7268
{ _XBF_KMEM, "KMEM" }, \
@@ -205,6 +201,7 @@ struct xfs_buf {
205201
unsigned int b_offset; /* page offset of b_addr,
206202
only for _XBF_KMEM buffers */
207203
int b_error; /* error code on I/O */
204+
void (*b_iodone)(struct xfs_buf *bp);
208205

209206
/*
210207
* async write failure retry count. Initialised to zero on the first

fs/xfs/xfs_dquot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ xfs_qm_dqflush(
14511451
* Attach the dquot to the buffer so that we can remove this dquot from
14521452
* the AIL and release the flush lock once the dquot is synced to disk.
14531453
*/
1454-
bp->b_flags |= _XBF_DQUOTS;
1454+
bp->b_iodone = xfs_buf_dquot_iodone;
14551455
list_add_tail(&lip->li_bio_list, &bp->b_li_list);
14561456

14571457
/*

fs/xfs/xfs_inode_item.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ xfs_inode_item_precommit(
199199
xfs_buf_hold(bp);
200200
spin_lock(&iip->ili_lock);
201201
iip->ili_item.li_buf = bp;
202-
bp->b_flags |= _XBF_INODES;
202+
bp->b_iodone = xfs_buf_inode_iodone;
203203
list_add_tail(&iip->ili_item.li_bio_list, &bp->b_li_list);
204204
xfs_trans_brelse(tp, bp);
205205
}

fs/xfs/xfs_trans_buf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ xfs_trans_inode_buf(
659659
ASSERT(atomic_read(&bip->bli_refcount) > 0);
660660

661661
bip->bli_flags |= XFS_BLI_INODE_BUF;
662-
bp->b_flags |= _XBF_INODES;
662+
bp->b_iodone = xfs_buf_inode_iodone;
663663
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF);
664664
}
665665

@@ -684,7 +684,7 @@ xfs_trans_stale_inode_buf(
684684
ASSERT(atomic_read(&bip->bli_refcount) > 0);
685685

686686
bip->bli_flags |= XFS_BLI_STALE_INODE;
687-
bp->b_flags |= _XBF_INODES;
687+
bp->b_iodone = xfs_buf_inode_iodone;
688688
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF);
689689
}
690690

@@ -709,7 +709,7 @@ xfs_trans_inode_alloc_buf(
709709
ASSERT(atomic_read(&bip->bli_refcount) > 0);
710710

711711
bip->bli_flags |= XFS_BLI_INODE_ALLOC_BUF;
712-
bp->b_flags |= _XBF_INODES;
712+
bp->b_iodone = xfs_buf_inode_iodone;
713713
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF);
714714
}
715715

@@ -820,6 +820,6 @@ xfs_trans_dquot_buf(
820820
break;
821821
}
822822

823-
bp->b_flags |= _XBF_DQUOTS;
823+
bp->b_iodone = xfs_buf_dquot_iodone;
824824
xfs_trans_buf_set_type(tp, bp, type);
825825
}

0 commit comments

Comments
 (0)