All of lore.kernel.org
 help / color / mirror / Atom feed
From: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
To: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 12/15] cifs: move close processing from cifs_close to cifsFileInfo_put
Date: Thu, 07 Oct 2010 12:37:19 +0530	[thread overview]
Message-ID: <4CAD71A7.20808@suse.de> (raw)
In-Reply-To: <1286394857-32541-13-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On 10/07/2010 01:24 AM, Jeff Layton wrote:
> Now that it's feasible for a cifsFileInfo to outlive the filp under
> which it was created, move the close processing into cifsFileInfo_put.
> 
> This means that the last user of the filehandle always does the actual
> on the wire close call. This also allows us to get rid of the closePend
> flag from cifsFileInfo. If we have an active reference to the file
> then it's never going to have a close pending.
> 
> cifs_close is converted to simply put the filehandle.
> 
> Signed-off-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  fs/cifs/cifsglob.h |    1 -
>  fs/cifs/file.c     |  187 +++++++++++++++++-----------------------------------
>  fs/cifs/misc.c     |   10 ---
>  3 files changed, 60 insertions(+), 138 deletions(-)
> 

> -/* Release a reference on the file private data */
> +/*
> + * Release a reference on the file private data. This may involve closing
> + * the filehandle out on the server.
> + */
>  void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
>  {
> -	if (atomic_dec_and_test(&cifs_file->count)) {
> -		cifs_put_tlink(cifs_file->tlink);
> -		dput(cifs_file->dentry);
> -		kfree(cifs_file);
> +	struct cifsTconInfo *tcon = tlink_tcon(cifs_file->tlink);
> +	struct cifsInodeInfo *cifsi = CIFS_I(cifs_file->dentry->d_inode);
> +	struct cifsLockInfo *li, *tmp;
> +
> +	write_lock(&cifs_file_list_lock);
> +	if (!atomic_dec_and_test(&cifs_file_list_lock)) {
> +		write_unlock(&cifs_file_list_lock);
> +		return;
> +	}
> +
> +	/* remove it from the lists */
> +	list_del(&cifs_file->flist);
> +	list_del(&cifs_file->tlist);
> +
> +	if (list_empty(&cifsi->openFileList)) {
> +		cFYI(1, "closing last open instance for inode %p",
> +			cifs_file->dentry->d_inode);
> +		cifsi->clientCanCacheRead = false;
> +		cifsi->clientCanCacheAll  = false;
> +	}
> +	write_unlock(&cifs_file_list_lock);
> +
> +	if (!tcon->need_reconnect && !cifs_file->invalidHandle) {
> +		int xid, rc;
> +
> +		xid = GetXid();
> +		rc = CIFSSMBClose(xid, tcon, cifs_file->netfid);
> +		FreeXid(xid);
> +	}
> +
> +	/* Delete any outstanding lock records. We'll lose them when the file
> +	 * is closed anyway.
> +	 */
> +	mutex_lock(&cifs_file->lock_mutex);
> +	list_for_each_entry_safe(li, tmp, &cifs_file->llist, llist) {
> +		list_del(&li->llist);
> +		kfree(li);
>  	}
> +	mutex_unlock(&cifs_file->lock_mutex);
> +
> +	cifs_put_tlink(cifs_file->tlink);
> +	dput(cifs_file->dentry);
> +	kfree(cifs_file);
>  }
>  
>  int cifs_open(struct inode *inode, struct file *file)
> @@ -542,79 +582,11 @@ reopen_error_exit:
>  
>  int cifs_close(struct inode *inode, struct file *file)
>  {
> -	int rc = 0;
> -	int xid, timeout;
> -	struct cifs_sb_info *cifs_sb;
> -	struct cifsTconInfo *pTcon;
> -	struct cifsFileInfo *pSMBFile = file->private_data;
> -
> -	xid = GetXid();
> -
> -	cifs_sb = CIFS_SB(inode->i_sb);
> -	pTcon = tlink_tcon(pSMBFile->tlink);
> -	if (pSMBFile) {
> -		struct cifsLockInfo *li, *tmp;
> -		write_lock(&cifs_file_list_lock);
> -		pSMBFile->closePend = true;
> -		if (pTcon) {
> -			/* no sense reconnecting to close a file that is
> -			   already closed */
> -			if (!pTcon->need_reconnect) {
> -				write_unlock(&cifs_file_list_lock);
> -				timeout = 2;
> -				while ((atomic_read(&pSMBFile->count) != 1)

This portion of code which induces manual delay seems missing. While I'm
not sure about the practical significance of this code, explaining why
we do not need this in the change log would help?


> -					&& (timeout <= 2048)) {
> -					/* Give write a better chance to get to
> -					server ahead of the close.  We do not
> -					want to add a wait_q here as it would
> -					increase the memory utilization as
> -					the struct would be in each open file,
> -					but this should give enough time to
> -					clear the socket */
> -					cFYI(DBG2, "close delay, write pending");
> -					msleep(timeout);
> -					timeout *= 4;
> -				}
> -				if (!pTcon->need_reconnect &&
> -				    !pSMBFile->invalidHandle)
> -					rc = CIFSSMBClose(xid, pTcon,
> -						  pSMBFile->netfid);
> -			} else
> -				write_unlock(&cifs_file_list_lock);
> -		} else
> -			write_unlock(&cifs_file_list_lock);
> -
> -		/* Delete any outstanding lock records.
> -		   We'll lose them when the file is closed anyway. */
> -		mutex_lock(&pSMBFile->lock_mutex);
> -		list_for_each_entry_safe(li, tmp, &pSMBFile->llist, llist) {
> -			list_del(&li->llist);
> -			kfree(li);
> -		}
> -		mutex_unlock(&pSMBFile->lock_mutex);
> +	cifsFileInfo_put(file->private_data);
> +	file->private_data = NULL;
>  
> -		write_lock(&cifs_file_list_lock);
> -		list_del(&pSMBFile->flist);
> -		list_del(&pSMBFile->tlist);
> -		write_unlock(&cifs_file_list_lock);
> -		cifsFileInfo_put(file->private_data);
> -		file->private_data = NULL;
> -	} else
> -		rc = -EBADF;
> -
> -	read_lock(&cifs_file_list_lock);
> -	if (list_empty(&(CIFS_I(inode)->openFileList))) {
> -		cFYI(1, "closing last open instance for inode %p", inode);
> -		/* if the file is not open we do not know if we can cache info
> -		   on this inode, much less write behind and read ahead */
> -		CIFS_I(inode)->clientCanCacheRead = false;
> -		CIFS_I(inode)->clientCanCacheAll  = false;
> -	}
> -	read_unlock(&cifs_file_list_lock);
> -	if ((rc == 0) && CIFS_I(inode)->write_behind_rc)
> -		rc = CIFS_I(inode)->write_behind_rc;
> -	FreeXid(xid);
> -	return rc;
> +	/* return code from the ->release op is always ignored */
> +	return 0;
>  }
>  


-- 
Suresh Jayaraman

  parent reply	other threads:[~2010-10-07  7:07 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-06 19:54 [PATCH 00/15] cifs: clean up management of open filehandle (try #2) Jeff Layton
     [not found] ` <1286394857-32541-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-10-06 19:54   ` [PATCH 01/15] cifs: keep dentry reference in cifsFileInfo instead of inode reference Jeff Layton
2010-10-06 19:54   ` [PATCH 02/15] cifs: don't use vfsmount to pin superblock for oplock breaks Jeff Layton
2010-10-06 19:54   ` [PATCH 03/15] cifs: eliminate cifs_posix_open_inode_helper Jeff Layton
2010-10-06 19:54   ` [PATCH 04/15] cifs: eliminate oflags option from cifs_new_fileinfo Jeff Layton
2010-10-06 19:54   ` [PATCH 05/15] cifs: eliminate the inode argument " Jeff Layton
2010-10-06 19:54   ` [PATCH 06/15] cifs: clean up cifs_reopen_file Jeff Layton
2010-10-06 19:54   ` [PATCH 07/15] cifs: cifs_write argument change and cleanup Jeff Layton
2010-10-06 19:54   ` [PATCH 08/15] cifs: eliminate pfile pointer from cifsFileInfo Jeff Layton
2010-10-06 19:54   ` [PATCH 09/15] cifs: move cifs_new_fileinfo to file.c Jeff Layton
2010-10-06 19:54   ` [PATCH 10/15] cifs: rename GlobalSMBSeslock to cifs_file_list_lock Jeff Layton
2010-10-06 19:54   ` [PATCH 11/15] cifs: move cifsFileInfo_put to file.c Jeff Layton
2010-10-06 19:54   ` [PATCH 12/15] cifs: move close processing from cifs_close to cifsFileInfo_put Jeff Layton
     [not found]     ` <1286394857-32541-13-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-10-07  7:07       ` Suresh Jayaraman [this message]
     [not found]         ` <4CAD71A7.20808-l3A5Bk7waGM@public.gmane.org>
2010-10-07 11:07           ` Jeff Layton
     [not found]             ` <20101007070726.0ef1b1a8-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
2010-10-08  9:34               ` Suresh Jayaraman
2010-10-06 19:54   ` [PATCH 13/15] cifs: convert cifsFileInfo->count to non-atomic counter Jeff Layton
     [not found]     ` <1286394857-32541-14-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-10-07  8:48       ` Suresh Jayaraman
     [not found]         ` <4CAD8972.9090406-l3A5Bk7waGM@public.gmane.org>
2010-10-07 11:18           ` Jeff Layton
     [not found]             ` <20101007071819.2446312b-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
2010-10-07 12:12               ` Suresh Jayaraman
     [not found]                 ` <4CADB949.2070205-l3A5Bk7waGM@public.gmane.org>
2010-10-07 12:43                   ` Jeff Layton
     [not found]                     ` <20101007084334.0e03f586-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
2010-10-07 15:37                       ` Steve French
     [not found]                         ` <AANLkTi=MMzU6nr6+19PKW=gPKTdk9e-O5pjrYWmbV4AJ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-07 16:59                           ` Jeff Layton
     [not found]                             ` <20101007125932.4506f3e6-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
2010-10-07 17:42                               ` Jeff Layton
2010-10-07 18:05                           ` Christoph Hellwig
2010-10-06 19:54   ` [PATCH 14/15] cifs: wait for writeback to complete in cifs_flush Jeff Layton
2010-10-06 19:54   ` [PATCH 15/15] cifs: eliminate cifsInodeInfo->write_behind_rc Jeff Layton
2010-10-08  9:40   ` [PATCH 00/15] cifs: clean up management of open filehandle (try #2) Suresh Jayaraman
  -- strict thread matches above, loose matches on Subject: below --
2010-10-08 17:30 [PATCH 00/15] cifs: clean up management of open filehandle (try #3) Jeff Layton
     [not found] ` <1286559072-29032-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-10-08 17:31   ` [PATCH 12/15] cifs: move close processing from cifs_close to cifsFileInfo_put Jeff Layton

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=4CAD71A7.20808@suse.de \
    --to=sjayaraman-l3a5bk7wagm@public.gmane.org \
    --cc=jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=smfrench-Re5JQEeQqe8AvxtiuMwx3w@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.