From: Jeff Layton <jlayton@redhat.com>
To: linux-cifs-client@lists.samba.org, linux-fsdevel@vger.kernel.org
Cc: smfrench@gmail.com
Subject: [PATCH 06/11] cifs: have cifs_new_fileinfo take a tcon arg
Date: Tue, 20 Apr 2010 16:07:14 -0400 [thread overview]
Message-ID: <1271794039-22787-7-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1271794039-22787-1-git-send-email-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 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;
--
1.6.6.1
next prev parent reply other threads:[~2010-04-20 20:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-20 20:07 [PATCH 00/11] cifs: implement multisession mounts (try #2) Jeff Layton
2010-04-20 20:07 ` [PATCH 01/11] cifs: add function to get a tcon from cifs_sb Jeff Layton
2010-04-20 20:07 ` [PATCH 02/11] cifs: add tcon field to cifsFileInfo struct Jeff Layton
2010-04-20 20:07 ` [PATCH 03/11] cifs: make various routines use the cifsFileInfo->tcon pointer Jeff Layton
2010-04-20 20:07 ` [PATCH 04/11] cifs: have find_readable/writable_file filter by fsuid Jeff Layton
2010-04-20 20:07 ` [PATCH 05/11] cifs: fix cifs_show_options to show "username=" or "multises" Jeff Layton
2010-04-20 20:07 ` Jeff Layton [this message]
2010-04-20 20:07 ` [PATCH 07/11] cifs: allow for cifs_sb_tcon() to return an error Jeff Layton
2010-04-20 20:07 ` [PATCH 08/11] cifs: fix handling of signing with writepages Jeff Layton
2010-04-20 20:07 ` [PATCH 09/11] cifs: add routines to build sessions and tcons on the fly Jeff Layton
2010-04-20 20:07 ` [PATCH 10/11] cifs: on multises mount, set ownership to current_fsuid/current_fsgid Jeff Layton
2010-04-20 20:07 ` [PATCH 11/11] cifs: add "multises" mount option Jeff Layton
2010-04-21 2:42 ` [PATCH 00/11] cifs: implement multisession mounts (try #2) Steve French
2010-04-21 14:16 ` Stef Bon
2010-04-21 18:13 ` [linux-cifs-client] " Jeff Layton
2010-04-22 14:56 ` Stef Bon
2010-04-22 15:39 ` Jamie Lokier
2010-04-22 16:57 ` Steve French
2010-04-24 2:30 ` [linux-cifs-client] " Jamie Lokier
2010-04-22 19:25 ` Jeff Layton
2010-04-22 19:55 ` Steve French
2010-04-24 2:26 ` [linux-cifs-client] " Jamie Lokier
2010-04-22 17:51 ` Jeff Layton
2010-04-22 19:55 ` Stef Bon
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=1271794039-22787-7-git-send-email-jlayton@redhat.com \
--to=jlayton@redhat.com \
--cc=linux-cifs-client@lists.samba.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=smfrench@gmail.com \
/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).