* [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently @ 2021-02-04 6:25 Steve French 2021-02-04 10:29 ` Aurélien Aptel 0 siblings, 1 reply; 6+ messages in thread From: Steve French @ 2021-02-04 6:25 UTC (permalink / raw) To: CIFS; +Cc: linux-fsdevel, David Howells [-- Attachment #1: Type: text/plain, Size: 2425 bytes --] (cleanup patch, to make netfs merge easier) 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> --- fs/cifs/cifsproto.h | 2 ++ fs/cifs/cifssmb.c | 6 +++--- fs/cifs/connect.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 32f7a013402e..75ce6f742b8d 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -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 int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, 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, struct page *page, unsigned int page_offset, diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 0496934feecb..c279527aae92 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1451,9 +1451,9 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server) while (remaining > 0) { int length; - length = cifs_read_from_socket(server, server->bigbuf, - min_t(unsigned int, remaining, - CIFSMaxBufSize + MAX_HEADER_SIZE(server))); + length = cifs_discard_from_socket(server, + min_t(size_t, remaining, + CIFSMaxBufSize + MAX_HEADER_SIZE(server))); if (length < 0) return length; server->total_read += length; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 10fe6d6d2dee..943f4eba027d 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -564,6 +564,16 @@ 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(&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) -- Thanks, Steve [-- Attachment #2: 0001-cifs-use-discard-iterator-to-discard-unneeded-networ.patch --] [-- Type: text/x-patch, Size: 2653 bytes --] From c3a4621f56db8038b19844fa9d5f3951afaac4fd Mon Sep 17 00:00:00 2001 From: David Howells <dhowells@redhat.com> Date: Thu, 4 Feb 2021 00:15:21 -0600 Subject: [PATCH] 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> --- fs/cifs/cifsproto.h | 2 ++ fs/cifs/cifssmb.c | 6 +++--- fs/cifs/connect.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 32f7a013402e..75ce6f742b8d 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -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 int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, 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, struct page *page, unsigned int page_offset, diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 0496934feecb..c279527aae92 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1451,9 +1451,9 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server) while (remaining > 0) { int length; - length = cifs_read_from_socket(server, server->bigbuf, - min_t(unsigned int, remaining, - CIFSMaxBufSize + MAX_HEADER_SIZE(server))); + length = cifs_discard_from_socket(server, + min_t(size_t, remaining, + CIFSMaxBufSize + MAX_HEADER_SIZE(server))); if (length < 0) return length; server->total_read += length; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 10fe6d6d2dee..943f4eba027d 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -564,6 +564,16 @@ 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(&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) -- 2.27.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently 2021-02-04 6:25 [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently Steve French @ 2021-02-04 10:29 ` Aurélien Aptel 2021-02-07 9:57 ` David Howells 2021-02-25 19:29 ` Steve French 0 siblings, 2 replies; 6+ messages in thread From: Aurélien Aptel @ 2021-02-04 10:29 UTC (permalink / raw) To: Steve French, CIFS; +Cc: linux-fsdevel, David Howells Steve French <smfrench@gmail.com> writes: > +ssize_t > +cifs_discard_from_socket(struct TCP_Server_Info *server, size_t to_read) > +{ > + struct msghdr smb_msg; > + > + iov_iter_discard(&smb_msg.msg_iter, READ, to_read); > + > + return cifs_readv_from_socket(server, &smb_msg); > +} > + Shouldn't smb_msg be initialized to zeroes? Looking around this needs to be done for cifs_read_from_socket() and cifs_read_page_from_socket() too. Cheers, -- Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently 2021-02-04 10:29 ` Aurélien Aptel @ 2021-02-07 9:57 ` David Howells 2021-02-25 19:29 ` Steve French 1 sibling, 0 replies; 6+ messages in thread From: David Howells @ 2021-02-07 9:57 UTC (permalink / raw) To: =?utf-8?Q?Aur=C3=A9lien?= Aptel Cc: dhowells, Steve French, CIFS, linux-fsdevel Aurélien Aptel <aaptel@suse.com> wrote: > > +{ > > + struct msghdr smb_msg; > > + > > + iov_iter_discard(&smb_msg.msg_iter, READ, to_read); > > + > > + return cifs_readv_from_socket(server, &smb_msg); > > +} > > + > > Shouldn't smb_msg be initialized to zeroes? Looking around this needs to > be done for cifs_read_from_socket() and cifs_read_page_from_socket() too. Yeah - I think you're right. I didn't manage to finish making the changes, so what I gave to Steve wasn't tested. David ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently 2021-02-04 10:29 ` Aurélien Aptel 2021-02-07 9:57 ` David Howells @ 2021-02-25 19:29 ` Steve French 2021-02-25 19:43 ` Steve French 1 sibling, 1 reply; 6+ messages in thread From: Steve French @ 2021-02-25 19:29 UTC (permalink / raw) To: Aurélien Aptel; +Cc: CIFS, linux-fsdevel, David Howells The other two routines initialize in iov_iter_bvec iov->type iov->bvec iov->offset iov->count but iov_iter_discard already does the initialization: iov_type iov_offset iov_count and then we call cifs_readv_from_socket in all 3 which sets: iov->msg_control = NULL iov->msg_controllen = NULL I will set the two additional ones to null iov->msg_name and iov->msg_namelen On Thu, Feb 4, 2021 at 4:29 AM Aurélien Aptel <aaptel@suse.com> wrote: > > Steve French <smfrench@gmail.com> writes: > > +ssize_t > > +cifs_discard_from_socket(struct TCP_Server_Info *server, size_t to_read) > > +{ > > + struct msghdr smb_msg; > > + > > + iov_iter_discard(&smb_msg.msg_iter, READ, to_read); > > + > > + return cifs_readv_from_socket(server, &smb_msg); > > +} > > + > > Shouldn't smb_msg be initialized to zeroes? Looking around this needs to > be done for cifs_read_from_socket() and cifs_read_page_from_socket() too. > > Cheers, > -- > Aurélien Aptel / SUSE Labs Samba Team > GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 > SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE > GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München) > -- Thanks, Steve ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently 2021-02-25 19:29 ` Steve French @ 2021-02-25 19:43 ` Steve French 2021-02-25 21:01 ` Steve French 0 siblings, 1 reply; 6+ messages in thread From: Steve French @ 2021-02-25 19:43 UTC (permalink / raw) To: Aurélien Aptel; +Cc: CIFS, linux-fsdevel, David Howells [-- Attachment #1: Type: text/plain, Size: 1513 bytes --] lightly updated patch On Thu, Feb 25, 2021 at 1:29 PM Steve French <smfrench@gmail.com> wrote: > > The other two routines initialize in iov_iter_bvec > > iov->type > iov->bvec > iov->offset > iov->count > > but iov_iter_discard already does the initialization: > iov_type > iov_offset > iov_count > > and then we call cifs_readv_from_socket in all 3 > which sets: > iov->msg_control = NULL > iov->msg_controllen = NULL > > I will set the two additional ones to null > iov->msg_name > and > iov->msg_namelen > > > > On Thu, Feb 4, 2021 at 4:29 AM Aurélien Aptel <aaptel@suse.com> wrote: > > > > Steve French <smfrench@gmail.com> writes: > > > +ssize_t > > > +cifs_discard_from_socket(struct TCP_Server_Info *server, size_t to_read) > > > +{ > > > + struct msghdr smb_msg; > > > + > > > + iov_iter_discard(&smb_msg.msg_iter, READ, to_read); > > > + > > > + return cifs_readv_from_socket(server, &smb_msg); > > > +} > > > + > > > > Shouldn't smb_msg be initialized to zeroes? Looking around this needs to > > be done for cifs_read_from_socket() and cifs_read_page_from_socket() too. > > > > Cheers, > > -- > > Aurélien Aptel / SUSE Labs Samba Team > > GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 > > SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE > > GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München) > > > > > -- > Thanks, > > Steve -- Thanks, Steve [-- Attachment #2: 0001-cifs-use-discard-iterator-to-discard-unneeded-networ.patch --] [-- Type: text/x-patch, Size: 2911 bytes --] From 1b0bdb5e6c9c8846ab4a548093a32311ae9d0037 Mon Sep 17 00:00:00 2001 From: David Howells <dhowells@redhat.com> Date: Thu, 4 Feb 2021 00:15:21 -0600 Subject: [PATCH] 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> --- fs/cifs/cifsproto.h | 2 ++ fs/cifs/cifssmb.c | 6 +++--- fs/cifs/connect.c | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index d4b2cc7e6b1e..64eb5c817712 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -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 int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, 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, struct page *page, unsigned int page_offset, diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 0496934feecb..c279527aae92 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1451,9 +1451,9 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server) while (remaining > 0) { int length; - length = cifs_read_from_socket(server, server->bigbuf, - min_t(unsigned int, remaining, - CIFSMaxBufSize + MAX_HEADER_SIZE(server))); + length = cifs_discard_from_socket(server, + min_t(size_t, remaining, + CIFSMaxBufSize + MAX_HEADER_SIZE(server))); if (length < 0) return length; server->total_read += length; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 55b1ec731d52..b9085625334e 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_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) -- 2.27.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently 2021-02-25 19:43 ` Steve French @ 2021-02-25 21:01 ` Steve French 0 siblings, 0 replies; 6+ messages in thread From: Steve French @ 2021-02-25 21:01 UTC (permalink / raw) To: Aurélien Aptel; +Cc: CIFS, linux-fsdevel, David Howells [-- Attachment #1: Type: text/plain, Size: 4492 bytes --] Had a typo in the previous attachment - reattached 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> --- fs/cifs/cifsproto.h | 2 ++ fs/cifs/cifssmb.c | 6 +++--- fs/cifs/connect.c | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index d4b2cc7e6b1e..64eb5c817712 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -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 int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, 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, struct page *page, unsigned int page_offset, diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 0496934feecb..c279527aae92 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1451,9 +1451,9 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server) while (remaining > 0) { int length; - length = cifs_read_from_socket(server, server->bigbuf, - min_t(unsigned int, remaining, - CIFSMaxBufSize + MAX_HEADER_SIZE(server))); + length = cifs_discard_from_socket(server, + min_t(size_t, remaining, + CIFSMaxBufSize + MAX_HEADER_SIZE(server))); if (length < 0) return length; server->total_read += length; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 55b1ec731d52..b9085625334e 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) On Thu, Feb 25, 2021 at 1:43 PM Steve French <smfrench@gmail.com> wrote: > > lightly updated patch > > > On Thu, Feb 25, 2021 at 1:29 PM Steve French <smfrench@gmail.com> wrote: > > > > The other two routines initialize in iov_iter_bvec > > > > iov->type > > iov->bvec > > iov->offset > > iov->count > > > > but iov_iter_discard already does the initialization: > > iov_type > > iov_offset > > iov_count > > > > and then we call cifs_readv_from_socket in all 3 > > which sets: > > iov->msg_control = NULL > > iov->msg_controllen = NULL > > > > I will set the two additional ones to null > > iov->msg_name > > and > > iov->msg_namelen > > > > > > > > On Thu, Feb 4, 2021 at 4:29 AM Aurélien Aptel <aaptel@suse.com> wrote: > > > > > > Steve French <smfrench@gmail.com> writes: > > > > +ssize_t > > > > +cifs_discard_from_socket(struct TCP_Server_Info *server, size_t to_read) > > > > +{ > > > > + struct msghdr smb_msg; > > > > + > > > > + iov_iter_discard(&smb_msg.msg_iter, READ, to_read); > > > > + > > > > + return cifs_readv_from_socket(server, &smb_msg); > > > > +} > > > > + > > > > > > Shouldn't smb_msg be initialized to zeroes? Looking around this needs to > > > be done for cifs_read_from_socket() and cifs_read_page_from_socket() too. > > > > > > Cheers, > > > -- > > > Aurélien Aptel / SUSE Labs Samba Team > > > GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 > > > SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE > > > GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München) > > > > > > > > > -- > > Thanks, > > > > Steve > > > > -- > Thanks, > > Steve -- Thanks, Steve [-- Attachment #2: 0001-cifs-use-discard-iterator-to-discard-unneeded-networ.patch --] [-- Type: text/x-patch, Size: 2919 bytes --] From 1b0bdb5e6c9c8846ab4a548093a32311ae9d0037 Mon Sep 17 00:00:00 2001 From: David Howells <dhowells@redhat.com> Date: Thu, 4 Feb 2021 00:15:21 -0600 Subject: [PATCH 1/2] 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> --- fs/cifs/cifsproto.h | 2 ++ fs/cifs/cifssmb.c | 6 +++--- fs/cifs/connect.c | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index d4b2cc7e6b1e..64eb5c817712 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -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 int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, 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, struct page *page, unsigned int page_offset, diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 0496934feecb..c279527aae92 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1451,9 +1451,9 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server) while (remaining > 0) { int length; - length = cifs_read_from_socket(server, server->bigbuf, - min_t(unsigned int, remaining, - CIFSMaxBufSize + MAX_HEADER_SIZE(server))); + length = cifs_discard_from_socket(server, + min_t(size_t, remaining, + CIFSMaxBufSize + MAX_HEADER_SIZE(server))); if (length < 0) return length; server->total_read += length; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 55b1ec731d52..b9085625334e 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) -- 2.27.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-02-25 21:05 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-02-04 6:25 [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently Steve French 2021-02-04 10:29 ` Aurélien Aptel 2021-02-07 9:57 ` David Howells 2021-02-25 19:29 ` Steve French 2021-02-25 19:43 ` Steve French 2021-02-25 21:01 ` Steve French
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox