btrfs: fix iomap_begin length for nocow writes
authorChristoph Hellwig <hch@lst.de>
Thu, 8 Jun 2023 09:10:25 +0000 (11:10 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 12 Jun 2023 22:01:00 +0000 (00:01 +0200)
commit7833b865953c8e62abc76a3261c04132b2fb69de
tree0f6161f5cafb24f8533b990731fa82dda3da481c
parent79b8ee702c918f1936e17cc53e14bec388ce1045
btrfs: fix iomap_begin length for nocow writes

can_nocow_extent can reduce the len passed in, which needs to be
propagated to btrfs_dio_iomap_begin so that iomap does not submit
more data then is mapped.

This problems exists since the btrfs_get_blocks_direct helper was added
in commit c5794e51784a ("btrfs: Factor out write portion of
btrfs_get_blocks_direct"), but the ordered_extent splitting added in
commit b73a6fd1b1ef ("btrfs: split partial dio bios before submit")
added a WARN_ON that made a syzkaller test fail.

Reported-by: syzbot+ee90502d5c8fd1d0dd93@syzkaller.appspotmail.com
Fixes: c5794e51784a ("btrfs: Factor out write portion of btrfs_get_blocks_direct")
CC: stable@vger.kernel.org # 6.1+
Tested-by: syzbot+ee90502d5c8fd1d0dd93@syzkaller.appspotmail.com
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c