diff options
author | David Howells <dhowells@redhat.com> | 2021-02-04 09:15:21 +0300 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2021-02-26 04:08:06 +0300 |
commit | cf0604a686b11175d8beae60281c4ccc95aaa5c2 (patch) | |
tree | 62ad782990865ba28f748e9e780925e1cc7a7693 /fs/cifs/connect.c | |
parent | 5ff2836ed3a5c24420a7235be25a462594cdc4ea (diff) | |
download | linux-cf0604a686b11175d8beae60281c4ccc95aaa5c2.tar.xz |
cifs: use discard iterator to discard unneeded network data more efficiently
The iterator, ITER_DISCARD, that can only be used in READ mode and
just discards any data copied to it, was added to allow a network
filesystem to discard any unwanted data sent by a server.
Convert cifs_discard_from_socket() to use this.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index b2447cea45ae..112692300fb6 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -564,6 +564,23 @@ cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, return cifs_readv_from_socket(server, &smb_msg); } +ssize_t +cifs_discard_from_socket(struct TCP_Server_Info *server, size_t to_read) +{ + struct msghdr smb_msg; + + /* + * iov_iter_discard already sets smb_msg.type and count and iov_offset + * and cifs_readv_from_socket sets msg_control and msg_controllen + * so little to initialize in struct msghdr + */ + smb_msg.msg_name = NULL; + smb_msg.msg_namelen = 0; + iov_iter_discard(&smb_msg.msg_iter, READ, to_read); + + return cifs_readv_from_socket(server, &smb_msg); +} + int cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page, unsigned int page_offset, unsigned int to_read) |