Skip to content

Commit f2a3717

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: add a fast path to xfs_buf_zero when b_addr is set
No need to walk the page list if bp->b_addr is valid. That also means b_offset doesn't need to be taken into account in the unmapped loop as b_offset is only set for kmem backed buffers which are always mapped. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 69659e4 commit f2a3717

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

fs/xfs/xfs_buf.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,13 +1633,18 @@ xfs_buf_zero(
16331633
{
16341634
size_t bend;
16351635

1636+
if (bp->b_addr) {
1637+
memset(bp->b_addr + boff, 0, bsize);
1638+
return;
1639+
}
1640+
16361641
bend = boff + bsize;
16371642
while (boff < bend) {
16381643
struct page *page;
16391644
int page_index, page_offset, csize;
16401645

1641-
page_index = (boff + bp->b_offset) >> PAGE_SHIFT;
1642-
page_offset = (boff + bp->b_offset) & ~PAGE_MASK;
1646+
page_index = boff >> PAGE_SHIFT;
1647+
page_offset = boff & ~PAGE_MASK;
16431648
page = bp->b_pages[page_index];
16441649
csize = min_t(size_t, PAGE_SIZE - page_offset,
16451650
BBTOB(bp->b_length) - boff);

0 commit comments

Comments
 (0)