Skip to content

Commit 25d48d5

Browse files
committed
Merge tag 'iomap-6.6-fixes-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull iomap fixes from Darrick Wong: - Handle a race between writing and shrinking block devices by returning EIO - Fix a typo in a comment * tag 'iomap-6.6-fixes-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: iomap: Spelling s/preceeding/preceding/g iomap: add a workaround for racy i_size updates on block devices
2 parents cefc06e + 684f7e6 commit 25d48d5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

fs/buffer.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,8 +2058,17 @@ iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh,
20582058
fallthrough;
20592059
case IOMAP_MAPPED:
20602060
if ((iomap->flags & IOMAP_F_NEW) ||
2061-
offset >= i_size_read(inode))
2061+
offset >= i_size_read(inode)) {
2062+
/*
2063+
* This can happen if truncating the block device races
2064+
* with the check in the caller as i_size updates on
2065+
* block devices aren't synchronized by i_rwsem for
2066+
* block devices.
2067+
*/
2068+
if (S_ISBLK(inode->i_mode))
2069+
return -EIO;
20622070
set_buffer_new(bh);
2071+
}
20632072
bh->b_blocknr = (iomap->addr + offset - iomap->offset) >>
20642073
inode->i_blkbits;
20652074
set_buffer_mapped(bh);

fs/iomap/buffered-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ static int iomap_write_delalloc_punch(struct inode *inode, struct folio *folio,
10491049

10501050
/*
10511051
* Scan the data range passed to us for dirty page cache folios. If we find a
1052-
* dirty folio, punch out the preceeding range and update the offset from which
1052+
* dirty folio, punch out the preceding range and update the offset from which
10531053
* the next punch will start from.
10541054
*
10551055
* We can punch out storage reservations under clean pages because they either

0 commit comments

Comments
 (0)