@@ -1263,29 +1263,29 @@ iomap_can_add_to_ioend(struct iomap_writepage_ctx *wpc, loff_t offset,
12631263 * first; otherwise finish off the current ioend and start another.
12641264 */
12651265static void
1266- iomap_add_to_ioend (struct inode * inode , loff_t offset , struct page * page ,
1266+ iomap_add_to_ioend (struct inode * inode , loff_t pos , struct folio * folio ,
12671267 struct iomap_page * iop , struct iomap_writepage_ctx * wpc ,
12681268 struct writeback_control * wbc , struct list_head * iolist )
12691269{
1270- sector_t sector = iomap_sector (& wpc -> iomap , offset );
1270+ sector_t sector = iomap_sector (& wpc -> iomap , pos );
12711271 unsigned len = i_blocksize (inode );
1272- unsigned poff = offset & ( PAGE_SIZE - 1 );
1272+ size_t poff = offset_in_folio ( folio , pos );
12731273
1274- if (!wpc -> ioend || !iomap_can_add_to_ioend (wpc , offset , sector )) {
1274+ if (!wpc -> ioend || !iomap_can_add_to_ioend (wpc , pos , sector )) {
12751275 if (wpc -> ioend )
12761276 list_add (& wpc -> ioend -> io_list , iolist );
1277- wpc -> ioend = iomap_alloc_ioend (inode , wpc , offset , sector , wbc );
1277+ wpc -> ioend = iomap_alloc_ioend (inode , wpc , pos , sector , wbc );
12781278 }
12791279
1280- if (bio_add_page (wpc -> ioend -> io_bio , page , len , poff ) != len ) {
1280+ if (! bio_add_folio (wpc -> ioend -> io_bio , folio , len , poff )) {
12811281 wpc -> ioend -> io_bio = iomap_chain_bio (wpc -> ioend -> io_bio );
1282- __bio_add_page (wpc -> ioend -> io_bio , page , len , poff );
1282+ bio_add_folio (wpc -> ioend -> io_bio , folio , len , poff );
12831283 }
12841284
12851285 if (iop )
12861286 atomic_add (len , & iop -> write_bytes_pending );
12871287 wpc -> ioend -> io_size += len ;
1288- wbc_account_cgroup_owner (wbc , page , len );
1288+ wbc_account_cgroup_owner (wbc , & folio -> page , len );
12891289}
12901290
12911291/*
@@ -1307,9 +1307,8 @@ iomap_add_to_ioend(struct inode *inode, loff_t offset, struct page *page,
13071307static int
13081308iomap_writepage_map (struct iomap_writepage_ctx * wpc ,
13091309 struct writeback_control * wbc , struct inode * inode ,
1310- struct page * page , u64 end_pos )
1310+ struct folio * folio , u64 end_pos )
13111311{
1312- struct folio * folio = page_folio (page );
13131312 struct iomap_page * iop = iomap_page_create (inode , folio );
13141313 struct iomap_ioend * ioend , * next ;
13151314 unsigned len = i_blocksize (inode );
@@ -1336,15 +1335,15 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
13361335 continue ;
13371336 if (wpc -> iomap .type == IOMAP_HOLE )
13381337 continue ;
1339- iomap_add_to_ioend (inode , pos , page , iop , wpc , wbc ,
1338+ iomap_add_to_ioend (inode , pos , folio , iop , wpc , wbc ,
13401339 & submit_list );
13411340 count ++ ;
13421341 }
13431342
13441343 WARN_ON_ONCE (!wpc -> ioend && !list_empty (& submit_list ));
1345- WARN_ON_ONCE (!PageLocked ( page ));
1346- WARN_ON_ONCE (PageWriteback ( page ));
1347- WARN_ON_ONCE (PageDirty ( page ));
1344+ WARN_ON_ONCE (!folio_test_locked ( folio ));
1345+ WARN_ON_ONCE (folio_test_writeback ( folio ));
1346+ WARN_ON_ONCE (folio_test_dirty ( folio ));
13481347
13491348 /*
13501349 * We cannot cancel the ioend directly here on error. We may have
@@ -1362,14 +1361,14 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
13621361 if (wpc -> ops -> discard_folio )
13631362 wpc -> ops -> discard_folio (folio , pos );
13641363 if (!count ) {
1365- ClearPageUptodate ( page );
1366- unlock_page ( page );
1364+ folio_clear_uptodate ( folio );
1365+ folio_unlock ( folio );
13671366 goto done ;
13681367 }
13691368 }
13701369
1371- set_page_writeback ( page );
1372- unlock_page ( page );
1370+ folio_start_writeback ( folio );
1371+ folio_unlock ( folio );
13731372
13741373 /*
13751374 * Preserve the original error if there was one; catch
@@ -1390,9 +1389,9 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
13901389 * with a partial page truncate on a sub-page block sized filesystem.
13911390 */
13921391 if (!count )
1393- end_page_writeback ( page );
1392+ folio_end_writeback ( folio );
13941393done :
1395- mapping_set_error (page -> mapping , error );
1394+ mapping_set_error (folio -> mapping , error );
13961395 return error ;
13971396}
13981397
@@ -1406,14 +1405,15 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
14061405static int
14071406iomap_do_writepage (struct page * page , struct writeback_control * wbc , void * data )
14081407{
1408+ struct folio * folio = page_folio (page );
14091409 struct iomap_writepage_ctx * wpc = data ;
1410- struct inode * inode = page -> mapping -> host ;
1410+ struct inode * inode = folio -> mapping -> host ;
14111411 u64 end_pos , isize ;
14121412
1413- trace_iomap_writepage (inode , page_offset ( page ), PAGE_SIZE );
1413+ trace_iomap_writepage (inode , folio_pos ( folio ), folio_size ( folio ) );
14141414
14151415 /*
1416- * Refuse to write the page out if we're called from reclaim context.
1416+ * Refuse to write the folio out if we're called from reclaim context.
14171417 *
14181418 * This avoids stack overflows when called from deeply used stacks in
14191419 * random callers for direct reclaim or memcg reclaim. We explicitly
@@ -1427,10 +1427,10 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
14271427 goto redirty ;
14281428
14291429 /*
1430- * Is this page beyond the end of the file?
1430+ * Is this folio beyond the end of the file?
14311431 *
1432- * The page index is less than the end_index, adjust the end_offset
1433- * to the highest offset that this page should represent.
1432+ * The folio index is less than the end_index, adjust the end_pos
1433+ * to the highest offset that this folio should represent.
14341434 * -----------------------------------------------------
14351435 * | file mapping | <EOF> |
14361436 * -----------------------------------------------------
@@ -1440,7 +1440,7 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
14401440 * ---------------------------------^------------------|
14411441 */
14421442 isize = i_size_read (inode );
1443- end_pos = page_offset ( page ) + PAGE_SIZE ;
1443+ end_pos = folio_pos ( folio ) + folio_size ( folio ) ;
14441444 if (end_pos > isize ) {
14451445 /*
14461446 * Check whether the page to write out is beyond or straddles
@@ -1453,7 +1453,7 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
14531453 * | | Straddles |
14541454 * ---------------------------------^-----------|--------|
14551455 */
1456- size_t poff = offset_in_page ( isize );
1456+ size_t poff = offset_in_folio ( folio , isize );
14571457 pgoff_t end_index = isize >> PAGE_SHIFT ;
14581458
14591459 /*
@@ -1473,8 +1473,8 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
14731473 * checking if the page is totally beyond i_size or if its
14741474 * offset is just equal to the EOF.
14751475 */
1476- if (page -> index > end_index ||
1477- (page -> index == end_index && poff == 0 ))
1476+ if (folio -> index > end_index ||
1477+ (folio -> index == end_index && poff == 0 ))
14781478 goto redirty ;
14791479
14801480 /*
@@ -1485,17 +1485,15 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
14851485 * memory is zeroed when mapped, and writes to that region are
14861486 * not written out to the file."
14871487 */
1488- zero_user_segment (page , poff , PAGE_SIZE );
1489-
1490- /* Adjust the end_offset to the end of file */
1488+ folio_zero_segment (folio , poff , folio_size (folio ));
14911489 end_pos = isize ;
14921490 }
14931491
1494- return iomap_writepage_map (wpc , wbc , inode , page , end_pos );
1492+ return iomap_writepage_map (wpc , wbc , inode , folio , end_pos );
14951493
14961494redirty :
1497- redirty_page_for_writepage (wbc , page );
1498- unlock_page ( page );
1495+ folio_redirty_for_writepage (wbc , folio );
1496+ folio_unlock ( folio );
14991497 return 0 ;
15001498}
15011499
0 commit comments