iomap: Simplify iomap_writepage_map()

Rename end_offset to end_pos and file_offset to pos to match the rest
of the file.  Simplify the loop by calculating nblocks up front instead
of each time around the loop.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 6e478521
...@@ -1307,37 +1307,36 @@ iomap_add_to_ioend(struct inode *inode, loff_t offset, struct page *page, ...@@ -1307,37 +1307,36 @@ iomap_add_to_ioend(struct inode *inode, loff_t offset, struct page *page,
static int static int
iomap_writepage_map(struct iomap_writepage_ctx *wpc, iomap_writepage_map(struct iomap_writepage_ctx *wpc,
struct writeback_control *wbc, struct inode *inode, struct writeback_control *wbc, struct inode *inode,
struct page *page, u64 end_offset) struct page *page, u64 end_pos)
{ {
struct folio *folio = page_folio(page); struct folio *folio = page_folio(page);
struct iomap_page *iop = iomap_page_create(inode, folio); struct iomap_page *iop = iomap_page_create(inode, folio);
struct iomap_ioend *ioend, *next; struct iomap_ioend *ioend, *next;
unsigned len = i_blocksize(inode); unsigned len = i_blocksize(inode);
u64 file_offset; /* file offset of page */ unsigned nblocks = i_blocks_per_folio(inode, folio);
u64 pos = folio_pos(folio);
int error = 0, count = 0, i; int error = 0, count = 0, i;
LIST_HEAD(submit_list); LIST_HEAD(submit_list);
WARN_ON_ONCE(iop && atomic_read(&iop->write_bytes_pending) != 0); WARN_ON_ONCE(iop && atomic_read(&iop->write_bytes_pending) != 0);
/* /*
* Walk through the page to find areas to write back. If we run off the * Walk through the folio to find areas to write back. If we
* end of the current map or find the current map invalid, grab a new * run off the end of the current map or find the current map
* one. * invalid, grab a new one.
*/ */
for (i = 0, file_offset = page_offset(page); for (i = 0; i < nblocks && pos < end_pos; i++, pos += len) {
i < (PAGE_SIZE >> inode->i_blkbits) && file_offset < end_offset;
i++, file_offset += len) {
if (iop && !test_bit(i, iop->uptodate)) if (iop && !test_bit(i, iop->uptodate))
continue; continue;
error = wpc->ops->map_blocks(wpc, inode, file_offset); error = wpc->ops->map_blocks(wpc, inode, pos);
if (error) if (error)
break; break;
if (WARN_ON_ONCE(wpc->iomap.type == IOMAP_INLINE)) if (WARN_ON_ONCE(wpc->iomap.type == IOMAP_INLINE))
continue; continue;
if (wpc->iomap.type == IOMAP_HOLE) if (wpc->iomap.type == IOMAP_HOLE)
continue; continue;
iomap_add_to_ioend(inode, file_offset, page, iop, wpc, wbc, iomap_add_to_ioend(inode, pos, page, iop, wpc, wbc,
&submit_list); &submit_list);
count++; count++;
} }
...@@ -1361,7 +1360,7 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc, ...@@ -1361,7 +1360,7 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
* now. * now.
*/ */
if (wpc->ops->discard_folio) if (wpc->ops->discard_folio)
wpc->ops->discard_folio(folio, file_offset); wpc->ops->discard_folio(folio, pos);
if (!count) { if (!count) {
ClearPageUptodate(page); ClearPageUptodate(page);
unlock_page(page); unlock_page(page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment