From patchwork Fri Sep 11 12:14:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 33449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4EA2EB7043 for ; Fri, 11 Sep 2009 22:14:22 +1000 (EST) Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 7D7B8465BC; Fri, 11 Sep 2009 06:03:37 -0600 (MDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fn.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=3.8 tests=AWL, BAYES_00, NO_MORE_FUNN, SPF_PASS autolearn=no version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from cdptpa-omtalb.mail.rr.com (cdptpa-omtalb.mail.rr.com [75.180.132.120]) by lists.samba.org (Postfix) with ESMTP id 21220465BC for ; Fri, 11 Sep 2009 06:03:25 -0600 (MDT) Received: from mail.poochiereds.net ([71.70.153.3]) by cdptpa-omta02.mail.rr.com with ESMTP id <20090911121409364.TRX14103@cdptpa-omta02.mail.rr.com>; Fri, 11 Sep 2009 12:14:09 +0000 Received: by mail.poochiereds.net (Postfix, from userid 4447) id 1CB5058169; Fri, 11 Sep 2009 08:14:09 -0400 (EDT) From: Jeff Layton To: smfrench@gmail.com Date: Fri, 11 Sep 2009 08:14:07 -0400 Message-Id: <1252671248-15874-4-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1252671248-15874-1-git-send-email-jlayton@redhat.com> References: <1252671248-15874-1-git-send-email-jlayton@redhat.com> Cc: linux-cifs-client@lists.samba.org Subject: [linux-cifs-client] [PATCH 3/4] cifs: have cifsFileInfo hold an extra inode reference X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org It's possible that this struct will outlive the filp to which it is attached. If it does and it needs to do some work on the inode, then it'll need a reference. Signed-off-by: Jeff Layton --- fs/cifs/cifsglob.h | 4 +++- fs/cifs/dir.c | 2 +- fs/cifs/file.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index b8d673c..908b2de 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -365,8 +365,10 @@ static inline void cifsFileInfo_get(struct cifsFileInfo *cifs_file) /* Release a reference on the file private data */ static inline void cifsFileInfo_put(struct cifsFileInfo *cifs_file) { - if (atomic_dec_and_test(&cifs_file->count)) + if (atomic_dec_and_test(&cifs_file->count)) { + iput(cifs_file->pInode); kfree(cifs_file); + } } /* diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index a6424cf..6b45feb 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -147,7 +147,7 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, pCifsFile->netfid = fileHandle; pCifsFile->pid = current->tgid; - pCifsFile->pInode = newinode; + pCifsFile->pInode = igrab(newinode); pCifsFile->invalidHandle = false; pCifsFile->closePend = false; mutex_init(&pCifsFile->fh_mutex); diff --git a/fs/cifs/file.c b/fs/cifs/file.c index fa7beac..9498d2c 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -50,7 +50,7 @@ static inline struct cifsFileInfo *cifs_init_private( mutex_init(&private_data->lock_mutex); INIT_LIST_HEAD(&private_data->llist); private_data->pfile = file; /* needed for writepage */ - private_data->pInode = inode; + private_data->pInode = igrab(inode); private_data->invalidHandle = false; private_data->closePend = false; /* Initialize reference count to one. The private data is