]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
cifs: keep dentry reference in cifsFileInfo instead of inode reference
authorJeff Layton <jlayton@redhat.com>
Mon, 11 Oct 2010 19:07:18 +0000 (15:07 -0400)
committerSteve French <sfrench@us.ibm.com>
Tue, 12 Oct 2010 18:06:42 +0000 (18:06 +0000)
cifsFileInfo is a bit problematic. It contains a reference back to the
struct file itself. This makes it difficult for a cifsFileInfo to exist
without a corresponding struct file.

It would be better instead of the cifsFileInfo just held info pertaining
to the open file on the server instead without any back refrences to the
struct file. This would allow it to exist after the filp to which it was
originally attached was closed.

Much of the use of the file pointer in this struct is to get at the
dentry.  Begin divorcing the cifsFileInfo from the struct file by
keeping a reference to the dentry. Since the dentry will have a
reference to the inode, we can eliminate the "pInode" field too and
convert the igrab/iput to dget/dput.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Suresh Jayaraman <sjayaraman@suse.de>
Acked-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/cifsglob.h
fs/cifs/dir.c
fs/cifs/file.c
fs/cifs/misc.c

index 4f85dfdf197d8fc6ebd00745d55b970689b483f4..8289e61937a2cffd27c3fa5b1c122ddb44fc11fd 100644 (file)
@@ -387,7 +387,7 @@ struct cifsFileInfo {
        /* BB add lock scope info here if needed */ ;
        /* lock scope id (0 if none) */
        struct file *pfile; /* needed for writepage */
-       struct inode *pInode; /* needed for oplock break */
+       struct dentry *dentry;
        struct vfsmount *mnt;
        struct tcon_link *tlink;
        struct mutex lock_mutex;
@@ -412,7 +412,7 @@ static inline void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
 {
        if (atomic_dec_and_test(&cifs_file->count)) {
                cifs_put_tlink(cifs_file->tlink);
-               iput(cifs_file->pInode);
+               dput(cifs_file->dentry);
                kfree(cifs_file);
        }
 }
index e249b561ce8f861d92e1f6dd46b244c50e709b51..6887c412c61a635ee6b214629cdab2f4b44f136b 100644 (file)
@@ -135,6 +135,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
                  struct vfsmount *mnt, struct tcon_link *tlink,
                  unsigned int oflags, __u32 oplock)
 {
+       struct dentry *dentry = file->f_path.dentry;
        struct cifsFileInfo *pCifsFile;
        struct cifsInodeInfo *pCifsInode;
 
@@ -145,7 +146,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
        pCifsFile->netfid = fileHandle;
        pCifsFile->pid = current->tgid;
        pCifsFile->uid = current_fsuid();
-       pCifsFile->pInode = igrab(newinode);
+       pCifsFile->dentry = dget(dentry);
        pCifsFile->mnt = mnt;
        pCifsFile->pfile = file;
        pCifsFile->invalidHandle = false;
index 80856f1807111ea4f6d04bff97b8b4c52b4f9b66..c302b9c5264488f598c53095f2fc2fd16bb32dab 100644 (file)
@@ -2335,7 +2335,7 @@ void cifs_oplock_break(struct work_struct *work)
 {
        struct cifsFileInfo *cfile = container_of(work, struct cifsFileInfo,
                                                  oplock_break);
-       struct inode *inode = cfile->pInode;
+       struct inode *inode = cfile->dentry->d_inode;
        struct cifsInodeInfo *cinode = CIFS_I(inode);
        int rc, waitrc = 0;
 
index 252f2768db849a3ec38bc4d8b0927d62e03b9892..9bac3e74b3149b6fd12025d362366dcf5aa21dac 100644 (file)
@@ -578,7 +578,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
                                }
 
                                cFYI(1, "file id match, oplock break");
-                               pCifsInode = CIFS_I(netfile->pInode);
+                               pCifsInode = CIFS_I(netfile->dentry->d_inode);
                                pCifsInode->clientCanCacheAll = false;
                                if (pSMB->OplockLevel == 0)
                                        pCifsInode->clientCanCacheRead = false;