diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2014-02-09 12:07:46 -0500 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-04-01 23:19:33 -0400 |
| commit | b2f42cfeeb0452ca3e004c3014cda99b53554d47 (patch) | |
| tree | 2d33d06d1214903f2008421abcfbc122e5b81489 | |
| parent | 920220c11122952061f2d81a9f06ca077bb744d9 (diff) | |
lustre: don't open-code kernel_recvmsg()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c | 30 | ||||
| -rw-r--r-- | drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c | 12 |
2 files changed, 9 insertions, 33 deletions
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c index c3b67165883b..733c79e1f12d 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c | |||
| @@ -215,15 +215,8 @@ ksocknal_lib_recv_iov (ksock_conn_t *conn) | |||
| 215 | #endif | 215 | #endif |
| 216 | struct iovec *iov = conn->ksnc_rx_iov; | 216 | struct iovec *iov = conn->ksnc_rx_iov; |
| 217 | struct msghdr msg = { | 217 | struct msghdr msg = { |
| 218 | .msg_name = NULL, | ||
| 219 | .msg_namelen = 0, | ||
| 220 | .msg_iov = scratchiov, | ||
| 221 | .msg_iovlen = niov, | ||
| 222 | .msg_control = NULL, | ||
| 223 | .msg_controllen = 0, | ||
| 224 | .msg_flags = 0 | 218 | .msg_flags = 0 |
| 225 | }; | 219 | }; |
| 226 | mm_segment_t oldmm = get_fs(); | ||
| 227 | int nob; | 220 | int nob; |
| 228 | int i; | 221 | int i; |
| 229 | int rc; | 222 | int rc; |
| @@ -241,10 +234,8 @@ ksocknal_lib_recv_iov (ksock_conn_t *conn) | |||
| 241 | } | 234 | } |
| 242 | LASSERT (nob <= conn->ksnc_rx_nob_wanted); | 235 | LASSERT (nob <= conn->ksnc_rx_nob_wanted); |
| 243 | 236 | ||
| 244 | set_fs (KERNEL_DS); | 237 | rc = kernel_recvmsg(conn->ksnc_sock, &msg, |
| 245 | rc = sock_recvmsg (conn->ksnc_sock, &msg, nob, MSG_DONTWAIT); | 238 | (struct kvec *)scratchiov, niov, nob, MSG_DONTWAIT); |
| 246 | /* NB this is just a boolean..........................^ */ | ||
| 247 | set_fs (oldmm); | ||
| 248 | 239 | ||
| 249 | saved_csum = 0; | 240 | saved_csum = 0; |
| 250 | if (conn->ksnc_proto == &ksocknal_protocol_v2x) { | 241 | if (conn->ksnc_proto == &ksocknal_protocol_v2x) { |
| @@ -333,14 +324,8 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn) | |||
| 333 | #endif | 324 | #endif |
| 334 | lnet_kiov_t *kiov = conn->ksnc_rx_kiov; | 325 | lnet_kiov_t *kiov = conn->ksnc_rx_kiov; |
| 335 | struct msghdr msg = { | 326 | struct msghdr msg = { |
| 336 | .msg_name = NULL, | ||
| 337 | .msg_namelen = 0, | ||
| 338 | .msg_iov = scratchiov, | ||
| 339 | .msg_control = NULL, | ||
| 340 | .msg_controllen = 0, | ||
| 341 | .msg_flags = 0 | 327 | .msg_flags = 0 |
| 342 | }; | 328 | }; |
| 343 | mm_segment_t oldmm = get_fs(); | ||
| 344 | int nob; | 329 | int nob; |
| 345 | int i; | 330 | int i; |
| 346 | int rc; | 331 | int rc; |
| @@ -348,12 +333,13 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn) | |||
| 348 | void *addr; | 333 | void *addr; |
| 349 | int sum; | 334 | int sum; |
| 350 | int fragnob; | 335 | int fragnob; |
| 336 | int n; | ||
| 351 | 337 | ||
| 352 | /* NB we can't trust socket ops to either consume our iovs | 338 | /* NB we can't trust socket ops to either consume our iovs |
| 353 | * or leave them alone. */ | 339 | * or leave them alone. */ |
| 354 | if ((addr = ksocknal_lib_kiov_vmap(kiov, niov, scratchiov, pages)) != NULL) { | 340 | if ((addr = ksocknal_lib_kiov_vmap(kiov, niov, scratchiov, pages)) != NULL) { |
| 355 | nob = scratchiov[0].iov_len; | 341 | nob = scratchiov[0].iov_len; |
| 356 | msg.msg_iovlen = 1; | 342 | n = 1; |
| 357 | 343 | ||
| 358 | } else { | 344 | } else { |
| 359 | for (nob = i = 0; i < niov; i++) { | 345 | for (nob = i = 0; i < niov; i++) { |
| @@ -361,15 +347,13 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn) | |||
| 361 | scratchiov[i].iov_base = kmap(kiov[i].kiov_page) + | 347 | scratchiov[i].iov_base = kmap(kiov[i].kiov_page) + |
| 362 | kiov[i].kiov_offset; | 348 | kiov[i].kiov_offset; |
| 363 | } | 349 | } |
| 364 | msg.msg_iovlen = niov; | 350 | n = niov; |
| 365 | } | 351 | } |
| 366 | 352 | ||
| 367 | LASSERT (nob <= conn->ksnc_rx_nob_wanted); | 353 | LASSERT (nob <= conn->ksnc_rx_nob_wanted); |
| 368 | 354 | ||
| 369 | set_fs (KERNEL_DS); | 355 | rc = kernel_recvmsg(conn->ksnc_sock, &msg, |
| 370 | rc = sock_recvmsg (conn->ksnc_sock, &msg, nob, MSG_DONTWAIT); | 356 | (struct kvec *)scratchiov, n, nob, MSG_DONTWAIT); |
| 371 | /* NB this is just a boolean.......................^ */ | ||
| 372 | set_fs (oldmm); | ||
| 373 | 357 | ||
| 374 | if (conn->ksnc_msg.ksm_csum != 0) { | 358 | if (conn->ksnc_msg.ksm_csum != 0) { |
| 375 | for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) { | 359 | for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) { |
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index 9bd08d666413..7539fe16d76f 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c | |||
| @@ -330,17 +330,11 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout) | |||
| 330 | LASSERT (ticks > 0); | 330 | LASSERT (ticks > 0); |
| 331 | 331 | ||
| 332 | for (;;) { | 332 | for (;;) { |
| 333 | struct iovec iov = { | 333 | struct kvec iov = { |
| 334 | .iov_base = buffer, | 334 | .iov_base = buffer, |
| 335 | .iov_len = nob | 335 | .iov_len = nob |
| 336 | }; | 336 | }; |
| 337 | struct msghdr msg = { | 337 | struct msghdr msg = { |
| 338 | .msg_name = NULL, | ||
| 339 | .msg_namelen = 0, | ||
| 340 | .msg_iov = &iov, | ||
| 341 | .msg_iovlen = 1, | ||
| 342 | .msg_control = NULL, | ||
| 343 | .msg_controllen = 0, | ||
| 344 | .msg_flags = 0 | 338 | .msg_flags = 0 |
| 345 | }; | 339 | }; |
| 346 | 340 | ||
| @@ -359,11 +353,9 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout) | |||
| 359 | return rc; | 353 | return rc; |
| 360 | } | 354 | } |
| 361 | 355 | ||
| 362 | set_fs(KERNEL_DS); | ||
| 363 | then = jiffies; | 356 | then = jiffies; |
| 364 | rc = sock_recvmsg(sock, &msg, iov.iov_len, 0); | 357 | rc = kernel_recvmsg(sock, &msg, &iov, 1, nob, 0); |
| 365 | ticks -= jiffies - then; | 358 | ticks -= jiffies - then; |
| 366 | set_fs(oldmm); | ||
| 367 | 359 | ||
| 368 | if (rc < 0) | 360 | if (rc < 0) |
| 369 | return rc; | 361 | return rc; |
