33 #include <linux/kernel.h>
34 #include <linux/slab.h>
35 #include <linux/export.h>
57 static void rds_message_purge(
struct rds_message *rm)
64 for (i = 0; i < rm->
data.op_nents; i++) {
65 rdsdebug(
"putting data page %p\n", (
void *)sg_page(&rm->
data.op_sg[i]));
69 rm->
data.op_nents = 0;
71 if (rm->
rdma.op_active)
73 if (rm->
rdma.op_rdma_mr)
74 rds_mr_put(rm->
rdma.op_rdma_mr);
79 rds_mr_put(rm->
atomic.op_rdma_mr);
92 rds_message_purge(rm);
111 const void *
data,
unsigned int len)
161 ext_type = src[offset++];
165 ext_len = rds_exthdr_size[ext_type];
170 if (ext_len < *buflen)
172 memcpy(buf, src + offset, *buflen);
200 rm = kzalloc(
sizeof(
struct rds_message) + extra_len, gfp);
243 int extra_bytes = num_sgs *
sizeof(
struct scatterlist);
253 if (!rm->data.op_sg) {
258 for (i = 0; i < rm->data.op_nents; ++
i) {
259 sg_set_page(&rm->data.op_sg[i],
270 unsigned long to_copy;
271 unsigned long iov_off;
272 unsigned long sg_off;
297 while (iov_off == iov->
iov_len) {
303 to_copy =
min_t(
size_t, to_copy, total_len);
305 rdsdebug(
"copying %lu bytes from user iov [%p, %zu] + %lu to "
306 "sg [%p, %u, %u] + %lu\n",
317 total_len -= to_copy;
334 unsigned long to_copy;
335 unsigned long iov_off;
336 unsigned long vec_off;
350 while (copied < size && copied < len) {
351 while (iov_off == iov->
iov_len) {
357 to_copy =
min_t(
size_t, to_copy, size - copied);
358 to_copy =
min_t(
unsigned long, to_copy, len - copied);
360 rdsdebug(
"copying %lu bytes to user iov [%p, %zu] + %lu to "
361 "sg [%p, %u, %u] + %lu\n",
377 if (vec_off == sg->
length) {