* + mpage-clean-up-do_mpage_readpage.patch added to mm-new branch
@ 2025-08-18 2:46 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2025-08-18 2:46 UTC (permalink / raw)
To: mm-commits, Yuezhang.Mo, willy, viro, sj1557.seo, linkinjeon,
jack, brauner, chizhiling, akpm
The patch titled
Subject: mpage: clean up do_mpage_readpage()
has been added to the -mm mm-new branch. Its filename is
mpage-clean-up-do_mpage_readpage.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mpage-clean-up-do_mpage_readpage.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Chi Zhiling <chizhiling@kylinos.cn>
Subject: mpage: clean up do_mpage_readpage()
Date: Tue, 12 Aug 2025 15:22:24 +0800
Replace two loop iterations with direct calculations. The variable
nblocks now represents the number of avalid blocks we can obtain from
map_bh. no functional change.
Link: https://lkml.kernel.org/r/20250812072225.181798-2-chizhiling@163.com
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Sungjong Seo <sj1557.seo@samsung.com>
Cc: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/mpage.c | 42 +++++++++++++++++-------------------------
1 file changed, 17 insertions(+), 25 deletions(-)
--- a/fs/mpage.c~mpage-clean-up-do_mpage_readpage
+++ a/fs/mpage.c
@@ -158,7 +158,6 @@ static struct bio *do_mpage_readpage(str
struct buffer_head *map_bh = &args->map_bh;
sector_t block_in_file;
sector_t last_block;
- sector_t last_block_in_file;
sector_t first_block;
unsigned page_block;
unsigned first_hole = blocks_per_folio;
@@ -180,9 +179,8 @@ static struct bio *do_mpage_readpage(str
block_in_file = folio_pos(folio) >> blkbits;
last_block = block_in_file + ((args->nr_pages * PAGE_SIZE) >> blkbits);
- last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits;
- if (last_block > last_block_in_file)
- last_block = last_block_in_file;
+ last_block = min_t(sector_t, last_block,
+ (i_size_read(inode) + blocksize - 1) >> blkbits);
page_block = 0;
/*
@@ -193,19 +191,15 @@ static struct bio *do_mpage_readpage(str
block_in_file > args->first_logical_block &&
block_in_file < (args->first_logical_block + nblocks)) {
unsigned map_offset = block_in_file - args->first_logical_block;
- unsigned last = nblocks - map_offset;
first_block = map_bh->b_blocknr + map_offset;
- for (relative_block = 0; ; relative_block++) {
- if (relative_block == last) {
- clear_buffer_mapped(map_bh);
- break;
- }
- if (page_block == blocks_per_folio)
- break;
- page_block++;
- block_in_file++;
- }
+ nblocks -= map_offset;
+ if (nblocks > blocks_per_folio - page_block)
+ nblocks = blocks_per_folio - page_block;
+ else
+ clear_buffer_mapped(map_bh);
+ page_block += nblocks;
+ block_in_file += nblocks;
bdev = map_bh->b_bdev;
}
@@ -243,7 +237,7 @@ static struct bio *do_mpage_readpage(str
map_buffer_to_folio(folio, map_bh, page_block);
goto confused;
}
-
+
if (first_hole != blocks_per_folio)
goto confused; /* hole -> non-hole */
@@ -252,16 +246,14 @@ static struct bio *do_mpage_readpage(str
first_block = map_bh->b_blocknr;
else if (first_block + page_block != map_bh->b_blocknr)
goto confused;
+
nblocks = map_bh->b_size >> blkbits;
- for (relative_block = 0; ; relative_block++) {
- if (relative_block == nblocks) {
- clear_buffer_mapped(map_bh);
- break;
- } else if (page_block == blocks_per_folio)
- break;
- page_block++;
- block_in_file++;
- }
+ if (nblocks > blocks_per_folio - page_block)
+ nblocks = blocks_per_folio - page_block;
+ else
+ clear_buffer_mapped(map_bh);
+ page_block += nblocks;
+ block_in_file += nblocks;
bdev = map_bh->b_bdev;
}
_
Patches currently in -mm which might be from chizhiling@kylinos.cn are
mm-filemap-do-not-use-is_partially_uptodate-for-entire-folio.patch
mm-filemap-skip-non-uptodate-folio-if-there-are-available-folios.patch
mpage-terminate-read-ahead-on-read-error.patch
mpage-clean-up-do_mpage_readpage.patch
mpage-convert-do_mpage_readpage-to-return-int-type.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-18 2:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 2:46 + mpage-clean-up-do_mpage_readpage.patch added to mm-new branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.