Skip to content

Commit 12e803c

Browse files
zhangyi089tytso
authored andcommitted
ext4: fix an off-by-one issue during moving extents
During the movement of a written extent, mext_page_mkuptodate() is called to read data in the range [from, to) into the page cache and to update the corresponding buffers. Therefore, we should not wait on any buffer whose start offset is >= 'to'. Otherwise, it will return -EIO and fail the extents movement. $ for i in `seq 3 -1 0`; \ do xfs_io -fs -c "pwrite -b 1024 $((i * 1024)) 1024" /mnt/foo; \ done $ umount /mnt && mount /dev/pmem1s /mnt # drop cache $ e4defrag /mnt/foo e4defrag 1.47.0 (5-Feb-2023) ext4 defragmentation for /mnt/foo [1/1]/mnt/foo: 0% [ NG ] Success: [0/1] Cc: [email protected] Fixes: a40759f ("ext4: remove array of buffer_heads from mext_page_mkuptodate()") Signed-off-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Message-ID: <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 9d80eaa commit 12e803c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/ext4/move_extent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static int mext_page_mkuptodate(struct folio *folio, size_t from, size_t to)
225225
do {
226226
if (bh_offset(bh) + blocksize <= from)
227227
continue;
228-
if (bh_offset(bh) > to)
228+
if (bh_offset(bh) >= to)
229229
break;
230230
wait_on_buffer(bh);
231231
if (buffer_uptodate(bh))

0 commit comments

Comments
 (0)