linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>
To: Al Viro <viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 4/6] cifs: no need to wank with copying and advancing iovec on recvmsg side either
Date: Tue, 19 Apr 2016 13:55:11 -0400	[thread overview]
Message-ID: <1461088511.15135.11.camel@poochiereds.net> (raw)
In-Reply-To: <20160409205210.GJ25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>

On Sat, 2016-04-09 at 21:52 +0100, Al Viro wrote:
> Signed-off-by: Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
> ---
>  fs/cifs/cifsglob.h |  2 --
>  fs/cifs/connect.c  | 72 ++++--------------------------------------------------
>  2 files changed, 5 insertions(+), 69 deletions(-)
> 
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index d21da9f..df03c5e 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -615,8 +615,6 @@ struct TCP_Server_Info {
>  	bool	sec_mskerberos;		/* supports legacy MS Kerberos */
>  	bool	large_buf;		/* is current buffer large? */
>  	struct delayed_work	echo; /* echo ping workqueue job */
> -	struct kvec *iov;	/* reusable kvec array for receives */
> -	unsigned int nr_iov;	/* number of kvecs in array */
>  	char	*smallbuf;	/* pointer to current "small" buffer */
>  	char	*bigbuf;	/* pointer to current "big" buffer */
>  	unsigned int total_read; /* total amount of data read in this pass */
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index a763cd3..eb42665 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -501,77 +501,20 @@ server_unresponsive(struct TCP_Server_Info *server)
>  	return false;
>  }
>  
> -/*
> - * kvec_array_init - clone a kvec array, and advance into it
> - * @new:	pointer to memory for cloned array
> - * @iov:	pointer to original array
> - * @nr_segs:	number of members in original array
> - * @bytes:	number of bytes to advance into the cloned array
> - *
> - * This function will copy the array provided in iov to a section of memory
> - * and advance the specified number of bytes into the new array. It returns
> - * the number of segments in the new array. "new" must be at least as big as
> - * the original iov array.
> - */
> -static unsigned int
> -kvec_array_init(struct kvec *new, struct kvec *iov, unsigned int nr_segs,
> -		size_t bytes)
> -{
> -	size_t base = 0;
> -
> -	while (bytes || !iov->iov_len) {
> -		int copy = min(bytes, iov->iov_len);
> -
> -		bytes -= copy;
> -		base += copy;
> -		if (iov->iov_len == base) {
> -			iov++;
> -			nr_segs--;
> -			base = 0;
> -		}
> -	}
> -	memcpy(new, iov, sizeof(*iov) * nr_segs);
> -	new->iov_base += base;
> -	new->iov_len -= base;
> -	return nr_segs;
> -}
> -
> -static struct kvec *
> -get_server_iovec(struct TCP_Server_Info *server, unsigned int nr_segs)
> -{
> -	struct kvec *new_iov;
> -
> -	if (server->iov && nr_segs <= server->nr_iov)
> -		return server->iov;
> -
> -	/* not big enough -- allocate a new one and release the old */
> -	new_iov = kmalloc(sizeof(*new_iov) * nr_segs, GFP_NOFS);
> -	if (new_iov) {
> -		kfree(server->iov);
> -		server->iov = new_iov;
> -		server->nr_iov = nr_segs;
> -	}
> -	return new_iov;
> -}
> -
>  int
>  cifs_readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig,
>  		       unsigned int nr_segs, unsigned int to_read)
>  {
>  	int length = 0;
>  	int total_read;
> -	unsigned int segs;
>  	struct msghdr smb_msg;
> -	struct kvec *iov;
> -
> -	iov = get_server_iovec(server, nr_segs);
> -	if (!iov)
> -		return -ENOMEM;
>  
>  	smb_msg.msg_control = NULL;
>  	smb_msg.msg_controllen = 0;
> +	iov_iter_kvec(&smb_msg.msg_iter, READ | ITER_KVEC,
> +		      iov_orig, nr_segs, to_read);
>  
> -	for (total_read = 0; to_read; total_read += length, to_read -= length) {
> +	for (total_read = 0; msg_data_left(&smb_msg); total_read += length) {
>  		try_to_freeze();
>  
>  		if (server_unresponsive(server)) {
> @@ -579,10 +522,7 @@ cifs_readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig,
>  			break;
>  		}
>  
> -		segs = kvec_array_init(iov, iov_orig, nr_segs, total_read);
> -
> -		length = kernel_recvmsg(server->ssocket, &smb_msg,
> -					iov, segs, to_read, 0);
> +		length = sock_recvmsg(server->ssocket, &smb_msg, 0);
>  
>  		if (server->tcpStatus == CifsExiting) {
>  			total_read = -ESHUTDOWN;
> @@ -603,8 +543,7 @@ cifs_readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig,
>  			length = 0;
>  			continue;
>  		} else if (length <= 0) {
> -			cifs_dbg(FYI, "Received no data or error: expecting %d\n"
> -				 "got %d", to_read, length);
> +			cifs_dbg(FYI, "Received no data or error: %d\n", length);
>  			cifs_reconnect(server);
>  			total_read = -ECONNABORTED;
>  			break;
> @@ -783,7 +722,6 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
>  	}
>  
>  	kfree(server->hostname);
> -	kfree(server->iov);
>  	kfree(server);
>  
>  	length = atomic_dec_return(&tcpSesAllocCount);

Good riddance.

Reviewed-by: Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>

  parent reply	other threads:[~2016-04-19 17:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-09 20:43 [RFC][PATCHSET] reduce messing with iovecs in cifs Al Viro
2016-04-09 20:50 ` [PATCH 2/6] cifs: merge the hash calculation helpers Al Viro
     [not found]   ` <20160409205056.GH25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2016-04-13  5:07     ` Shirish Pargaonkar
2016-04-19 16:12   ` Jeff Layton
     [not found] ` <20160409204301.GF25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2016-04-09 20:50   ` [PATCH 1/6] [net] drop 'size' argument of sock_recvmsg() Al Viro
     [not found]     ` <20160409205029.GG25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2016-04-19 16:03       ` Jeff Layton
2016-04-09 20:51   ` [PATCH 3/6] cifs: quit playing games with draining iovecs Al Viro
     [not found]     ` <20160409205129.GI25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2016-04-19 17:53       ` Jeff Layton
2016-04-19 22:41         ` Al Viro
2016-04-09 20:52   ` [PATCH 4/6] cifs: no need to wank with copying and advancing iovec on recvmsg side either Al Viro
     [not found]     ` <20160409205210.GJ25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2016-04-19 17:55       ` Jeff Layton [this message]
2016-04-09 20:52   ` [PATCH 5/6] cifs_readv_receive: use cifs_read_from_socket() Al Viro
     [not found]     ` <20160409205236.GK25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2016-04-19 15:01       ` Jeff Layton
2016-04-09 20:53   ` [PATCH 6/6] cifs: don't bother with kmap on read_pages side Al Viro
     [not found]     ` <20160409205304.GL25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2016-04-19 18:24       ` Jeff Layton
2016-04-11  2:43   ` [RFC][PATCHSET] reduce messing with iovecs in cifs Shirish Pargaonkar
2016-04-25  3:22   ` Steve French

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461088511.15135.11.camel@poochiereds.net \
    --to=jlayton-vpemndpepfumzcb2o+c8xq@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).