Skip to content

Commit 4db47b2

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
ext4: 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-5-willy@infradead.org Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Andreas Dilger <adilger.kernel@dilger.ca> Cc: linux-ext4@vger.kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 6870892 commit 4db47b2

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

fs/ext4/inode.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,8 +1319,8 @@ static int ext4_write_begin(const struct kiocb *iocb,
13191319
if (IS_ERR(folio))
13201320
return PTR_ERR(folio);
13211321

1322-
if (pos + len > folio_pos(folio) + folio_size(folio))
1323-
len = folio_pos(folio) + folio_size(folio) - pos;
1322+
if (len > folio_next_pos(folio) - pos)
1323+
len = folio_next_pos(folio) - pos;
13241324

13251325
from = offset_in_folio(folio, pos);
13261326
to = from + len;
@@ -2704,7 +2704,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
27042704

27052705
if (mpd->map.m_len == 0)
27062706
mpd->start_pos = folio_pos(folio);
2707-
mpd->next_pos = folio_pos(folio) + folio_size(folio);
2707+
mpd->next_pos = folio_next_pos(folio);
27082708
/*
27092709
* Writeout when we cannot modify metadata is simple.
27102710
* Just submit the page. For data=journal mode we
@@ -3146,8 +3146,8 @@ static int ext4_da_write_begin(const struct kiocb *iocb,
31463146
if (IS_ERR(folio))
31473147
return PTR_ERR(folio);
31483148

3149-
if (pos + len > folio_pos(folio) + folio_size(folio))
3150-
len = folio_pos(folio) + folio_size(folio) - pos;
3149+
if (len > folio_next_pos(folio) - pos)
3150+
len = folio_next_pos(folio) - pos;
31513151

31523152
ret = ext4_block_write_begin(NULL, folio, pos, len,
31533153
ext4_da_get_block_prep);

0 commit comments

Comments
 (0)