aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2010-10-15 15:33:58 -0400
committerSteve French <sfrench@us.ibm.com>2010-10-17 21:04:16 -0400
commitabfe1eedd682ea0f20e7035445982e6d371a2024 (patch)
tree70d5fe483cae0f782b8e78ea5c08ef2dbb45c2e7
parentf6a53460e2a105904deeada737b3f878d78517b3 (diff)
cifs: eliminate the inode argument from cifs_new_fileinfo
It already takes a file pointer. The inode associated with that had damn well better be the same one we're passing in anyway. Thus, there's no need for a separate argument here. Also, get rid of the bogus check for a null pCifsInode pointer. The CIFS_I macro uses container_of(), and that will virtually never return a NULL pointer anyway. Finally, move the setting of the canCache* flags outside of the lock. Other places in the code don't hold that lock when setting it, so I assume it's not really needed here either. 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>
-rw-r--r--fs/cifs/cifsproto.h3
-rw-r--r--fs/cifs/dir.c40
-rw-r--r--fs/cifs/file.c6
3 files changed, 22 insertions, 27 deletions
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 781676e9cfc3..ca6a0d9130cb 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -105,8 +105,7 @@ extern u64 cifs_UnixTimeToNT(struct timespec);
105extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, 105extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
106 int offset); 106 int offset);
107 107
108extern struct cifsFileInfo *cifs_new_fileinfo(struct inode *newinode, 108extern struct cifsFileInfo *cifs_new_fileinfo(__u16 fileHandle, struct file *file,
109 __u16 fileHandle, struct file *file,
110 struct tcon_link *tlink, __u32 oplock); 109 struct tcon_link *tlink, __u32 oplock);
111extern int cifs_posix_open(char *full_path, struct inode **pinode, 110extern int cifs_posix_open(char *full_path, struct inode **pinode,
112 struct super_block *sb, 111 struct super_block *sb,
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index ce1fa3027b23..36cf3e2ec252 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -131,12 +131,13 @@ cifs_bp_rename_retry:
131} 131}
132 132
133struct cifsFileInfo * 133struct cifsFileInfo *
134cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file, 134cifs_new_fileinfo(__u16 fileHandle, struct file *file,
135 struct tcon_link *tlink, __u32 oplock) 135 struct tcon_link *tlink, __u32 oplock)
136{ 136{
137 struct dentry *dentry = file->f_path.dentry; 137 struct dentry *dentry = file->f_path.dentry;
138 struct inode *inode = dentry->d_inode;
139 struct cifsInodeInfo *pCifsInode = CIFS_I(inode);
138 struct cifsFileInfo *pCifsFile; 140 struct cifsFileInfo *pCifsFile;
139 struct cifsInodeInfo *pCifsInode;
140 141
141 pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); 142 pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
142 if (pCifsFile == NULL) 143 if (pCifsFile == NULL)
@@ -158,24 +159,20 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
158 159
159 write_lock(&GlobalSMBSeslock); 160 write_lock(&GlobalSMBSeslock);
160 list_add(&pCifsFile->tlist, &(tlink_tcon(tlink)->openFileList)); 161 list_add(&pCifsFile->tlist, &(tlink_tcon(tlink)->openFileList));
161 pCifsInode = CIFS_I(newinode); 162 /* if readable file instance put first in list*/
162 if (pCifsInode) { 163 if (file->f_mode & FMODE_READ)
163 /* if readable file instance put first in list*/ 164 list_add(&pCifsFile->flist, &pCifsInode->openFileList);
164 if (file->f_mode & FMODE_READ) 165 else
165 list_add(&pCifsFile->flist, &pCifsInode->openFileList); 166 list_add_tail(&pCifsFile->flist, &pCifsInode->openFileList);
166 else
167 list_add_tail(&pCifsFile->flist,
168 &pCifsInode->openFileList);
169
170 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
171 pCifsInode->clientCanCacheAll = true;
172 pCifsInode->clientCanCacheRead = true;
173 cFYI(1, "Exclusive Oplock inode %p", newinode);
174 } else if ((oplock & 0xF) == OPLOCK_READ)
175 pCifsInode->clientCanCacheRead = true;
176 }
177 write_unlock(&GlobalSMBSeslock); 167 write_unlock(&GlobalSMBSeslock);
178 168
169 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
170 pCifsInode->clientCanCacheAll = true;
171 pCifsInode->clientCanCacheRead = true;
172 cFYI(1, "Exclusive Oplock inode %p", inode);
173 } else if ((oplock & 0xF) == OPLOCK_READ)
174 pCifsInode->clientCanCacheRead = true;
175
179 file->private_data = pCifsFile; 176 file->private_data = pCifsFile;
180 177
181 return pCifsFile; 178 return pCifsFile;
@@ -395,8 +392,7 @@ cifs_create_set_dentry:
395 goto cifs_create_out; 392 goto cifs_create_out;
396 } 393 }
397 394
398 pfile_info = cifs_new_fileinfo(newinode, fileHandle, filp, 395 pfile_info = cifs_new_fileinfo(fileHandle, filp, tlink, oplock);
399 tlink, oplock);
400 if (pfile_info == NULL) { 396 if (pfile_info == NULL) {
401 fput(filp); 397 fput(filp);
402 CIFSSMBClose(xid, tcon, fileHandle); 398 CIFSSMBClose(xid, tcon, fileHandle);
@@ -669,8 +665,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
669 goto lookup_out; 665 goto lookup_out;
670 } 666 }
671 667
672 cfile = cifs_new_fileinfo(newInode, fileHandle, filp, 668 cfile = cifs_new_fileinfo(fileHandle, filp, tlink,
673 tlink, oplock); 669 oplock);
674 if (cfile == NULL) { 670 if (cfile == NULL) {
675 fput(filp); 671 fput(filp);
676 CIFSSMBClose(xid, pTcon, fileHandle); 672 CIFSSMBClose(xid, pTcon, fileHandle);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 774e3ac1208b..394cf28f080d 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -272,8 +272,8 @@ int cifs_open(struct inode *inode, struct file *file)
272 if (rc == 0) { 272 if (rc == 0) {
273 cFYI(1, "posix open succeeded"); 273 cFYI(1, "posix open succeeded");
274 274
275 pCifsFile = cifs_new_fileinfo(inode, netfid, file, 275 pCifsFile = cifs_new_fileinfo(netfid, file, tlink,
276 tlink, oplock); 276 oplock);
277 if (pCifsFile == NULL) { 277 if (pCifsFile == NULL) {
278 CIFSSMBClose(xid, tcon, netfid); 278 CIFSSMBClose(xid, tcon, netfid);
279 rc = -ENOMEM; 279 rc = -ENOMEM;
@@ -365,7 +365,7 @@ int cifs_open(struct inode *inode, struct file *file)
365 if (rc != 0) 365 if (rc != 0)
366 goto out; 366 goto out;
367 367
368 pCifsFile = cifs_new_fileinfo(inode, netfid, file, tlink, oplock); 368 pCifsFile = cifs_new_fileinfo(netfid, file, tlink, oplock);
369 if (pCifsFile == NULL) { 369 if (pCifsFile == NULL) {
370 rc = -ENOMEM; 370 rc = -ENOMEM;
371 goto out; 371 goto out;