Skip to content

Commit 8642174

Browse files
committed
Merge tag 'iomap-5.19-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull iomap updates from Darrick Wong: "There's a couple of corrections sent in by Andreas for some accounting errors. The biggest change this time around is that writeback errors longer clear pageuptodate nor does XFS invalidate the page cache anymore. This brings XFS (and gfs2/zonefs) behavior in line with every other Linux filesystem driver, and fixes some UAF bugs that only cropped up after willy turned on multipage folios for XFS in 5.18-rc1. Regrettably, it took all the way to the end of the 5.18 cycle to find the source of these bugs and reach a consensus that XFS' writeback failure behavior from 20 years ago is no longer necessary. Summary: - Fix a couple of accounting errors in the buffered io code. - Discontinue the practice of marking folios !uptodate and invalidating them when writeback fails. This fixes some UAF bugs when multipage folios are enabled, and brings the behavior of XFS/gfs/zonefs into alignment with the behavior of all the other Linux filesystems" * tag 'iomap-5.19-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: iomap: don't invalidate folios after writeback errors iomap: iomap_write_end cleanup iomap: iomap_write_failed fix
2 parents f289811 + e9c3a8e commit 8642174

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

fs/iomap/buffered-io.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,8 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
531531
* write started inside the existing inode size.
532532
*/
533533
if (pos + len > i_size)
534-
truncate_pagecache_range(inode, max(pos, i_size), pos + len);
534+
truncate_pagecache_range(inode, max(pos, i_size),
535+
pos + len - 1);
535536
}
536537

537538
static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,
@@ -733,7 +734,7 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len,
733734
folio_put(folio);
734735

735736
if (ret < len)
736-
iomap_write_failed(iter->inode, pos, len);
737+
iomap_write_failed(iter->inode, pos + ret, len - ret);
737738
return ret;
738739
}
739740

@@ -1386,7 +1387,6 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
13861387
if (wpc->ops->discard_folio)
13871388
wpc->ops->discard_folio(folio, pos);
13881389
if (!count) {
1389-
folio_clear_uptodate(folio);
13901390
folio_unlock(folio);
13911391
goto done;
13921392
}

fs/xfs/xfs_aops.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ xfs_discard_folio(
464464
int error;
465465

466466
if (xfs_is_shutdown(mp))
467-
goto out_invalidate;
467+
return;
468468

469469
xfs_alert_ratelimited(mp,
470470
"page discard on page "PTR_FMT", inode 0x%llx, pos %llu.",
@@ -474,8 +474,6 @@ xfs_discard_folio(
474474
i_blocks_per_folio(inode, folio) - pageoff_fsb);
475475
if (error && !xfs_is_shutdown(mp))
476476
xfs_alert(mp, "page discard unable to remove delalloc mapping.");
477-
out_invalidate:
478-
iomap_invalidate_folio(folio, offset, folio_size(folio) - offset);
479477
}
480478

481479
static const struct iomap_writeback_ops xfs_writeback_ops = {

0 commit comments

Comments
 (0)