aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 38c06f826575..302ea15f02e6 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -130,10 +130,6 @@ static inline int cifs_posix_open_inode_helper(struct inode *inode,
130 struct cifsFileInfo *pCifsFile, int oplock, u16 netfid) 130 struct cifsFileInfo *pCifsFile, int oplock, u16 netfid)
131{ 131{
132 132
133 file->private_data = kmalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
134 if (file->private_data == NULL)
135 return -ENOMEM;
136 pCifsFile = cifs_init_private(file->private_data, inode, file, netfid);
137 write_lock(&GlobalSMBSeslock); 133 write_lock(&GlobalSMBSeslock);
138 134
139 pCifsInode = CIFS_I(file->f_path.dentry->d_inode); 135 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
@@ -184,6 +180,38 @@ psx_client_can_cache:
184 return 0; 180 return 0;
185} 181}
186 182
183static struct cifsFileInfo *
184cifs_fill_filedata(struct file *file)
185{
186 struct list_head *tmp;
187 struct cifsFileInfo *pCifsFile = NULL;
188 struct cifsInodeInfo *pCifsInode = NULL;
189
190 /* search inode for this file and fill in file->private_data */
191 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
192 read_lock(&GlobalSMBSeslock);
193 list_for_each(tmp, &pCifsInode->openFileList) {
194 pCifsFile = list_entry(tmp, struct cifsFileInfo, flist);
195 if ((pCifsFile->pfile == NULL) &&
196 (pCifsFile->pid == current->tgid)) {
197 /* mode set in cifs_create */
198
199 /* needed for writepage */
200 pCifsFile->pfile = file;
201 file->private_data = pCifsFile;
202 break;
203 }
204 }
205 read_unlock(&GlobalSMBSeslock);
206
207 if (file->private_data != NULL) {
208 return pCifsFile;
209 } else if ((file->f_flags & O_CREAT) && (file->f_flags & O_EXCL))
210 cERROR(1, ("could not find file instance for "
211 "new file %p", file));
212 return NULL;
213}
214
187/* all arguments to this function must be checked for validity in caller */ 215/* all arguments to this function must be checked for validity in caller */
188static inline int cifs_open_inode_helper(struct inode *inode, struct file *file, 216static inline int cifs_open_inode_helper(struct inode *inode, struct file *file,
189 struct cifsInodeInfo *pCifsInode, struct cifsFileInfo *pCifsFile, 217 struct cifsInodeInfo *pCifsInode, struct cifsFileInfo *pCifsFile,
@@ -258,7 +286,6 @@ int cifs_open(struct inode *inode, struct file *file)
258 struct cifsTconInfo *tcon; 286 struct cifsTconInfo *tcon;
259 struct cifsFileInfo *pCifsFile; 287 struct cifsFileInfo *pCifsFile;
260 struct cifsInodeInfo *pCifsInode; 288 struct cifsInodeInfo *pCifsInode;
261 struct list_head *tmp;
262 char *full_path = NULL; 289 char *full_path = NULL;
263 int desiredAccess; 290 int desiredAccess;
264 int disposition; 291 int disposition;
@@ -270,32 +297,12 @@ int cifs_open(struct inode *inode, struct file *file)
270 cifs_sb = CIFS_SB(inode->i_sb); 297 cifs_sb = CIFS_SB(inode->i_sb);
271 tcon = cifs_sb->tcon; 298 tcon = cifs_sb->tcon;
272 299
273 /* search inode for this file and fill in file->private_data */
274 pCifsInode = CIFS_I(file->f_path.dentry->d_inode); 300 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
275 read_lock(&GlobalSMBSeslock); 301 pCifsFile = cifs_fill_filedata(file);
276 list_for_each(tmp, &pCifsInode->openFileList) { 302 if (pCifsFile) {
277 pCifsFile = list_entry(tmp, struct cifsFileInfo,
278 flist);
279 if ((pCifsFile->pfile == NULL) &&
280 (pCifsFile->pid == current->tgid)) {
281 /* mode set in cifs_create */
282
283 /* needed for writepage */
284 pCifsFile->pfile = file;
285
286 file->private_data = pCifsFile;
287 break;
288 }
289 }
290 read_unlock(&GlobalSMBSeslock);
291
292 if (file->private_data != NULL) {
293 rc = 0;
294 FreeXid(xid); 303 FreeXid(xid);
295 return rc; 304 return 0;
296 } else if ((file->f_flags & O_CREAT) && (file->f_flags & O_EXCL)) 305 }
297 cERROR(1, ("could not find file instance for "
298 "new file %p", file));
299 306
300 full_path = build_path_from_dentry(file->f_path.dentry); 307 full_path = build_path_from_dentry(file->f_path.dentry);
301 if (full_path == NULL) { 308 if (full_path == NULL) {
@@ -325,6 +332,7 @@ int cifs_open(struct inode *inode, struct file *file)
325 /* no need for special case handling of setting mode 332 /* no need for special case handling of setting mode
326 on read only files needed here */ 333 on read only files needed here */
327 334
335 pCifsFile = cifs_fill_filedata(file);
328 cifs_posix_open_inode_helper(inode, file, pCifsInode, 336 cifs_posix_open_inode_helper(inode, file, pCifsInode,
329 pCifsFile, oplock, netfid); 337 pCifsFile, oplock, netfid);
330 goto out; 338 goto out;