diff options
| author | Qu Wenruo <wqu@suse.com> | 2026-06-16 17:42:36 +0930 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-06-16 14:48:35 -0600 |
| commit | d5b58fbb2fd7ac25fcd7e1c14730f998a90b0322 (patch) | |
| tree | f5a039aeff1113781001663a695c21aa91d19fed /block | |
| parent | b68d4979c88e31488970373f67ac79b4f6267008 (diff) | |
| download | lwn-d5b58fbb2fd7ac25fcd7e1c14730f998a90b0322.tar.gz lwn-d5b58fbb2fd7ac25fcd7e1c14730f998a90b0322.zip | |
block: respect iov_iter::nofault flag in bio_iov_iter_bounce_write()
For the incoming usage of IOMAP_DIO_BOUNCE in btrfs, btrfs has set
iov_iter::nofault to prevent deadlock when a page fault is needed to
read out the buffer.
However bio_iov_iter_bounce_write() doesn't respect iov_iter::nofault
flag, and just call a plain copy_from_iter() so it can still trigger
page fault and cause deadlock in btrfs.
Fix it by utilizing copy_folio_from_iter_atomic() if nofault flag is
set, otherwise use copy_folio_from_iter().
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/9c165a314022b61566eb247852eb773ca6c70889.1781597506.git.wqu@suse.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
| -rw-r--r-- | block/bio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/block/bio.c b/block/bio.c index 96f40d39b62b..f2a5f4d0a967 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1335,7 +1335,11 @@ static int bio_iov_iter_bounce_write(struct bio *bio, struct iov_iter *iter, break; bio_add_folio_nofail(bio, folio, this_len, 0); - copied = copy_from_iter(folio_address(folio), this_len, iter); + if (iter->nofault) + copied = copy_folio_from_iter_atomic(folio, 0, this_len, + iter); + else + copied = copy_folio_from_iter(folio, 0, this_len, iter); if (copied < this_len) { /* * Need to revert the iov iter for all bytes we have |
