aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-11-12 04:51:19 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-12-26 21:21:23 -0500
commitc1696cab700588f8493df7b51e096abf5bfb1d40 (patch)
tree1ae3b1243c009c158a586f16ac3f19b566b6e4a4
parent79ab80beb792fc56141ca9bc5675b2109b729955 (diff)
[nbd] switch sock_xmit() to sock_{send,recv}msg()
Step 1 - don't reinintialize ->msg_iter on each iteration. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/block/nbd.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 38c576f76d36..8e63caecdd00 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -215,7 +215,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send, void *buf,
215 struct socket *sock = nbd->socks[index]->sock; 215 struct socket *sock = nbd->socks[index]->sock;
216 int result; 216 int result;
217 struct msghdr msg; 217 struct msghdr msg;
218 struct kvec iov; 218 struct kvec iov = {.iov_base = buf, .iov_len = size};
219 unsigned long pflags = current->flags; 219 unsigned long pflags = current->flags;
220 220
221 if (unlikely(!sock)) { 221 if (unlikely(!sock)) {
@@ -225,11 +225,12 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send, void *buf,
225 return -EINVAL; 225 return -EINVAL;
226 } 226 }
227 227
228 iov_iter_kvec(&msg.msg_iter, (send ? WRITE : READ) | ITER_KVEC,
229 &iov, 1, size);
230
228 current->flags |= PF_MEMALLOC; 231 current->flags |= PF_MEMALLOC;
229 do { 232 do {
230 sock->sk->sk_allocation = GFP_NOIO | __GFP_MEMALLOC; 233 sock->sk->sk_allocation = GFP_NOIO | __GFP_MEMALLOC;
231 iov.iov_base = buf;
232 iov.iov_len = size;
233 msg.msg_name = NULL; 234 msg.msg_name = NULL;
234 msg.msg_namelen = 0; 235 msg.msg_namelen = 0;
235 msg.msg_control = NULL; 236 msg.msg_control = NULL;
@@ -237,19 +238,16 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send, void *buf,
237 msg.msg_flags = msg_flags | MSG_NOSIGNAL; 238 msg.msg_flags = msg_flags | MSG_NOSIGNAL;
238 239
239 if (send) 240 if (send)
240 result = kernel_sendmsg(sock, &msg, &iov, 1, size); 241 result = sock_sendmsg(sock, &msg);
241 else 242 else
242 result = kernel_recvmsg(sock, &msg, &iov, 1, size, 243 result = sock_recvmsg(sock, &msg, msg.msg_flags);
243 msg.msg_flags);
244 244
245 if (result <= 0) { 245 if (result <= 0) {
246 if (result == 0) 246 if (result == 0)
247 result = -EPIPE; /* short read */ 247 result = -EPIPE; /* short read */
248 break; 248 break;
249 } 249 }
250 size -= result; 250 } while (msg_data_left(&msg));
251 buf += result;
252 } while (size > 0);
253 251
254 tsk_restore_flags(current, pflags, PF_MEMALLOC); 252 tsk_restore_flags(current, pflags, PF_MEMALLOC);
255 253