* [PATCH 04/10] ext4: Use folio_next_pos() [not found] <20251024170822.1427218-1-willy@infradead.org> @ 2025-10-24 17:08 ` Matthew Wilcox (Oracle) 2025-10-25 3:20 ` Zhang Yi 2025-10-27 7:54 ` Christoph Hellwig 0 siblings, 2 replies; 3+ messages in thread From: Matthew Wilcox (Oracle) @ 2025-10-24 17:08 UTC (permalink / raw) To: linux-fsdevel, Christian Brauner Cc: Matthew Wilcox (Oracle), Theodore Ts'o, Andreas Dilger, linux-ext4 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> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Andreas Dilger <adilger.kernel@dilger.ca> Cc: linux-ext4@vger.kernel.org --- fs/ext4/inode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e99306a8f47c..1b22e9516db4 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1319,8 +1319,8 @@ static int ext4_write_begin(const struct kiocb *iocb, if (IS_ERR(folio)) return PTR_ERR(folio); - if (pos + len > folio_pos(folio) + folio_size(folio)) - len = folio_pos(folio) + folio_size(folio) - pos; + if (len > folio_next_pos(folio) - pos) + len = folio_next_pos(folio) - pos; from = offset_in_folio(folio, pos); to = from + len; @@ -2704,7 +2704,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) if (mpd->map.m_len == 0) mpd->start_pos = folio_pos(folio); - mpd->next_pos = folio_pos(folio) + folio_size(folio); + mpd->next_pos = folio_next_pos(folio); /* * Writeout when we cannot modify metadata is simple. * Just submit the page. For data=journal mode we @@ -3146,8 +3146,8 @@ static int ext4_da_write_begin(const struct kiocb *iocb, if (IS_ERR(folio)) return PTR_ERR(folio); - if (pos + len > folio_pos(folio) + folio_size(folio)) - len = folio_pos(folio) + folio_size(folio) - pos; + if (len > folio_next_pos(folio) - pos) + len = folio_next_pos(folio) - pos; ret = ext4_block_write_begin(NULL, folio, pos, len, ext4_da_get_block_prep); -- 2.47.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 04/10] ext4: Use folio_next_pos() 2025-10-24 17:08 ` [PATCH 04/10] ext4: Use folio_next_pos() Matthew Wilcox (Oracle) @ 2025-10-25 3:20 ` Zhang Yi 2025-10-27 7:54 ` Christoph Hellwig 1 sibling, 0 replies; 3+ messages in thread From: Zhang Yi @ 2025-10-25 3:20 UTC (permalink / raw) To: Matthew Wilcox (Oracle), linux-fsdevel, Christian Brauner Cc: Theodore Ts'o, Andreas Dilger, linux-ext4 On 10/25/2025 1:08 AM, Matthew Wilcox (Oracle) wrote: > 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> > Cc: Theodore Ts'o <tytso@mit.edu> > Cc: Andreas Dilger <adilger.kernel@dilger.ca> > Cc: linux-ext4@vger.kernel.org A nice cleanup! Reviewed-by: Zhang Yi <yi.zhang@huawei.com> > --- > fs/ext4/inode.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index e99306a8f47c..1b22e9516db4 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -1319,8 +1319,8 @@ static int ext4_write_begin(const struct kiocb *iocb, > if (IS_ERR(folio)) > return PTR_ERR(folio); > > - if (pos + len > folio_pos(folio) + folio_size(folio)) > - len = folio_pos(folio) + folio_size(folio) - pos; > + if (len > folio_next_pos(folio) - pos) > + len = folio_next_pos(folio) - pos; > > from = offset_in_folio(folio, pos); > to = from + len; > @@ -2704,7 +2704,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) > > if (mpd->map.m_len == 0) > mpd->start_pos = folio_pos(folio); > - mpd->next_pos = folio_pos(folio) + folio_size(folio); > + mpd->next_pos = folio_next_pos(folio); > /* > * Writeout when we cannot modify metadata is simple. > * Just submit the page. For data=journal mode we > @@ -3146,8 +3146,8 @@ static int ext4_da_write_begin(const struct kiocb *iocb, > if (IS_ERR(folio)) > return PTR_ERR(folio); > > - if (pos + len > folio_pos(folio) + folio_size(folio)) > - len = folio_pos(folio) + folio_size(folio) - pos; > + if (len > folio_next_pos(folio) - pos) > + len = folio_next_pos(folio) - pos; > > ret = ext4_block_write_begin(NULL, folio, pos, len, > ext4_da_get_block_prep); ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 04/10] ext4: Use folio_next_pos() 2025-10-24 17:08 ` [PATCH 04/10] ext4: Use folio_next_pos() Matthew Wilcox (Oracle) 2025-10-25 3:20 ` Zhang Yi @ 2025-10-27 7:54 ` Christoph Hellwig 1 sibling, 0 replies; 3+ messages in thread From: Christoph Hellwig @ 2025-10-27 7:54 UTC (permalink / raw) To: Matthew Wilcox (Oracle) Cc: linux-fsdevel, Christian Brauner, Theodore Ts'o, Andreas Dilger, linux-ext4 Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-27 7:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251024170822.1427218-1-willy@infradead.org>
2025-10-24 17:08 ` [PATCH 04/10] ext4: Use folio_next_pos() Matthew Wilcox (Oracle)
2025-10-25 3:20 ` Zhang Yi
2025-10-27 7:54 ` Christoph Hellwig
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).