aboutsummaryrefslogtreecommitdiffstats
path: root/net/rds/message.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-11-20 09:21:14 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2014-11-24 05:16:43 -0500
commitc310e72c89926e06138e4881f21e4c8da3e7ef18 (patch)
treecf40fae1e3639f0ff3607561c1e4fd484b7b53e9 /net/rds/message.c
parent7424ce65065852bdf7a040bf2490da4a8fc4b464 (diff)
rds: switch ->inc_copy_to_user() to passing iov_iter
instances get considerably simpler from that... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/rds/message.c')
-rw-r--r--net/rds/message.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/net/rds/message.c b/net/rds/message.c
index aba232f9f308..7a546e089a57 100644
--- a/net/rds/message.c
+++ b/net/rds/message.c
@@ -325,14 +325,11 @@ out:
325 return ret; 325 return ret;
326} 326}
327 327
328int rds_message_inc_copy_to_user(struct rds_incoming *inc, 328int rds_message_inc_copy_to_user(struct rds_incoming *inc, struct iov_iter *to)
329 struct iovec *first_iov, size_t size)
330{ 329{
331 struct rds_message *rm; 330 struct rds_message *rm;
332 struct iovec *iov;
333 struct scatterlist *sg; 331 struct scatterlist *sg;
334 unsigned long to_copy; 332 unsigned long to_copy;
335 unsigned long iov_off;
336 unsigned long vec_off; 333 unsigned long vec_off;
337 int copied; 334 int copied;
338 int ret; 335 int ret;
@@ -341,36 +338,20 @@ int rds_message_inc_copy_to_user(struct rds_incoming *inc,
341 rm = container_of(inc, struct rds_message, m_inc); 338 rm = container_of(inc, struct rds_message, m_inc);
342 len = be32_to_cpu(rm->m_inc.i_hdr.h_len); 339 len = be32_to_cpu(rm->m_inc.i_hdr.h_len);
343 340
344 iov = first_iov;
345 iov_off = 0;
346 sg = rm->data.op_sg; 341 sg = rm->data.op_sg;
347 vec_off = 0; 342 vec_off = 0;
348 copied = 0; 343 copied = 0;
349 344
350 while (copied < size && copied < len) { 345 while (iov_iter_count(to) && copied < len) {
351 while (iov_off == iov->iov_len) { 346 to_copy = min(iov_iter_count(to), sg->length - vec_off);
352 iov_off = 0;
353 iov++;
354 }
355
356 to_copy = min(iov->iov_len - iov_off, sg->length - vec_off);
357 to_copy = min_t(size_t, to_copy, size - copied);
358 to_copy = min_t(unsigned long, to_copy, len - copied); 347 to_copy = min_t(unsigned long, to_copy, len - copied);
359 348
360 rdsdebug("copying %lu bytes to user iov [%p, %zu] + %lu to " 349 rds_stats_add(s_copy_to_user, to_copy);
361 "sg [%p, %u, %u] + %lu\n", 350 ret = copy_page_to_iter(sg_page(sg), sg->offset + vec_off,
362 to_copy, iov->iov_base, iov->iov_len, iov_off, 351 to_copy, to);
363 sg_page(sg), sg->offset, sg->length, vec_off); 352 if (ret != to_copy)
364 353 return -EFAULT;
365 ret = rds_page_copy_to_user(sg_page(sg), sg->offset + vec_off,
366 iov->iov_base + iov_off,
367 to_copy);
368 if (ret) {
369 copied = ret;
370 break;
371 }
372 354
373 iov_off += to_copy;
374 vec_off += to_copy; 355 vec_off += to_copy;
375 copied += to_copy; 356 copied += to_copy;
376 357