diff mbox

[linux-cifs-client,06/11] cifs: have cifs_new_fileinfo take a tcon arg

Message ID 1271794039-22787-7-git-send-email-jlayton@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton April 20, 2010, 8:07 p.m. UTC
None
diff mbox

Patch

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index e563314..05ee024 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -131,8 +131,9 @@  cifs_bp_rename_retry:
 }
 
 struct cifsFileInfo *
-cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,
-		  struct file *file, struct vfsmount *mnt, unsigned int oflags)
+cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
+		  struct vfsmount *mnt, struct cifsTconInfo *tcon,
+		  unsigned int oflags)
 {
 	int oplock = 0;
 	struct cifsFileInfo *pCifsFile;
@@ -154,7 +155,7 @@  cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,
 	pCifsFile->pfile = file;
 	pCifsFile->invalidHandle = false;
 	pCifsFile->closePend = false;
-	pCifsFile->tcon = cifs_sb_tcon(cifs_sb);
+	pCifsFile->tcon = tcon;
 	mutex_init(&pCifsFile->fh_mutex);
 	mutex_init(&pCifsFile->lock_mutex);
 	INIT_LIST_HEAD(&pCifsFile->llist);
@@ -193,6 +194,10 @@  int cifs_posix_open(char *full_path, struct inode **pinode,
 	__u32 posix_flags = 0;
 	struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb);
 	struct cifs_fattr fattr;
+	struct cifsTconInfo *tcon = cifs_sb_tcon(cifs_sb);
+
+	if (IS_ERR(tcon))
+		return PTR_ERR(tcon);
 
 	cFYI(1, ("posix open %s", full_path));
 
@@ -227,9 +232,9 @@  int cifs_posix_open(char *full_path, struct inode **pinode,
 		posix_flags |= SMB_O_DIRECT;
 
 	mode &= ~current_umask();
-	rc = CIFSPOSIXCreate(xid, cifs_sb_tcon(cifs_sb), posix_flags, mode,
-			pnetfid, presp_data, poplock, full_path,
-			cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
+	rc = CIFSPOSIXCreate(xid, tcon, posix_flags, mode, pnetfid, presp_data,
+			     poplock, full_path, cifs_sb->local_nls,
+			     cifs_sb->mnt_cifs_flags &
 					CIFS_MOUNT_MAP_SPECIAL_CHR);
 	if (rc)
 		goto posix_open_ret;
@@ -253,7 +258,7 @@  int cifs_posix_open(char *full_path, struct inode **pinode,
 		cifs_fattr_to_inode(*pinode, &fattr);
 	}
 
-	cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt, oflags);
+	cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt, tcon, oflags);
 
 posix_open_ret:
 	kfree(presp_data);
@@ -304,6 +309,11 @@  cifs_create(struct inode *inode, struct dentry *direntry, int mode,
 	cifs_sb = CIFS_SB(inode->i_sb);
 	tcon = cifs_sb_tcon(cifs_sb);
 
+	if (IS_ERR(tcon)) {
+		FreeXid(xid);
+		return PTR_ERR(tcon);
+	}
+
 	full_path = build_path_from_dentry(direntry);
 	if (full_path == NULL) {
 		rc = -ENOMEM;
@@ -467,7 +477,7 @@  cifs_create_set_dentry:
 		CIFSSMBClose(xid, tcon, fileHandle);
 	} else if (!(posix_create) && (newinode)) {
 			cifs_new_fileinfo(newinode, fileHandle, NULL,
-						nd->path.mnt, oflags);
+					  nd->path.mnt, tcon, oflags);
 	}
 cifs_create_out:
 	kfree(buf);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 651dde4..26665b8 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -269,6 +269,10 @@  int cifs_open(struct inode *inode, struct file *file)
 
 	cifs_sb = CIFS_SB(inode->i_sb);
 	tcon = cifs_sb_tcon(cifs_sb);
+	if (IS_ERR(tcon)) {
+		FreeXid(xid);
+		return PTR_ERR(tcon);
+	}
 
 	pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
 	pCifsFile = cifs_fill_filedata(file);
@@ -391,7 +395,7 @@  int cifs_open(struct inode *inode, struct file *file)
 	}
 
 	pCifsFile = cifs_new_fileinfo(inode, netfid, file, file->f_path.mnt,
-					file->f_flags);
+				      tcon, file->f_flags);
 	file->private_data = pCifsFile;
 	if (file->private_data == NULL) {
 		rc = -ENOMEM;