Commit cf0604a6 authored by David Howells's avatar David Howells Committed by Steve French

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: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 5ff2836e
...@@ -232,6 +232,8 @@ extern unsigned int setup_special_user_owner_ACE(struct cifs_ace *pace); ...@@ -232,6 +232,8 @@ extern unsigned int setup_special_user_owner_ACE(struct cifs_ace *pace);
extern void dequeue_mid(struct mid_q_entry *mid, bool malformed); extern void dequeue_mid(struct mid_q_entry *mid, bool malformed);
extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
unsigned int to_read); unsigned int to_read);
extern ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server,
size_t to_read);
extern int cifs_read_page_from_socket(struct TCP_Server_Info *server, extern int cifs_read_page_from_socket(struct TCP_Server_Info *server,
struct page *page, struct page *page,
unsigned int page_offset, unsigned int page_offset,
......
...@@ -1451,9 +1451,9 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server) ...@@ -1451,9 +1451,9 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server)
while (remaining > 0) { while (remaining > 0) {
int length; int length;
length = cifs_read_from_socket(server, server->bigbuf, length = cifs_discard_from_socket(server,
min_t(unsigned int, remaining, min_t(size_t, remaining,
CIFSMaxBufSize + MAX_HEADER_SIZE(server))); CIFSMaxBufSize + MAX_HEADER_SIZE(server)));
if (length < 0) if (length < 0)
return length; return length;
server->total_read += length; server->total_read += length;
......
...@@ -564,6 +564,23 @@ cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, ...@@ -564,6 +564,23 @@ cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
return cifs_readv_from_socket(server, &smb_msg); 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 int
cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page, cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page,
unsigned int page_offset, unsigned int to_read) unsigned int page_offset, unsigned int to_read)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment