]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iomap: skip unnecessary ifs_block_is_uptodate check
authorGou Hao <gouhao@uniontech.com>
Thu, 10 Apr 2025 07:12:36 +0000 (15:12 +0800)
committerChristian Brauner <brauner@kernel.org>
Fri, 11 Apr 2025 14:02:27 +0000 (16:02 +0200)
In iomap_adjust_read_range, i is either the first !uptodate block, or it
is past last for the second loop looking for trailing uptodate blocks.
Assuming there's no overflow (there's no combination of huge folios and
tiny blksize) then yeah, there is no point in retesting that the same
block pointed to by i is uptodate since we hold the folio lock so nobody
else could have set it uptodate.

Signed-off-by: Gou Hao <gouhao@uniontech.com>
Link: https://lore.kernel.org/20250410071236.16017-1-gouhao@uniontech.com
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/iomap/buffered-io.c

index 31553372b33ace994bacd183e5c46a8b744434db..5b08bd417b2872886b529b94dd7b53d113b541c1 100644 (file)
@@ -259,7 +259,7 @@ static void iomap_adjust_read_range(struct inode *inode, struct folio *folio,
                }
 
                /* truncate len if we find any trailing uptodate block(s) */
-               for ( ; i <= last; i++) {
+               while (++i <= last) {
                        if (ifs_block_is_uptodate(ifs, i)) {
                                plen -= (last - i + 1) * block_size;
                                last = i - 1;