From: Mengmeng Zhao <[email protected]> A buffered write copies through the CPU linear address, which a device mapping cannot provide. fault_in_iov_iter_readable() treats a dmabuf iterator as always readable, so the copy fails with a WARN_ON_ONCE from iterate_and_advance2() and iomap_write_iter() retries the unchanged remainder forever.
Refuse the iterator at the entry with -EOPNOTSUPP, as generic_perform_write() and the generic read paths already do, so that every generic buffered copy helper turns the iterator away before touching the page cache. Signed-off-by: Mengmeng Zhao <[email protected]> Signed-off-by: Li Wang <[email protected]> --- fs/iomap/buffered-io.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 0a5ebfda90f1..3f56bd225e8c 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1304,6 +1304,13 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i, }; ssize_t ret; + /* + * A buffered write copies through the CPU linear address, which a + * device mapping cannot provide. + */ + if (iov_iter_is_dmabuf_map(i)) + return -EOPNOTSUPP; + if (iocb->ki_flags & IOCB_NOWAIT) iter.flags |= IOMAP_NOWAIT; if (iocb->ki_flags & IOCB_DONTCACHE) -- 2.43.0
