Skip to content

xfs: clean up buffer cache disk addressing

Dave Chinner linux-xfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 2 repliesIn review
  2. v13 patches 10 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3xfs: introduce xfs_buf_daddr()fs/xfs/libxfs/xfs_alloc_btree.c fs/xfs/libxfs/xfs_attr.c fs/xfs/libxfs/xfs_bmap.c +12 more+26 -220 replies
2/3xfs: convert bp->b_bn references to xfs_buf_daddr()fs/xfs/libxfs/xfs_ag.c fs/xfs/libxfs/xfs_attr_leaf.c fs/xfs/libxfs/xfs_attr_remote.c +18 more+58 -611 reply
3/3xfs: rename buffer cache index variable b_bnfs/xfs/xfs_buf.c fs/xfs/xfs_buf.h+12 -251 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchDarrick J. WongChristoph Hellwig
1/3R-b R-b
2/3R-b R-b
3/3R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH 0/3 v2] xfs: clean up buffer cache disk addressing

Over time, we've moved from using bp->b_bn as the physical disk address for a buffer to using the address of the first buffer map attached to the buffer. This can be seen by the implementation of XFS_BUF_ADDR() macro:

#define XFS_BUF_ADDR(bp) ((bp)->b_maps[0].bm_bn)

The bp->b_bn value is now used as the buffer cache index for the buffer, and it is always set to XFS_BUF_DADDR_NULL for uncached buffers. Hence code that uses bp->b_bn for the physical address of the buffer will not do the right thing when passed an uncached buffer.

THis series of patches addresses this problem. It adds a helper function xfs_buf_daddr() to extract the physical address of the buffer from it, and replaces all the open coded bp->b_bn accesses and the XFS_BUF_ADDR() users to use it. It then renames b_bn to b_index and converts all the internal cache lookup code to use b_index rather than b_bn.

The result is that all code now uses xfs_buf_daddr() where physical addresses are required, and the cache index variable isn't named in a manner that engenders external use of access. The changes end up being relatively small, and the impact on userspace outside libxfs is even smaller (only a couple of dozen references to b_bn or XFS_BUF_ADDR).

Version 2
- rebase on 5.14-rc4 + for-next + "xfs: rework feature flags v3"
- use __be64 type for comparison in xfs_btree_new_iroot()
- rename b_index to b_rhash_key
- fix typos and wording in commit messages

Version 1
- based on 5.14-rc4 + for-next
- https://lore.kernel.org/linux-xfs/[email protected]/