Commit 9fffa4e9 authored by David Howells's avatar David Howells Committed by Christian Brauner

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: default avatarDavid Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/2238548.1727424522@warthog.procyon.org.uk
cc: Jeff Layton <jlayton@kernel.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent ff98751b
...@@ -307,6 +307,7 @@ static int netfs_write_folio(struct netfs_io_request *wreq, ...@@ -307,6 +307,7 @@ static int netfs_write_folio(struct netfs_io_request *wreq,
struct netfs_io_stream *stream; struct netfs_io_stream *stream;
struct netfs_group *fgroup; /* TODO: Use this with ceph */ struct netfs_group *fgroup; /* TODO: Use this with ceph */
struct netfs_folio *finfo; struct netfs_folio *finfo;
size_t iter_off = 0;
size_t fsize = folio_size(folio), flen = fsize, foff = 0; size_t fsize = folio_size(folio), flen = fsize, foff = 0;
loff_t fpos = folio_pos(folio), i_size; loff_t fpos = folio_pos(folio), i_size;
bool to_eof = false, streamw = false; bool to_eof = false, streamw = false;
...@@ -462,7 +463,12 @@ static int netfs_write_folio(struct netfs_io_request *wreq, ...@@ -462,7 +463,12 @@ static int netfs_write_folio(struct netfs_io_request *wreq,
if (choose_s < 0) if (choose_s < 0)
break; break;
stream = &wreq->io_streams[choose_s]; stream = &wreq->io_streams[choose_s];
wreq->io_iter.iov_offset = stream->submit_off;
/* Advance the iterator(s). */
if (stream->submit_off > iter_off) {
iov_iter_advance(&wreq->io_iter, stream->submit_off - iter_off);
iter_off = stream->submit_off;
}
atomic64_set(&wreq->issued_to, fpos + stream->submit_off); atomic64_set(&wreq->issued_to, fpos + stream->submit_off);
stream->submit_extendable_to = fsize - stream->submit_off; stream->submit_extendable_to = fsize - stream->submit_off;
...@@ -477,8 +483,8 @@ static int netfs_write_folio(struct netfs_io_request *wreq, ...@@ -477,8 +483,8 @@ static int netfs_write_folio(struct netfs_io_request *wreq,
debug = true; debug = true;
} }
wreq->io_iter.iov_offset = 0; if (fsize > iter_off)
iov_iter_advance(&wreq->io_iter, fsize); iov_iter_advance(&wreq->io_iter, fsize - iter_off);
atomic64_set(&wreq->issued_to, fpos + fsize); atomic64_set(&wreq->issued_to, fpos + fsize);
if (!debug) if (!debug)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment