Skip to content

Commit a2f790b

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: kill XBF_UNMAPPED
Unmapped buffer access is a pain, so kill it. The switch to large folios means we rarely pay a vmap penalty for large buffers, so this functionality is largely unnecessary now. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 94c78cf commit a2f790b

File tree

8 files changed

+21
-73
lines changed

8 files changed

+21
-73
lines changed

fs/xfs/libxfs/xfs_ialloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ xfs_ialloc_inode_init(
364364
(j * M_IGEO(mp)->blocks_per_cluster));
365365
error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
366366
mp->m_bsize * M_IGEO(mp)->blocks_per_cluster,
367-
XBF_UNMAPPED, &fbuf);
367+
0, &fbuf);
368368
if (error)
369369
return error;
370370

fs/xfs/libxfs/xfs_inode_buf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ xfs_imap_to_bp(
137137
int error;
138138

139139
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno,
140-
imap->im_len, XBF_UNMAPPED, bpp, &xfs_inode_buf_ops);
140+
imap->im_len, 0, bpp, &xfs_inode_buf_ops);
141141
if (xfs_metadata_is_sick(error))
142142
xfs_agno_mark_sick(mp, xfs_daddr_to_agno(mp, imap->im_blkno),
143143
XFS_SICK_AG_INODES);

fs/xfs/scrub/inode_repair.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,8 +1560,7 @@ xrep_dinode_core(
15601560

15611561
/* Read the inode cluster buffer. */
15621562
error = xfs_trans_read_buf(sc->mp, sc->tp, sc->mp->m_ddev_targp,
1563-
ri->imap.im_blkno, ri->imap.im_len, XBF_UNMAPPED, &bp,
1564-
NULL);
1563+
ri->imap.im_blkno, ri->imap.im_len, 0, &bp, NULL);
15651564
if (error)
15661565
return error;
15671566

fs/xfs/xfs_buf.c

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ _xfs_buf_alloc(
145145
* We don't want certain flags to appear in b_flags unless they are
146146
* specifically set by later operations on the buffer.
147147
*/
148-
flags &= ~(XBF_UNMAPPED | XBF_TRYLOCK | XBF_ASYNC | XBF_READ_AHEAD);
148+
flags &= ~(XBF_TRYLOCK | XBF_ASYNC | XBF_READ_AHEAD);
149149

150150
/*
151151
* A new buffer is held and locked by the owner. This ensures that the
@@ -289,9 +289,7 @@ xfs_buf_alloc_kmem(
289289
*
290290
* The third type of buffer is the multi-page buffer. These are always made
291291
* up of single pages so that they can be fed to vmap_ram() to return a
292-
* contiguous memory region we can access the data through, or mark it as
293-
* XBF_UNMAPPED and access the data directly through individual page_address()
294-
* calls.
292+
* contiguous memory region we can access the data through.
295293
*/
296294
static int
297295
xfs_buf_alloc_backing_mem(
@@ -413,8 +411,6 @@ _xfs_buf_map_pages(
413411
if (bp->b_page_count == 1) {
414412
/* A single page buffer is always mappable */
415413
bp->b_addr = page_address(bp->b_pages[0]);
416-
} else if (flags & XBF_UNMAPPED) {
417-
bp->b_addr = NULL;
418414
} else {
419415
int retried = 0;
420416
unsigned nofs_flag;
@@ -1345,7 +1341,7 @@ __xfs_buf_ioend(
13451341
trace_xfs_buf_iodone(bp, _RET_IP_);
13461342

13471343
if (bp->b_flags & XBF_READ) {
1348-
if (!bp->b_error && bp->b_addr && is_vmalloc_addr(bp->b_addr))
1344+
if (!bp->b_error && is_vmalloc_addr(bp->b_addr))
13491345
invalidate_kernel_vmap_range(bp->b_addr,
13501346
xfs_buf_vmap_len(bp));
13511347
if (!bp->b_error && bp->b_ops)
@@ -1526,7 +1522,7 @@ xfs_buf_submit_bio(
15261522
__bio_add_page(bio, bp->b_pages[p], PAGE_SIZE, 0);
15271523
bio->bi_iter.bi_size = size; /* limit to the actual size used */
15281524

1529-
if (bp->b_addr && is_vmalloc_addr(bp->b_addr))
1525+
if (is_vmalloc_addr(bp->b_addr))
15301526
flush_kernel_vmap_range(bp->b_addr,
15311527
xfs_buf_vmap_len(bp));
15321528
}
@@ -1657,52 +1653,6 @@ xfs_buf_submit(
16571653
xfs_buf_submit_bio(bp);
16581654
}
16591655

1660-
void *
1661-
xfs_buf_offset(
1662-
struct xfs_buf *bp,
1663-
size_t offset)
1664-
{
1665-
struct page *page;
1666-
1667-
if (bp->b_addr)
1668-
return bp->b_addr + offset;
1669-
1670-
page = bp->b_pages[offset >> PAGE_SHIFT];
1671-
return page_address(page) + (offset & (PAGE_SIZE-1));
1672-
}
1673-
1674-
void
1675-
xfs_buf_zero(
1676-
struct xfs_buf *bp,
1677-
size_t boff,
1678-
size_t bsize)
1679-
{
1680-
size_t bend;
1681-
1682-
if (bp->b_addr) {
1683-
memset(bp->b_addr + boff, 0, bsize);
1684-
return;
1685-
}
1686-
1687-
bend = boff + bsize;
1688-
while (boff < bend) {
1689-
struct page *page;
1690-
int page_index, page_offset, csize;
1691-
1692-
page_index = boff >> PAGE_SHIFT;
1693-
page_offset = boff & ~PAGE_MASK;
1694-
page = bp->b_pages[page_index];
1695-
csize = min_t(size_t, PAGE_SIZE - page_offset,
1696-
BBTOB(bp->b_length) - boff);
1697-
1698-
ASSERT((csize + page_offset) <= PAGE_SIZE);
1699-
1700-
memset(page_address(page) + page_offset, 0, csize);
1701-
1702-
boff += csize;
1703-
}
1704-
}
1705-
17061656
/*
17071657
* Log a message about and stale a buffer that a caller has decided is corrupt.
17081658
*

fs/xfs/xfs_buf.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ struct xfs_buf;
4848
#define XBF_LIVESCAN (1u << 28)
4949
#define XBF_INCORE (1u << 29)/* lookup only, return if found in cache */
5050
#define XBF_TRYLOCK (1u << 30)/* lock requested, but do not wait */
51-
#define XBF_UNMAPPED (1u << 31)/* do not map the buffer */
5251

5352

5453
typedef unsigned int xfs_buf_flags_t;
@@ -68,8 +67,7 @@ typedef unsigned int xfs_buf_flags_t;
6867
/* The following interface flags should never be set */ \
6968
{ XBF_LIVESCAN, "LIVESCAN" }, \
7069
{ XBF_INCORE, "INCORE" }, \
71-
{ XBF_TRYLOCK, "TRYLOCK" }, \
72-
{ XBF_UNMAPPED, "UNMAPPED" }
70+
{ XBF_TRYLOCK, "TRYLOCK" }
7371

7472
/*
7573
* Internal state flags.
@@ -313,12 +311,20 @@ extern void __xfs_buf_ioerror(struct xfs_buf *bp, int error,
313311
#define xfs_buf_ioerror(bp, err) __xfs_buf_ioerror((bp), (err), __this_address)
314312
extern void xfs_buf_ioerror_alert(struct xfs_buf *bp, xfs_failaddr_t fa);
315313
void xfs_buf_ioend_fail(struct xfs_buf *);
316-
void xfs_buf_zero(struct xfs_buf *bp, size_t boff, size_t bsize);
317314
void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa);
318315
#define xfs_buf_mark_corrupt(bp) __xfs_buf_mark_corrupt((bp), __this_address)
319316

320317
/* Buffer Utility Routines */
321-
extern void *xfs_buf_offset(struct xfs_buf *, size_t);
318+
static inline void *xfs_buf_offset(struct xfs_buf *bp, size_t offset)
319+
{
320+
return bp->b_addr + offset;
321+
}
322+
323+
static inline void xfs_buf_zero(struct xfs_buf *bp, size_t boff, size_t bsize)
324+
{
325+
memset(bp->b_addr + boff, 0, bsize);
326+
}
327+
322328
extern void xfs_buf_stale(struct xfs_buf *bp);
323329

324330
/* Delayed Write Buffer Routines */

fs/xfs/xfs_buf_item.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ xfs_buf_item_straddle(
7070
{
7171
void *first, *last;
7272

73-
if (bp->b_page_count == 1 || !(bp->b_flags & XBF_UNMAPPED))
73+
if (bp->b_page_count == 1)
7474
return false;
7575

7676
first = xfs_buf_offset(bp, offset + (first_bit << XFS_BLF_SHIFT));

fs/xfs/xfs_buf_item_recover.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,6 @@ xlog_recover_buf_commit_pass2(
10061006
struct xfs_mount *mp = log->l_mp;
10071007
struct xfs_buf *bp;
10081008
int error;
1009-
uint buf_flags;
10101009
xfs_lsn_t lsn;
10111010

10121011
/*
@@ -1025,13 +1024,8 @@ xlog_recover_buf_commit_pass2(
10251024
}
10261025

10271026
trace_xfs_log_recover_buf_recover(log, buf_f);
1028-
1029-
buf_flags = 0;
1030-
if (buf_f->blf_flags & XFS_BLF_INODE_BUF)
1031-
buf_flags |= XBF_UNMAPPED;
1032-
10331027
error = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len,
1034-
buf_flags, &bp, NULL);
1028+
0, &bp, NULL);
10351029
if (error)
10361030
return error;
10371031

fs/xfs/xfs_inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,8 +1721,7 @@ xfs_ifree_cluster(
17211721
* to mark all the active inodes on the buffer stale.
17221722
*/
17231723
error = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno,
1724-
mp->m_bsize * igeo->blocks_per_cluster,
1725-
XBF_UNMAPPED, &bp);
1724+
mp->m_bsize * igeo->blocks_per_cluster, 0, &bp);
17261725
if (error)
17271726
return error;
17281727

0 commit comments

Comments
 (0)