diff mbox series

cifs: convert readpages_fill_pages to use iter

Message ID CAH2r5mt+69AZFh_2OOd2JHLtqG9jo7=O7HF4bTGbSjhgi=M53g@mail.gmail.com
State New
Headers show
Series cifs: convert readpages_fill_pages to use iter | expand

Commit Message

Steve French Feb. 4, 2021, 6:49 a.m. UTC
(Another patch to make conversion to new netfs interfaces easier)

Optimize read_page_from_socket by using an iov_iter

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/cifsglob.h  |  1 +
 fs/cifs/cifsproto.h |  3 +++
 fs/cifs/connect.c   | 16 ++++++++++++++++
 fs/cifs/file.c      |  3 +--
 4 files changed, 21 insertions(+), 2 deletions(-)

Comments

Steve French Feb. 25, 2021, 6:44 p.m. UTC | #1
Tentatively merged into cifs-2.6.git for-next, pending testing

On Thu, Feb 4, 2021 at 12:49 AM Steve French <smfrench@gmail.com> wrote:
>
> (Another patch to make conversion to new netfs interfaces easier)
>
> Optimize read_page_from_socket by using an iov_iter
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> Signed-off-by: Steve French <stfrench@microsoft.com>
> ---
>  fs/cifs/cifsglob.h  |  1 +
>  fs/cifs/cifsproto.h |  3 +++
>  fs/cifs/connect.c   | 16 ++++++++++++++++
>  fs/cifs/file.c      |  3 +--
>  4 files changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index 50fcb65920e8..73f80cc38316 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -1301,6 +1301,7 @@ struct cifs_readdata {
>   int (*copy_into_pages)(struct TCP_Server_Info *server,
>   struct cifs_readdata *rdata,
>   struct iov_iter *iter);
> + struct iov_iter iter;
>   struct kvec iov[2];
>   struct TCP_Server_Info *server;
>  #ifdef CONFIG_CIFS_SMB_DIRECT
> diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
> index 75ce6f742b8d..64eb5c817712 100644
> --- a/fs/cifs/cifsproto.h
> +++ b/fs/cifs/cifsproto.h
> @@ -239,6 +239,9 @@ extern int cifs_read_page_from_socket(struct
> TCP_Server_Info *server,
>   unsigned int page_offset,
>   unsigned int to_read);
>  extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
> +extern int cifs_read_iter_from_socket(struct TCP_Server_Info *server,
> +       struct iov_iter *iter,
> +       unsigned int to_read);
>  extern int cifs_match_super(struct super_block *, void *);
>  extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct
> smb3_fs_context *ctx);
>  extern void cifs_umount(struct cifs_sb_info *);
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 943f4eba027d..7c8db233fba4 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -585,6 +585,22 @@ cifs_read_page_from_socket(struct TCP_Server_Info
> *server, struct page *page,
>   return cifs_readv_from_socket(server, &smb_msg);
>  }
>
> +int
> +cifs_read_iter_from_socket(struct TCP_Server_Info *server, struct
> iov_iter *iter,
> +    unsigned int to_read)
> +{
> + struct msghdr smb_msg;
> + int ret;
> +
> + smb_msg.msg_iter = *iter;
> + if (smb_msg.msg_iter.count > to_read)
> + smb_msg.msg_iter.count = to_read;
> + ret = cifs_readv_from_socket(server, &smb_msg);
> + if (ret > 0)
> + iov_iter_advance(iter, ret);
> + return ret;
> +}
> +
>  static bool
>  is_smb_response(struct TCP_Server_Info *server, unsigned char type)
>  {
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index 6d001905c8e5..4b8c1ac58f00 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -4261,8 +4261,7 @@ readpages_fill_pages(struct TCP_Server_Info *server,
>   result = n;
>  #endif
>   else
> - result = cifs_read_page_from_socket(
> - server, page, page_offset, n);
> + result = cifs_read_iter_from_socket(server, &rdata->iter, n);
>   if (result < 0)
>   break;
>
>
> --
> Thanks,
>
> Steve
Steve French Feb. 26, 2021, 2:24 a.m. UTC | #2
It regressed when buildbot tests run on it (hundreds of signing error
messages logged as well) - so backed this patch out of for-next

On Thu, Feb 25, 2021 at 12:44 PM Steve French <smfrench@gmail.com> wrote:
>
> Tentatively merged into cifs-2.6.git for-next, pending testing
>
> On Thu, Feb 4, 2021 at 12:49 AM Steve French <smfrench@gmail.com> wrote:
> >
> > (Another patch to make conversion to new netfs interfaces easier)
> >
> > Optimize read_page_from_socket by using an iov_iter
> >
> > Signed-off-by: David Howells <dhowells@redhat.com>
> > Signed-off-by: Steve French <stfrench@microsoft.com>
> > ---
> >  fs/cifs/cifsglob.h  |  1 +
> >  fs/cifs/cifsproto.h |  3 +++
> >  fs/cifs/connect.c   | 16 ++++++++++++++++
> >  fs/cifs/file.c      |  3 +--
> >  4 files changed, 21 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> > index 50fcb65920e8..73f80cc38316 100644
> > --- a/fs/cifs/cifsglob.h
> > +++ b/fs/cifs/cifsglob.h
> > @@ -1301,6 +1301,7 @@ struct cifs_readdata {
> >   int (*copy_into_pages)(struct TCP_Server_Info *server,
> >   struct cifs_readdata *rdata,
> >   struct iov_iter *iter);
> > + struct iov_iter iter;
> >   struct kvec iov[2];
> >   struct TCP_Server_Info *server;
> >  #ifdef CONFIG_CIFS_SMB_DIRECT
> > diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
> > index 75ce6f742b8d..64eb5c817712 100644
> > --- a/fs/cifs/cifsproto.h
> > +++ b/fs/cifs/cifsproto.h
> > @@ -239,6 +239,9 @@ extern int cifs_read_page_from_socket(struct
> > TCP_Server_Info *server,
> >   unsigned int page_offset,
> >   unsigned int to_read);
> >  extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
> > +extern int cifs_read_iter_from_socket(struct TCP_Server_Info *server,
> > +       struct iov_iter *iter,
> > +       unsigned int to_read);
> >  extern int cifs_match_super(struct super_block *, void *);
> >  extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct
> > smb3_fs_context *ctx);
> >  extern void cifs_umount(struct cifs_sb_info *);
> > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> > index 943f4eba027d..7c8db233fba4 100644
> > --- a/fs/cifs/connect.c
> > +++ b/fs/cifs/connect.c
> > @@ -585,6 +585,22 @@ cifs_read_page_from_socket(struct TCP_Server_Info
> > *server, struct page *page,
> >   return cifs_readv_from_socket(server, &smb_msg);
> >  }
> >
> > +int
> > +cifs_read_iter_from_socket(struct TCP_Server_Info *server, struct
> > iov_iter *iter,
> > +    unsigned int to_read)
> > +{
> > + struct msghdr smb_msg;
> > + int ret;
> > +
> > + smb_msg.msg_iter = *iter;
> > + if (smb_msg.msg_iter.count > to_read)
> > + smb_msg.msg_iter.count = to_read;
> > + ret = cifs_readv_from_socket(server, &smb_msg);
> > + if (ret > 0)
> > + iov_iter_advance(iter, ret);
> > + return ret;
> > +}
> > +
> >  static bool
> >  is_smb_response(struct TCP_Server_Info *server, unsigned char type)
> >  {
> > diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> > index 6d001905c8e5..4b8c1ac58f00 100644
> > --- a/fs/cifs/file.c
> > +++ b/fs/cifs/file.c
> > @@ -4261,8 +4261,7 @@ readpages_fill_pages(struct TCP_Server_Info *server,
> >   result = n;
> >  #endif
> >   else
> > - result = cifs_read_page_from_socket(
> > - server, page, page_offset, n);
> > + result = cifs_read_iter_from_socket(server, &rdata->iter, n);
> >   if (result < 0)
> >   break;
> >
> >
> > --
> > Thanks,
> >
> > Steve
>
>
>
> --
> Thanks,
>
> Steve
diff mbox series

Patch

From a4c963803ddf8c17f36913089965f0348e536330 Mon Sep 17 00:00:00 2001
From: David Howells <dhowells@redhat.com>
Date: Thu, 4 Feb 2021 00:44:04 -0600
Subject: [PATCH] cifs: convert readpages_fill_pages to use iter

Optimize read_page_from_socket by using an iov_iter

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/cifsglob.h  |  1 +
 fs/cifs/cifsproto.h |  3 +++
 fs/cifs/connect.c   | 16 ++++++++++++++++
 fs/cifs/file.c      |  3 +--
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 50fcb65920e8..73f80cc38316 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1301,6 +1301,7 @@  struct cifs_readdata {
 	int (*copy_into_pages)(struct TCP_Server_Info *server,
 				struct cifs_readdata *rdata,
 				struct iov_iter *iter);
+	struct iov_iter			iter;
 	struct kvec			iov[2];
 	struct TCP_Server_Info		*server;
 #ifdef CONFIG_CIFS_SMB_DIRECT
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 75ce6f742b8d..64eb5c817712 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -239,6 +239,9 @@  extern int cifs_read_page_from_socket(struct TCP_Server_Info *server,
 					unsigned int page_offset,
 					unsigned int to_read);
 extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
+extern int cifs_read_iter_from_socket(struct TCP_Server_Info *server,
+				      struct iov_iter *iter,
+				      unsigned int to_read);
 extern int cifs_match_super(struct super_block *, void *);
 extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
 extern void cifs_umount(struct cifs_sb_info *);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 943f4eba027d..7c8db233fba4 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -585,6 +585,22 @@  cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page,
 	return cifs_readv_from_socket(server, &smb_msg);
 }
 
+int
+cifs_read_iter_from_socket(struct TCP_Server_Info *server, struct iov_iter *iter,
+			   unsigned int to_read)
+{
+	struct msghdr smb_msg;
+	int ret;
+
+	smb_msg.msg_iter = *iter;
+	if (smb_msg.msg_iter.count > to_read)
+		smb_msg.msg_iter.count = to_read;
+	ret = cifs_readv_from_socket(server, &smb_msg);
+	if (ret > 0)
+		iov_iter_advance(iter, ret);
+	return ret;
+}
+
 static bool
 is_smb_response(struct TCP_Server_Info *server, unsigned char type)
 {
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 6d001905c8e5..4b8c1ac58f00 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -4261,8 +4261,7 @@  readpages_fill_pages(struct TCP_Server_Info *server,
 			result = n;
 #endif
 		else
-			result = cifs_read_page_from_socket(
-					server, page, page_offset, n);
+			result = cifs_read_iter_from_socket(server, &rdata->iter, n);
 		if (result < 0)
 			break;
 
-- 
2.27.0