From: Jeff Layton <jlayton@samba.org>
To: linux-cifs-client@lists.samba.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 11/15] cifs: have cifs_new_fileinfo take a tcon arg
Date: Tue, 30 Mar 2010 15:51:13 -0400 [thread overview]
Message-ID: <1269978677-6817-12-git-send-email-jlayton@samba.org> (raw)
In-Reply-To: <1269978677-6817-1-git-send-email-jlayton@samba.org>
From: Jeff Layton <jlayton@redhat.com>
To minimize calls to cifs_sb_tcon and to allow for a clear error path if
a tcon can't be acquired.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
fs/cifs/dir.c | 26 ++++++++++++++++++--------
fs/cifs/file.c | 6 +++++-
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index dbc6b97..3467626 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 8285d14..308520e 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -268,6 +268,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);
@@ -390,7 +394,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;
--
1.6.6.1
next prev parent reply other threads:[~2010-03-30 19:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-30 19:51 [PATCH 00/15] cifs: implement multisession mounts (RFC) Jeff Layton
2010-03-30 19:51 ` [PATCH 01/15] cifs: remove unused list_head from cifs_sb_info Jeff Layton
2010-03-30 19:51 ` [PATCH 02/15] cifs: add function to get a tcon from cifs_sb Jeff Layton
2010-03-30 19:51 ` [PATCH 03/15] cifs: track local_nls in volume info Jeff Layton
2010-03-30 19:51 ` [PATCH 04/15] cifs: move SMB session creation code into separate function Jeff Layton
2010-03-30 19:51 ` [PATCH 05/15] cifs: move tcon find/create " Jeff Layton
2010-03-30 19:51 ` [PATCH 06/15] cifs: add tcon field to cifsFileInfo struct Jeff Layton
2010-03-30 19:51 ` [PATCH 07/15] cifs: make various routines use the cifsFileInfo->tcon pointer Jeff Layton
2010-03-30 19:51 ` [PATCH 08/15] cifs: have find_readable/writable_file filter by fsuid Jeff Layton
2010-03-30 19:51 ` [PATCH 09/15] cifs: fix cifs_show_options to show "username=" or "multises" Jeff Layton
2010-03-30 19:51 ` [PATCH 10/15] cifs: move secType to the SMB session Jeff Layton
2010-03-30 19:51 ` Jeff Layton [this message]
2010-03-30 19:51 ` [PATCH 12/15] cifs: build sessions and tcons on the fly Jeff Layton
2010-03-30 19:51 ` [PATCH 13/15] cifs: on multises mount, set ownership to current_fsuid/current_fsgid Jeff Layton
2010-03-30 19:51 ` [PATCH 14/15] cifs: add "multises" mount option Jeff Layton
2010-03-30 19:51 ` [PATCH 15/15] cifs: temporary hack -- set secType to Kerberos Jeff Layton
2010-03-31 12:18 ` [PATCH 00/15] cifs: implement multisession mounts (RFC) Jamie Lokier
2010-03-31 13:42 ` Jeff Layton
2010-03-31 16:43 ` Jeremy Allison
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1269978677-6817-12-git-send-email-jlayton@samba.org \
--to=jlayton@samba.org \
--cc=linux-cifs-client@lists.samba.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).