Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 451

kernel-2.6.18-238.el5.src.rpm

From: Jeff Layton <jlayton@redhat.com>
Date: Mon, 26 Oct 2009 15:54:22 -0400
Subject: [cifs] have cifsFileInfo hold an extra inode reference
Message-id: <1256572464-27293-8-git-send-email-jlayton@redhat.com>
Patchwork-id: 21217
O-Subject: [RHEL5.5 PATCH 7/9] BZ#531005: cifs: have cifsFileInfo hold an extra
	inode reference
Bugzilla: 531005
RH-Acked-by: Steve Dickson <SteveD@redhat.com>
RH-Acked-by: Peter Staubach <staubach@redhat.com>

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 <jlayton@redhat.com>

diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index bd1e0c0..f83b226 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -375,8 +375,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 d12e68f..a24bc54 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -424,7 +424,7 @@ cifs_create_set_dentry:
 			goto cifs_create_out;
 		pCifsFile->netfid = fileHandle;
 		pCifsFile->pid = current->tgid;
-		pCifsFile->pInode = newinode;
+		pCifsFile->pInode = igrab(newinode);
 		pCifsFile->invalidHandle = false;
 		pCifsFile->closePend     = false;
 		init_MUTEX(&pCifsFile->fh_sem);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index e27e106..1e677fb 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -61,7 +61,7 @@ static inline struct cifsFileInfo *cifs_init_private(
 #endif
 	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