Skip to content

Commit

Permalink
xfs: mark dquot buffers in cache
Browse files Browse the repository at this point in the history
dquot buffers always have write IO callbacks, so by marking them
directly we can avoid needing to attach ->b_iodone functions to
them. This avoids an indirect call, and makes future modifications
much simpler.

This is largely a rearrangement of the code at this point - no IO
completion functionality changes at this point, just how the
code is run is modified.

Signed-off-by: Dave Chinner <[email protected]>
Reviewed-by: Brian Foster <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
  • Loading branch information
dchinner authored and djwong committed Jul 6, 2020
1 parent f593bf1 commit 0c7e5af
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/xfs/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,11 @@ xfs_buf_ioend(
return;
}

if (bp->b_flags & _XBF_DQUOTS) {
xfs_buf_dquot_iodone(bp);
return;
}

if (bp->b_iodone) {
(*(bp->b_iodone))(bp);
return;
Expand Down
2 changes: 2 additions & 0 deletions fs/xfs/xfs_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

/* buffer type flags for write callbacks */
#define _XBF_INODES (1 << 16)/* inode buffer */
#define _XBF_DQUOTS (1 << 17)/* dquot buffer */

/* flags used only internally */
#define _XBF_PAGES (1 << 20)/* backed by refcounted pages */
Expand All @@ -54,6 +55,7 @@ typedef unsigned int xfs_buf_flags_t;
{ XBF_STALE, "STALE" }, \
{ XBF_WRITE_FAIL, "WRITE_FAIL" }, \
{ _XBF_INODES, "INODES" }, \
{ _XBF_DQUOTS, "DQUOTS" }, \
{ _XBF_PAGES, "PAGES" }, \
{ _XBF_KMEM, "KMEM" }, \
{ _XBF_DELWRI_Q, "DELWRI_Q" }, \
Expand Down
10 changes: 10 additions & 0 deletions fs/xfs/xfs_buf_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,16 @@ xfs_buf_inode_iodone(
xfs_buf_ioend_finish(bp);
}

/*
* Dquot buffer iodone callback function.
*/
void
xfs_buf_dquot_iodone(
struct xfs_buf *bp)
{
xfs_buf_run_callbacks(bp);
xfs_buf_ioend_finish(bp);
}

/*
* This is the iodone() function for buffers which have been
Expand Down
1 change: 1 addition & 0 deletions fs/xfs/xfs_buf_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void xfs_buf_attach_iodone(struct xfs_buf *,
void xfs_buf_iodone_callbacks(struct xfs_buf *);
void xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
void xfs_buf_inode_iodone(struct xfs_buf *);
void xfs_buf_dquot_iodone(struct xfs_buf *);
bool xfs_buf_log_check_iovec(struct xfs_log_iovec *iovec);

extern kmem_zone_t *xfs_buf_item_zone;
Expand Down
1 change: 1 addition & 0 deletions fs/xfs/xfs_dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,7 @@ xfs_qm_dqflush(
* Attach an iodone routine 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;
xfs_buf_attach_iodone(bp, xfs_qm_dqflush_done,
&dqp->q_logitem.qli_item);

Expand Down
1 change: 1 addition & 0 deletions fs/xfs/xfs_trans_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,5 +788,6 @@ xfs_trans_dquot_buf(
break;
}

bp->b_flags |= _XBF_DQUOTS;
xfs_trans_buf_set_type(tp, bp, type);
}

0 comments on commit 0c7e5af

Please sign in to comment.