Skip to content

Commit 9fffa4e

Browse files
dhowellsbrauner
authored andcommitted
netfs: Advance iterator correctly rather than jumping it
In netfs_write_folio(), use iov_iter_advance() to advance the folio as we split bits of it off to subrequests rather than manually jumping the ->iov_offset value around. This becomes more problematic when we use a bounce buffer made out of single-page folios to cover a multipage pagecache folio. Signed-off-by: David Howells <[email protected]> Link: https://lore.kernel.org/r/[email protected] cc: Jeff Layton <[email protected]> cc: [email protected] cc: [email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent ff98751 commit 9fffa4e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

fs/netfs/write_issue.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ static int netfs_write_folio(struct netfs_io_request *wreq,
307307
struct netfs_io_stream *stream;
308308
struct netfs_group *fgroup; /* TODO: Use this with ceph */
309309
struct netfs_folio *finfo;
310+
size_t iter_off = 0;
310311
size_t fsize = folio_size(folio), flen = fsize, foff = 0;
311312
loff_t fpos = folio_pos(folio), i_size;
312313
bool to_eof = false, streamw = false;
@@ -462,7 +463,12 @@ static int netfs_write_folio(struct netfs_io_request *wreq,
462463
if (choose_s < 0)
463464
break;
464465
stream = &wreq->io_streams[choose_s];
465-
wreq->io_iter.iov_offset = stream->submit_off;
466+
467+
/* Advance the iterator(s). */
468+
if (stream->submit_off > iter_off) {
469+
iov_iter_advance(&wreq->io_iter, stream->submit_off - iter_off);
470+
iter_off = stream->submit_off;
471+
}
466472

467473
atomic64_set(&wreq->issued_to, fpos + stream->submit_off);
468474
stream->submit_extendable_to = fsize - stream->submit_off;
@@ -477,8 +483,8 @@ static int netfs_write_folio(struct netfs_io_request *wreq,
477483
debug = true;
478484
}
479485

480-
wreq->io_iter.iov_offset = 0;
481-
iov_iter_advance(&wreq->io_iter, fsize);
486+
if (fsize > iter_off)
487+
iov_iter_advance(&wreq->io_iter, fsize - iter_off);
482488
atomic64_set(&wreq->issued_to, fpos + fsize);
483489

484490
if (!debug)

0 commit comments

Comments
 (0)