@@ -1263,29 +1263,29 @@ iomap_can_add_to_ioend(struct iomap_writepage_ctx *wpc, loff_t offset,
1263
1263
* first; otherwise finish off the current ioend and start another.
1264
1264
*/
1265
1265
static 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 ,
1267
1267
struct iomap_page * iop , struct iomap_writepage_ctx * wpc ,
1268
1268
struct writeback_control * wbc , struct list_head * iolist )
1269
1269
{
1270
- sector_t sector = iomap_sector (& wpc -> iomap , offset );
1270
+ sector_t sector = iomap_sector (& wpc -> iomap , pos );
1271
1271
unsigned len = i_blocksize (inode );
1272
- unsigned poff = offset & ( PAGE_SIZE - 1 );
1272
+ size_t poff = offset_in_folio ( folio , pos );
1273
1273
1274
- if (!wpc -> ioend || !iomap_can_add_to_ioend (wpc , offset , sector )) {
1274
+ if (!wpc -> ioend || !iomap_can_add_to_ioend (wpc , pos , sector )) {
1275
1275
if (wpc -> ioend )
1276
1276
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 );
1278
1278
}
1279
1279
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 )) {
1281
1281
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 );
1283
1283
}
1284
1284
1285
1285
if (iop )
1286
1286
atomic_add (len , & iop -> write_bytes_pending );
1287
1287
wpc -> ioend -> io_size += len ;
1288
- wbc_account_cgroup_owner (wbc , page , len );
1288
+ wbc_account_cgroup_owner (wbc , & folio -> page , len );
1289
1289
}
1290
1290
1291
1291
/*
@@ -1307,9 +1307,8 @@ iomap_add_to_ioend(struct inode *inode, loff_t offset, struct page *page,
1307
1307
static int
1308
1308
iomap_writepage_map (struct iomap_writepage_ctx * wpc ,
1309
1309
struct writeback_control * wbc , struct inode * inode ,
1310
- struct page * page , u64 end_pos )
1310
+ struct folio * folio , u64 end_pos )
1311
1311
{
1312
- struct folio * folio = page_folio (page );
1313
1312
struct iomap_page * iop = iomap_page_create (inode , folio );
1314
1313
struct iomap_ioend * ioend , * next ;
1315
1314
unsigned len = i_blocksize (inode );
@@ -1336,15 +1335,15 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
1336
1335
continue ;
1337
1336
if (wpc -> iomap .type == IOMAP_HOLE )
1338
1337
continue ;
1339
- iomap_add_to_ioend (inode , pos , page , iop , wpc , wbc ,
1338
+ iomap_add_to_ioend (inode , pos , folio , iop , wpc , wbc ,
1340
1339
& submit_list );
1341
1340
count ++ ;
1342
1341
}
1343
1342
1344
1343
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 ));
1348
1347
1349
1348
/*
1350
1349
* We cannot cancel the ioend directly here on error. We may have
@@ -1362,14 +1361,14 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
1362
1361
if (wpc -> ops -> discard_folio )
1363
1362
wpc -> ops -> discard_folio (folio , pos );
1364
1363
if (!count ) {
1365
- ClearPageUptodate ( page );
1366
- unlock_page ( page );
1364
+ folio_clear_uptodate ( folio );
1365
+ folio_unlock ( folio );
1367
1366
goto done ;
1368
1367
}
1369
1368
}
1370
1369
1371
- set_page_writeback ( page );
1372
- unlock_page ( page );
1370
+ folio_start_writeback ( folio );
1371
+ folio_unlock ( folio );
1373
1372
1374
1373
/*
1375
1374
* Preserve the original error if there was one; catch
@@ -1390,9 +1389,9 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
1390
1389
* with a partial page truncate on a sub-page block sized filesystem.
1391
1390
*/
1392
1391
if (!count )
1393
- end_page_writeback ( page );
1392
+ folio_end_writeback ( folio );
1394
1393
done :
1395
- mapping_set_error (page -> mapping , error );
1394
+ mapping_set_error (folio -> mapping , error );
1396
1395
return error ;
1397
1396
}
1398
1397
@@ -1406,14 +1405,15 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
1406
1405
static int
1407
1406
iomap_do_writepage (struct page * page , struct writeback_control * wbc , void * data )
1408
1407
{
1408
+ struct folio * folio = page_folio (page );
1409
1409
struct iomap_writepage_ctx * wpc = data ;
1410
- struct inode * inode = page -> mapping -> host ;
1410
+ struct inode * inode = folio -> mapping -> host ;
1411
1411
u64 end_pos , isize ;
1412
1412
1413
- trace_iomap_writepage (inode , page_offset ( page ), PAGE_SIZE );
1413
+ trace_iomap_writepage (inode , folio_pos ( folio ), folio_size ( folio ) );
1414
1414
1415
1415
/*
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.
1417
1417
*
1418
1418
* This avoids stack overflows when called from deeply used stacks in
1419
1419
* 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)
1427
1427
goto redirty ;
1428
1428
1429
1429
/*
1430
- * Is this page beyond the end of the file?
1430
+ * Is this folio beyond the end of the file?
1431
1431
*
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.
1434
1434
* -----------------------------------------------------
1435
1435
* | file mapping | <EOF> |
1436
1436
* -----------------------------------------------------
@@ -1440,7 +1440,7 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
1440
1440
* ---------------------------------^------------------|
1441
1441
*/
1442
1442
isize = i_size_read (inode );
1443
- end_pos = page_offset ( page ) + PAGE_SIZE ;
1443
+ end_pos = folio_pos ( folio ) + folio_size ( folio ) ;
1444
1444
if (end_pos > isize ) {
1445
1445
/*
1446
1446
* 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)
1453
1453
* | | Straddles |
1454
1454
* ---------------------------------^-----------|--------|
1455
1455
*/
1456
- size_t poff = offset_in_page ( isize );
1456
+ size_t poff = offset_in_folio ( folio , isize );
1457
1457
pgoff_t end_index = isize >> PAGE_SHIFT ;
1458
1458
1459
1459
/*
@@ -1473,8 +1473,8 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
1473
1473
* checking if the page is totally beyond i_size or if its
1474
1474
* offset is just equal to the EOF.
1475
1475
*/
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 ))
1478
1478
goto redirty ;
1479
1479
1480
1480
/*
@@ -1485,17 +1485,15 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
1485
1485
* memory is zeroed when mapped, and writes to that region are
1486
1486
* not written out to the file."
1487
1487
*/
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 ));
1491
1489
end_pos = isize ;
1492
1490
}
1493
1491
1494
- return iomap_writepage_map (wpc , wbc , inode , page , end_pos );
1492
+ return iomap_writepage_map (wpc , wbc , inode , folio , end_pos );
1495
1493
1496
1494
redirty :
1497
- redirty_page_for_writepage (wbc , page );
1498
- unlock_page ( page );
1495
+ folio_redirty_for_writepage (wbc , folio );
1496
+ folio_unlock ( folio );
1499
1497
return 0 ;
1500
1498
}
1501
1499
0 commit comments