diff mbox series

[03/12] iomap: Simplify is_partially_uptodate a little

Message ID 20220330144930.315951-4-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Additional patches for 5.18 | expand

Commit Message

Matthew Wilcox March 30, 2022, 2:49 p.m. UTC
Remove the unnecessary variable 'len' and fix a comment to refer to
the folio instead of the page.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/iomap/buffered-io.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Christoph Hellwig March 30, 2022, 2:52 p.m. UTC | #1
On Wed, Mar 30, 2022 at 03:49:21PM +0100, Matthew Wilcox (Oracle) wrote:
> Remove the unnecessary variable 'len' and fix a comment to refer to
> the folio instead of the page.

I'd rather keep the len name instead of count, but either way this looks
ok:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Matthew Wilcox March 30, 2022, 4 p.m. UTC | #2
On Wed, Mar 30, 2022 at 07:52:11AM -0700, Christoph Hellwig wrote:
> On Wed, Mar 30, 2022 at 03:49:21PM +0100, Matthew Wilcox (Oracle) wrote:
> > Remove the unnecessary variable 'len' and fix a comment to refer to
> > the folio instead of the page.
> 
> I'd rather keep the len name instead of count, but either way this looks
> ok:

Heh, that was the way I did it first.  But block_is_partially_uptodate()
uses 'count', include/linux/fs.h calls it 'count' and one of the two
callers in mm/filemap.c calls it 'count', so I thought it was probably
best to not call it len.
Christoph Hellwig March 31, 2022, 12:33 p.m. UTC | #3
On Wed, Mar 30, 2022 at 05:00:21PM +0100, Matthew Wilcox wrote:
> On Wed, Mar 30, 2022 at 07:52:11AM -0700, Christoph Hellwig wrote:
> > On Wed, Mar 30, 2022 at 03:49:21PM +0100, Matthew Wilcox (Oracle) wrote:
> > > Remove the unnecessary variable 'len' and fix a comment to refer to
> > > the folio instead of the page.
> > 
> > I'd rather keep the len name instead of count, but either way this looks
> > ok:
> 
> Heh, that was the way I did it first.  But block_is_partially_uptodate()
> uses 'count', include/linux/fs.h calls it 'count' and one of the two
> callers in mm/filemap.c calls it 'count', so I thought it was probably
> best to not call it len.

As said I'm fine either way, but len seems more descriptiv here.
diff mbox series

Patch

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 49dccd9050f1..8ce8720093b9 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -435,18 +435,17 @@  bool iomap_is_partially_uptodate(struct folio *folio, size_t from, size_t count)
 {
 	struct iomap_page *iop = to_iomap_page(folio);
 	struct inode *inode = folio->mapping->host;
-	size_t len;
 	unsigned first, last, i;
 
 	if (!iop)
 		return false;
 
-	/* Limit range to this folio */
-	len = min(folio_size(folio) - from, count);
+	/* Caller's range may extend past the end of this folio */
+	count = min(folio_size(folio) - from, count);
 
-	/* First and last blocks in range within page */
+	/* First and last blocks in range within folio */
 	first = from >> inode->i_blkbits;
-	last = (from + len - 1) >> inode->i_blkbits;
+	last = (from + count - 1) >> inode->i_blkbits;
 
 	for (i = first; i <= last; i++)
 		if (!test_bit(i, iop->uptodate))