xfs: hide b_flags manipulation from code outside of xfs_buf.c

Add helpers for the remaining buffer flags manipulation not done in the
core buffer cache code.

Signed-off-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:
Christoph Hellwig 2026-07-15 16:50:59 +02:00 committed by Carlos Maiolino
parent d80fe85bb2
commit 9f224de410
7 changed files with 29 additions and 13 deletions

View File

@ -248,11 +248,10 @@ xfs_btree_bload_drop_buf(
return 0;
/*
* Mark this buffer XBF_DONE (i.e. uptodate) so that a subsequent
* xfs_buf_read will not pointlessly reread the contents from the disk.
* Mark this buffer uptodate so that a subsequent xfs_buf_read will
* not pointlessly reread the contents from the disk.
*/
bp->b_flags |= XBF_DONE;
xfs_buf_set_uptodate(bp);
xfs_buf_delwri_queue_here(bp, buffers_list);
xfs_buf_relse(bp);
*bpp = NULL;

View File

@ -413,7 +413,7 @@ xfs_ialloc_inode_init(
xfs_trans_ordered_buf(tp, fbuf);
}
} else {
fbuf->b_flags |= XBF_DONE;
xfs_buf_set_uptodate(fbuf);
xfs_buf_delwri_queue(fbuf, buffer_list);
xfs_buf_relse(fbuf);
}

View File

@ -55,6 +55,13 @@ static inline bool xfs_buf_is_uncached(struct xfs_buf *bp)
return bp->b_rhash_key == XFS_BUF_DADDR_NULL;
}
void
xfs_buf_set_uptodate(
struct xfs_buf *bp)
{
bp->b_flags |= XBF_DONE;
}
/*
* When we mark a buffer stale, we remove the buffer from the LRU and clear the
* b_lru_ref count so that the buffer is freed immediately when the buffer
@ -85,6 +92,15 @@ xfs_buf_stale(
spin_unlock(&bp->b_lockref.lock);
}
void
xfs_buf_clear_stale(
struct xfs_buf *bp)
{
ASSERT(bp->b_flags & XBF_STALE);
bp->b_flags &= ~XBF_STALE;
}
static void
xfs_buf_free_callback(
struct callback_head *cb)

View File

@ -301,7 +301,9 @@ static inline void xfs_buf_zero(struct xfs_buf *bp, size_t boff, size_t bsize)
memset(bp->b_addr + boff, 0, bsize);
}
extern void xfs_buf_stale(struct xfs_buf *bp);
void xfs_buf_set_uptodate(struct xfs_buf *bp);
void xfs_buf_stale(struct xfs_buf *bp);
void xfs_buf_clear_stale(struct xfs_buf *bp);
/* Delayed Write Buffer Routines */
extern void xfs_buf_delwri_cancel(struct list_head *);

View File

@ -501,7 +501,7 @@ xfs_do_force_shutdown(
return;
}
if (mp->m_sb_bp)
mp->m_sb_bp->b_flags |= XBF_DONE;
xfs_buf_set_uptodate(mp->m_sb_bp);
if (flags & SHUTDOWN_FORCE_UMOUNT)
xfs_alert(mp, "User initiated shutdown received.");

View File

@ -1753,7 +1753,7 @@ xfs_ifree_cluster(
* attachment may occur in xfs_inode_item_precommit() after we
* have marked this buffer stale. If this buffer was not in
* memory before xfs_ifree_cluster() started, it will not be
* marked XBF_DONE and this will cause problems later in
* marked uptodate and this will cause problems later in
* xfs_inode_item_precommit() when we trip over a (stale, !done)
* buffer to attached to the transaction.
*
@ -1766,7 +1766,7 @@ xfs_ifree_cluster(
* fail. We can acheive this by adding a write verifier to the
* buffer.
*/
bp->b_flags |= XBF_DONE;
xfs_buf_set_uptodate(bp);
bp->b_ops = &xfs_inode_buf_ops;
/*

View File

@ -140,7 +140,7 @@ xfs_trans_get_buf_map(
ASSERT(xfs_buf_islocked(bp));
if (xfs_is_shutdown(tp->t_mountp)) {
xfs_buf_stale(bp);
bp->b_flags |= XBF_DONE;
xfs_buf_set_uptodate(bp);
}
ASSERT(bp->b_transp == tp);
@ -482,7 +482,7 @@ xfs_trans_dirty_buf(
* item from the AIL and free it when the buffer is flushed
* to disk.
*/
bp->b_flags |= XBF_DONE;
xfs_buf_set_uptodate(bp);
ASSERT(atomic_read(&bip->bli_refcount) > 0);
@ -494,8 +494,7 @@ xfs_trans_dirty_buf(
*/
if (bip->bli_flags & XFS_BLI_STALE) {
bip->bli_flags &= ~XFS_BLI_STALE;
ASSERT(bp->b_flags & XBF_STALE);
bp->b_flags &= ~XBF_STALE;
xfs_buf_clear_stale(bp);
bip->__bli_format.blf_flags &= ~XFS_BLF_CANCEL;
}
bip->bli_flags |= XFS_BLI_DIRTY | XFS_BLI_LOGGED;