Skip to content

Commit 6e47852

Browse files
author
Matthew Wilcox (Oracle)
committed
iomap,xfs: Convert ->discard_page to ->discard_folio
XFS has the only implementation of ->discard_page today, so convert it to use folios in the same patch as converting the API. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]>
1 parent 9c4ce08 commit 6e47852

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

fs/iomap/buffered-io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,8 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
13601360
* won't be affected by I/O completion and we must unlock it
13611361
* now.
13621362
*/
1363-
if (wpc->ops->discard_page)
1364-
wpc->ops->discard_page(page, file_offset);
1363+
if (wpc->ops->discard_folio)
1364+
wpc->ops->discard_folio(folio, file_offset);
13651365
if (!count) {
13661366
ClearPageUptodate(page);
13671367
unlock_page(page);

fs/xfs/xfs_aops.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -437,37 +437,37 @@ xfs_prepare_ioend(
437437
* see a ENOSPC in writeback).
438438
*/
439439
static void
440-
xfs_discard_page(
441-
struct page *page,
442-
loff_t fileoff)
440+
xfs_discard_folio(
441+
struct folio *folio,
442+
loff_t pos)
443443
{
444-
struct inode *inode = page->mapping->host;
444+
struct inode *inode = folio->mapping->host;
445445
struct xfs_inode *ip = XFS_I(inode);
446446
struct xfs_mount *mp = ip->i_mount;
447-
unsigned int pageoff = offset_in_page(fileoff);
448-
xfs_fileoff_t start_fsb = XFS_B_TO_FSBT(mp, fileoff);
449-
xfs_fileoff_t pageoff_fsb = XFS_B_TO_FSBT(mp, pageoff);
447+
size_t offset = offset_in_folio(folio, pos);
448+
xfs_fileoff_t start_fsb = XFS_B_TO_FSBT(mp, pos);
449+
xfs_fileoff_t pageoff_fsb = XFS_B_TO_FSBT(mp, offset);
450450
int error;
451451

452452
if (xfs_is_shutdown(mp))
453453
goto out_invalidate;
454454

455455
xfs_alert_ratelimited(mp,
456-
"page discard on page "PTR_FMT", inode 0x%llx, offset %llu.",
457-
page, ip->i_ino, fileoff);
456+
"page discard on page "PTR_FMT", inode 0x%llx, pos %llu.",
457+
folio, ip->i_ino, pos);
458458

459459
error = xfs_bmap_punch_delalloc_range(ip, start_fsb,
460-
i_blocks_per_page(inode, page) - pageoff_fsb);
460+
i_blocks_per_folio(inode, folio) - pageoff_fsb);
461461
if (error && !xfs_is_shutdown(mp))
462462
xfs_alert(mp, "page discard unable to remove delalloc mapping.");
463463
out_invalidate:
464-
iomap_invalidatepage(page, pageoff, PAGE_SIZE - pageoff);
464+
iomap_invalidate_folio(folio, offset, folio_size(folio) - offset);
465465
}
466466

467467
static const struct iomap_writeback_ops xfs_writeback_ops = {
468468
.map_blocks = xfs_map_blocks,
469469
.prepare_ioend = xfs_prepare_ioend,
470-
.discard_page = xfs_discard_page,
470+
.discard_folio = xfs_discard_folio,
471471
};
472472

473473
STATIC int

include/linux/iomap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ struct iomap_writeback_ops {
285285
* Optional, allows the file system to discard state on a page where
286286
* we failed to submit any I/O.
287287
*/
288-
void (*discard_page)(struct page *page, loff_t fileoff);
288+
void (*discard_folio)(struct folio *folio, loff_t pos);
289289
};
290290

291291
struct iomap_writepage_ctx {

0 commit comments

Comments
 (0)