aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2010-06-16 13:40:16 -0400
committerJeff Layton <jlayton@redhat.com>2010-06-16 13:40:16 -0400
commit2422f676fb78942d054f7e7a2c3ceaeb7945d814 (patch)
treecacba53545327624023baf450868749ccec5a65b /fs/cifs/file.c
parent0933a95dfdb1ae5c93e1ede5899f35acc2bb244d (diff)
cifs: move cifs_new_fileinfo call out of cifs_posix_open
Having cifs_posix_open call cifs_new_fileinfo is problematic and inconsistent with how "regular" opens work. It's also buggy as cifs_reopen_file calls this function on a reconnect, which creates a new struct cifsFileInfo that just gets leaked. Push it out into the callers. This also allows us to get rid of the "mnt" arg to cifs_posix_open. Finally, in the event that a cifsFileInfo isn't or can't be created, we always want to close the filehandle out on the server as the client won't have a record of the filehandle and can't actually use it. Make sure that CIFSSMBClose is called in those cases. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-and-Tested-by: Suresh Jayaraman <sjayaraman@suse.de>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 75541af4b3db..542e0c874d64 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -299,8 +299,7 @@ int cifs_open(struct inode *inode, struct file *file)
299 int oflags = (int) cifs_posix_convert_flags(file->f_flags); 299 int oflags = (int) cifs_posix_convert_flags(file->f_flags);
300 oflags |= SMB_O_CREAT; 300 oflags |= SMB_O_CREAT;
301 /* can not refresh inode info since size could be stale */ 301 /* can not refresh inode info since size could be stale */
302 rc = cifs_posix_open(full_path, &inode, file->f_path.mnt, 302 rc = cifs_posix_open(full_path, &inode, inode->i_sb,
303 inode->i_sb,
304 cifs_sb->mnt_file_mode /* ignored */, 303 cifs_sb->mnt_file_mode /* ignored */,
305 oflags, &oplock, &netfid, xid); 304 oflags, &oplock, &netfid, xid);
306 if (rc == 0) { 305 if (rc == 0) {
@@ -308,7 +307,16 @@ int cifs_open(struct inode *inode, struct file *file)
308 /* no need for special case handling of setting mode 307 /* no need for special case handling of setting mode
309 on read only files needed here */ 308 on read only files needed here */
310 309
311 pCifsFile = cifs_fill_filedata(file); 310 pCifsFile = cifs_new_fileinfo(inode, netfid, file,
311 file->f_path.mnt,
312 oflags);
313 if (pCifsFile == NULL) {
314 CIFSSMBClose(xid, tcon, netfid);
315 rc = -ENOMEM;
316 goto out;
317 }
318 file->private_data = pCifsFile;
319
312 cifs_posix_open_inode_helper(inode, file, pCifsInode, 320 cifs_posix_open_inode_helper(inode, file, pCifsInode,
313 oplock, netfid); 321 oplock, netfid);
314 goto out; 322 goto out;
@@ -513,8 +521,7 @@ reopen_error_exit:
513 le64_to_cpu(tcon->fsUnixInfo.Capability))) { 521 le64_to_cpu(tcon->fsUnixInfo.Capability))) {
514 int oflags = (int) cifs_posix_convert_flags(file->f_flags); 522 int oflags = (int) cifs_posix_convert_flags(file->f_flags);
515 /* can not refresh inode info since size could be stale */ 523 /* can not refresh inode info since size could be stale */
516 rc = cifs_posix_open(full_path, NULL, file->f_path.mnt, 524 rc = cifs_posix_open(full_path, NULL, inode->i_sb,
517 inode->i_sb,
518 cifs_sb->mnt_file_mode /* ignored */, 525 cifs_sb->mnt_file_mode /* ignored */,
519 oflags, &oplock, &netfid, xid); 526 oflags, &oplock, &netfid, xid);
520 if (rc == 0) { 527 if (rc == 0) {