diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-09 19:54:50 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-03-28 14:05:52 -0400 |
commit | 71335664c38f03de10d7cf1d82705fe55a130b33 (patch) | |
tree | 3a098dc6f5355f77fa4f55e987ae1d8aaeb9ed29 /fs/cifs/connect.c | |
parent | a6137305a8c47fa92ab1a8efcfe76f0e9fa96ab7 (diff) |
cifs: don't bother with kmap on read_pages side
just do ITER_BVEC recvmsg
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index eb426658566d..e33c5e0ecfd0 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -501,39 +501,34 @@ server_unresponsive(struct TCP_Server_Info *server) | |||
501 | return false; | 501 | return false; |
502 | } | 502 | } |
503 | 503 | ||
504 | int | 504 | static int |
505 | cifs_readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig, | 505 | cifs_readv_from_socket(struct TCP_Server_Info *server, struct msghdr *smb_msg) |
506 | unsigned int nr_segs, unsigned int to_read) | ||
507 | { | 506 | { |
508 | int length = 0; | 507 | int length = 0; |
509 | int total_read; | 508 | int total_read; |
510 | struct msghdr smb_msg; | ||
511 | 509 | ||
512 | smb_msg.msg_control = NULL; | 510 | smb_msg->msg_control = NULL; |
513 | smb_msg.msg_controllen = 0; | 511 | smb_msg->msg_controllen = 0; |
514 | iov_iter_kvec(&smb_msg.msg_iter, READ | ITER_KVEC, | ||
515 | iov_orig, nr_segs, to_read); | ||
516 | 512 | ||
517 | for (total_read = 0; msg_data_left(&smb_msg); total_read += length) { | 513 | for (total_read = 0; msg_data_left(smb_msg); total_read += length) { |
518 | try_to_freeze(); | 514 | try_to_freeze(); |
519 | 515 | ||
520 | if (server_unresponsive(server)) { | 516 | if (server_unresponsive(server)) |
521 | total_read = -ECONNABORTED; | 517 | return -ECONNABORTED; |
522 | break; | ||
523 | } | ||
524 | 518 | ||
525 | length = sock_recvmsg(server->ssocket, &smb_msg, 0); | 519 | length = sock_recvmsg(server->ssocket, smb_msg, 0); |
526 | 520 | ||
527 | if (server->tcpStatus == CifsExiting) { | 521 | if (server->tcpStatus == CifsExiting) |
528 | total_read = -ESHUTDOWN; | 522 | return -ESHUTDOWN; |
529 | break; | 523 | |
530 | } else if (server->tcpStatus == CifsNeedReconnect) { | 524 | if (server->tcpStatus == CifsNeedReconnect) { |
531 | cifs_reconnect(server); | 525 | cifs_reconnect(server); |
532 | total_read = -ECONNABORTED; | 526 | return -ECONNABORTED; |
533 | break; | 527 | } |
534 | } else if (length == -ERESTARTSYS || | 528 | |
535 | length == -EAGAIN || | 529 | if (length == -ERESTARTSYS || |
536 | length == -EINTR) { | 530 | length == -EAGAIN || |
531 | length == -EINTR) { | ||
537 | /* | 532 | /* |
538 | * Minimum sleep to prevent looping, allowing socket | 533 | * Minimum sleep to prevent looping, allowing socket |
539 | * to clear and app threads to set tcpStatus | 534 | * to clear and app threads to set tcpStatus |
@@ -542,11 +537,12 @@ cifs_readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig, | |||
542 | usleep_range(1000, 2000); | 537 | usleep_range(1000, 2000); |
543 | length = 0; | 538 | length = 0; |
544 | continue; | 539 | continue; |
545 | } else if (length <= 0) { | 540 | } |
541 | |||
542 | if (length <= 0) { | ||
546 | cifs_dbg(FYI, "Received no data or error: %d\n", length); | 543 | cifs_dbg(FYI, "Received no data or error: %d\n", length); |
547 | cifs_reconnect(server); | 544 | cifs_reconnect(server); |
548 | total_read = -ECONNABORTED; | 545 | return -ECONNABORTED; |
549 | break; | ||
550 | } | 546 | } |
551 | } | 547 | } |
552 | return total_read; | 548 | return total_read; |
@@ -556,12 +552,21 @@ int | |||
556 | cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, | 552 | cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, |
557 | unsigned int to_read) | 553 | unsigned int to_read) |
558 | { | 554 | { |
559 | struct kvec iov; | 555 | struct msghdr smb_msg; |
556 | struct kvec iov = {.iov_base = buf, .iov_len = to_read}; | ||
557 | iov_iter_kvec(&smb_msg.msg_iter, READ | ITER_KVEC, &iov, 1, to_read); | ||
560 | 558 | ||
561 | iov.iov_base = buf; | 559 | return cifs_readv_from_socket(server, &smb_msg); |
562 | iov.iov_len = to_read; | 560 | } |
563 | 561 | ||
564 | return cifs_readv_from_socket(server, &iov, 1, to_read); | 562 | int |
563 | cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page, | ||
564 | unsigned int to_read) | ||
565 | { | ||
566 | struct msghdr smb_msg; | ||
567 | struct bio_vec bv = {.bv_page = page, .bv_len = to_read}; | ||
568 | iov_iter_bvec(&smb_msg.msg_iter, READ | ITER_BVEC, &bv, 1, to_read); | ||
569 | return cifs_readv_from_socket(server, &smb_msg); | ||
565 | } | 570 | } |
566 | 571 | ||
567 | static bool | 572 | static bool |