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 13/15] cifs: convert cifsFileInfo->count to non-atomic counter
Date: Mon, 11 Oct 2010 11:16:19 +0530 [thread overview]
Message-ID: <4CB2A4AB.2000503@suse.de> (raw)
In-Reply-To: <1286559072-29032-14-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
On 10/08/2010 11:01 PM, Jeff Layton wrote:
> The count for cifsFileInfo is currently an atomic, but that just adds
> complexity for little value. We generally need to hold cifs_file_list_lock
> to traverse the lists anyway so we might as well make this counter
> non-atomic and simply use the cifs_file_list_lock to protect it.
>
> Signed-off-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> fs/cifs/cifsglob.h | 9 ++++++---
> fs/cifs/file.c | 8 +++++---
> 2 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index c928e39..2327dcb 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -393,16 +393,19 @@ struct cifsFileInfo {
> struct list_head llist; /* list of byte range locks we have. */
> bool invalidHandle:1; /* file closed via session abend */
> bool oplock_break_cancelled:1;
> - atomic_t count; /* reference count */
> + int count; /* refcount -- protected by cifs_file_list_lock */
> struct mutex fh_mutex; /* prevents reopen race after dead ses*/
> struct cifs_search_info srch_inf;
> struct work_struct oplock_break; /* work for oplock breaks */
> };
>
> -/* Take a reference on the file private data */
> +/*
> + * Take a reference on the file private data. Must be called with
> + * cifs_file_list_lock held.
> + */
> static inline void cifsFileInfo_get(struct cifsFileInfo *cifs_file)
> {
> - atomic_inc(&cifs_file->count);
> + ++cifs_file->count;
> }
>
> void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index 8cedcd7..7b8122b 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -172,6 +172,7 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
> if (pCifsFile == NULL)
> return pCifsFile;
>
> + pCifsFile->count = 1;
> pCifsFile->netfid = fileHandle;
> pCifsFile->pid = current->tgid;
> pCifsFile->uid = current_fsuid();
> @@ -182,7 +183,6 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
> mutex_init(&pCifsFile->fh_mutex);
> mutex_init(&pCifsFile->lock_mutex);
> INIT_LIST_HEAD(&pCifsFile->llist);
> - atomic_set(&pCifsFile->count, 1);
> INIT_WORK(&pCifsFile->oplock_break, cifs_oplock_break);
>
> spin_lock(&cifs_file_list_lock);
> @@ -203,7 +203,8 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
>
> /*
> * Release a reference on the file private data. This may involve closing
> - * the filehandle out on the server.
> + * the filehandle out on the server. Must be called without holding
> + * cifs_file_list_lock.
> */
> void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
> {
> @@ -212,7 +213,7 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
> struct cifsLockInfo *li, *tmp;
>
> spin_lock(&cifs_file_list_lock);
> - if (!atomic_dec_and_test(&cifs_file->count)) {
> + if (--cifs_file->count > 0) {
> spin_unlock(&cifs_file_list_lock);
> return;
> }
> @@ -2254,6 +2255,7 @@ void cifs_oplock_break(struct work_struct *work)
> cifs_oplock_break_put(cfile);
> }
>
> +/* must be called while holding cifs_file_list_lock */
> void cifs_oplock_break_get(struct cifsFileInfo *cfile)
> {
> cifs_sb_active(cfile->dentry->d_sb);
Looks correct to me.
Reviewed-by: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
next prev parent reply other threads:[~2010-10-11 5:46 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
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:30 ` [PATCH 01/15] cifs: keep dentry reference in cifsFileInfo instead of inode reference Jeff Layton
2010-10-08 17:30 ` [PATCH 02/15] cifs: don't use vfsmount to pin superblock for oplock breaks Jeff Layton
2010-10-08 17:31 ` [PATCH 03/15] cifs: eliminate cifs_posix_open_inode_helper Jeff Layton
2010-10-08 17:31 ` [PATCH 04/15] cifs: eliminate oflags option from cifs_new_fileinfo Jeff Layton
[not found] ` <1286559072-29032-5-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-10-11 5:41 ` Suresh Jayaraman
[not found] ` <4CB2A392.9030400-l3A5Bk7waGM@public.gmane.org>
2010-10-11 11:13 ` Jeff Layton
[not found] ` <20101011071322.3a6e090c-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2010-10-11 17:04 ` Steve French
[not found] ` <AANLkTik4=achQnm=8XN+GWWKFL8QOddz4xVVaBs4X3sX-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-11 17:17 ` Jeff Layton
[not found] ` <20101011131707.646b8532-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2010-10-11 17:27 ` Steve French
[not found] ` <AANLkTik6tc0iJwDACT-nctOi2Ui5E31AihWN8-vCM2zo-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-11 18:52 ` Jeff Layton
2010-10-08 17:31 ` [PATCH 05/15] cifs: eliminate the inode argument " Jeff Layton
2010-10-08 17:31 ` [PATCH 06/15] cifs: clean up cifs_reopen_file Jeff Layton
2010-10-08 17:31 ` [PATCH 07/15] cifs: cifs_write argument change and cleanup Jeff Layton
2010-10-08 17:31 ` [PATCH 08/15] cifs: eliminate pfile pointer from cifsFileInfo Jeff Layton
2010-10-08 17:31 ` [PATCH 09/15] cifs: move cifs_new_fileinfo to file.c Jeff Layton
2010-10-08 17:31 ` [PATCH 10/15] cifs: convert GlobalSMBSeslock from a rwlock to regular spinlock Jeff Layton
[not found] ` <1286559072-29032-11-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-10-11 5:45 ` Suresh Jayaraman
[not found] ` <4CB2A478.50401-l3A5Bk7waGM@public.gmane.org>
2010-10-12 13:28 ` Christoph Hellwig
2010-10-08 17:31 ` [PATCH 11/15] cifs: move cifsFileInfo_put to file.c Jeff Layton
2010-10-08 17:31 ` [PATCH 12/15] cifs: move close processing from cifs_close to cifsFileInfo_put Jeff Layton
2010-10-08 17:31 ` [PATCH 13/15] cifs: convert cifsFileInfo->count to non-atomic counter Jeff Layton
[not found] ` <1286559072-29032-14-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-10-11 5:46 ` Suresh Jayaraman [this message]
2010-10-08 17:31 ` [PATCH 14/15] cifs: wait for writeback to complete in cifs_flush Jeff Layton
2010-10-08 17:31 ` [PATCH 15/15] cifs: eliminate cifsInodeInfo->write_behind_rc Jeff Layton
-- strict thread matches above, loose matches on Subject: below --
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 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
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=4CB2A4AB.2000503@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox