Skip to content

Commit ac97520

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
iomap: Use folio_next_pos()
This is one instruction more efficient than open-coding folio_pos() + folio_size(). It's the equivalent of (x + y) << z rather than x << z + y << z. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Link: https://patch.msgid.link/20251024170822.1427218-8-willy@infradead.org Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Cc: Darrick J. Wong <djwong@kernel.org> Cc: linux-xfs@vger.kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 5f0fc78 commit ac97520

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

fs/iomap/buffered-io.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ static int __iomap_write_begin(const struct iomap_iter *iter,
707707
* are not changing pagecache contents.
708708
*/
709709
if (!(iter->flags & IOMAP_UNSHARE) && pos <= folio_pos(folio) &&
710-
pos + len >= folio_pos(folio) + folio_size(folio))
710+
pos + len >= folio_next_pos(folio))
711711
return 0;
712712

713713
ifs = ifs_alloc(iter->inode, folio, iter->flags);
@@ -1097,8 +1097,7 @@ static void iomap_write_delalloc_ifs_punch(struct inode *inode,
10971097
if (!ifs)
10981098
return;
10991099

1100-
last_byte = min_t(loff_t, end_byte - 1,
1101-
folio_pos(folio) + folio_size(folio) - 1);
1100+
last_byte = min_t(loff_t, end_byte - 1, folio_next_pos(folio) - 1);
11021101
first_blk = offset_in_folio(folio, start_byte) >> blkbits;
11031102
last_blk = offset_in_folio(folio, last_byte) >> blkbits;
11041103
for (i = first_blk; i <= last_blk; i++) {
@@ -1129,8 +1128,7 @@ static void iomap_write_delalloc_punch(struct inode *inode, struct folio *folio,
11291128
* Make sure the next punch start is correctly bound to
11301129
* the end of this data range, not the end of the folio.
11311130
*/
1132-
*punch_start_byte = min_t(loff_t, end_byte,
1133-
folio_pos(folio) + folio_size(folio));
1131+
*punch_start_byte = min_t(loff_t, end_byte, folio_next_pos(folio));
11341132
}
11351133

11361134
/*
@@ -1170,7 +1168,7 @@ static void iomap_write_delalloc_scan(struct inode *inode,
11701168
start_byte, end_byte, iomap, punch);
11711169

11721170
/* move offset to start of next folio in range */
1173-
start_byte = folio_pos(folio) + folio_size(folio);
1171+
start_byte = folio_next_pos(folio);
11741172
folio_unlock(folio);
11751173
folio_put(folio);
11761174
}

0 commit comments

Comments
 (0)