History

netfs: Provide an iterator-reset function

Provide a function to reset the iterator on a subrequest.

David Howells committed 2 years ago

Commit bfaa33b1 parent cd0277e4 files · +23 −8Browse files

Unified · Split

4 files
  1. fs/netfs/internal.h +1 −3
  2. fs/netfs/misc.c +18 −0
  3. fs/netfs/write_collect.c +1 −2
  4. fs/netfs/write_issue.c +3 −3
fs/netfs/internal.h+1−3
@@ -69,6 +69,7 @@ int netfs_buffer_append_folio(struct netfs_io_request *rreq, struct folio *folio · 68 unmodified lines
69 bool needs_put);69 bool needs_put);
70struct folio_queue *netfs_delete_buffer_head(struct netfs_io_request *wreq);70struct folio_queue *netfs_delete_buffer_head(struct netfs_io_request *wreq);
71void netfs_clear_buffer(struct netfs_io_request *rreq);71void netfs_clear_buffer(struct netfs_io_request *rreq);
72void netfs_reset_iter(struct netfs_io_subrequest *subreq);
72 73
73/*74/*
74 * objects.c75 * objects.c
@@ -161,9 +162,6 @@ struct netfs_io_request *netfs_create_write_req(struct address_space *mapping, · 86 unmodified lines
161void netfs_reissue_write(struct netfs_io_stream *stream,162void netfs_reissue_write(struct netfs_io_stream *stream,
162 struct netfs_io_subrequest *subreq,163 struct netfs_io_subrequest *subreq,
163 struct iov_iter *source);164 struct iov_iter *source);
164int netfs_advance_write(struct netfs_io_request *wreq,
165 struct netfs_io_stream *stream,
166 loff_t start, size_t len, bool to_eof);
167struct netfs_io_request *netfs_begin_writethrough(struct kiocb *iocb, size_t len);165struct netfs_io_request *netfs_begin_writethrough(struct kiocb *iocb, size_t len);
168int netfs_advance_writethrough(struct netfs_io_request *wreq, struct writeback_control *wbc,166int netfs_advance_writethrough(struct netfs_io_request *wreq, struct writeback_control *wbc,
169 struct folio *folio, size_t copied, bool to_page_end,167 struct folio *folio, size_t copied, bool to_page_end,
fs/netfs/misc.c+18−0
@@ -84,6 +84,24 @@ void netfs_clear_buffer(struct netfs_io_request *rreq) · 83 unmodified lines
84 }84 }
85}85}
86 86
87/*
88 * Reset the subrequest iterator to refer just to the region remaining to be
89 * read. The iterator may or may not have been advanced by socket ops or
90 * extraction ops to an extent that may or may not match the amount actually
91 * read.
92 */
93void netfs_reset_iter(struct netfs_io_subrequest *subreq)
94{
95 struct iov_iter *io_iter = &subreq->io_iter;
96 size_t remain = subreq->len - subreq->transferred;
97
98 if (io_iter->count > remain)
99 iov_iter_advance(io_iter, io_iter->count - remain);
100 else if (io_iter->count < remain)
101 iov_iter_revert(io_iter, remain - io_iter->count);
102 iov_iter_truncate(&subreq->io_iter, remain);
103}
104
87/**105/**
88 * netfs_dirty_folio - Mark folio dirty and pin a cache object for writeback106 * netfs_dirty_folio - Mark folio dirty and pin a cache object for writeback
89 * @mapping: The mapping the folio belongs to.107 * @mapping: The mapping the folio belongs to.
fs/netfs/write_collect.c+1−2
@@ -226,9 +226,8 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq, · 225 unmodified lines
226 /* Determine the set of buffers we're going to use. Each226 /* Determine the set of buffers we're going to use. Each
227 * subreq gets a subset of a single overall contiguous buffer.227 * subreq gets a subset of a single overall contiguous buffer.
228 */228 */
229 netfs_reset_iter(from);
229 source = from->io_iter;230 source = from->io_iter;
230 iov_iter_revert(&source, subreq->len - source.count);
231 iov_iter_advance(&source, from->transferred);
232 source.count = len;231 source.count = len;
233 232
234 /* Work through the sublist. */233 /* Work through the sublist. */
fs/netfs/write_issue.c+3−3
@@ -261,9 +261,9 @@ static void netfs_issue_write(struct netfs_io_request *wreq, · 260 unmodified lines
261 * we can avoid overrunning the credits obtained (cifs) and try to parallelise261 * we can avoid overrunning the credits obtained (cifs) and try to parallelise
262 * content-crypto preparation with network writes.262 * content-crypto preparation with network writes.
263 */263 */
264int netfs_advance_write(struct netfs_io_request *wreq,264static int netfs_advance_write(struct netfs_io_request *wreq,
265 struct netfs_io_stream *stream,265 struct netfs_io_stream *stream,
266 loff_t start, size_t len, bool to_eof)266 loff_t start, size_t len, bool to_eof)
267{267{
268 struct netfs_io_subrequest *subreq = stream->construct;268 struct netfs_io_subrequest *subreq = stream->construct;
269 size_t part;269 size_t part;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t