cifs: have cifsFileInfo hold an extra inode reference
authorJeff Layton <jlayton@redhat.com>
Sat, 12 Sep 2009 15:54:29 +0000 (11:54 -0400)
committerSteve French <sfrench@us.ibm.com>
Tue, 15 Sep 2009 19:45:25 +0000 (19:45 +0000)
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>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/cifsglob.h
fs/cifs/dir.c
fs/cifs/file.c

index 9a7527dc977ec675de99c8bd0c947f2ff5dcb2b8..c19419a38f62f5da4bdc9e32a41e4588d657644f 100644 (file)
@@ -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);
+       }
 }
 
 /*
index 44f735aa2e3fa1ea1ce8ad1f41f498ee90ead315..36435502b5e8e69feaf1e1a0879df4ea5091b19e 100644 (file)
@@ -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);
index 225d127c960eb13b9dd734df406065d4be51c058..b976cea24102f7b03c079ec128e59404cc93d906 100644 (file)
@@ -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