A preparation patch splitting the frag array handling loop into two,
where first we skip frags below the requested offset. It makes further
changes more readable.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 816a169b848e..162e67287916 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -1877,23 +1877,29 @@ static int __zcrx_recv_skb(read_descriptor_t *desc, struct sk_buff *skb,
const skb_frag_t *frag = &shi->frags[i];
unsigned frag_end = start + skb_frag_size(frag);
+ if (offset < frag_end)
+ break;
+ start = frag_end;
+ }
+
+ for (; i < shi->nr_frags; i++) {
+ const skb_frag_t *frag = &shi->frags[i];
+ unsigned frag_end = start + skb_frag_size(frag);
+ unsigned copy = min(frag_end - offset, len);
+ unsigned frag_off = offset - start;
+
if (WARN_ON(start > offset + len))
return -EFAULT;
+ start = frag_end;
- if (offset < frag_end) {
- unsigned copy = min(frag_end - offset, len);
- unsigned frag_off = offset - start;
-
- ret = io_zcrx_recv_frag(req, ifq, frag, frag_off, copy);
- if (ret < 0)
- goto out;
+ ret = io_zcrx_recv_frag(req, ifq, frag, frag_off, copy);
+ if (ret < 0)
+ goto out;
- offset += ret;
- len -= ret;
- if (len == 0 || ret != copy)
- goto out;
- }
- start = frag_end;
+ offset += ret;
+ len -= ret;
+ if (len == 0 || ret != copy)
+ goto out;
}
skb_walk_frags(skb, frag_iter) {--
2.54.0