From: Jeff Layton <jlayton@samba.org>
To: linux-cifs-client@lists.samba.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 05/15] cifs: move tcon find/create into separate function
Date: Tue, 30 Mar 2010 15:51:07 -0400 [thread overview]
Message-ID: <1269978677-6817-6-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>
...and out of cifs_mount.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
fs/cifs/connect.c | 156 +++++++++++++++++++++++++++++------------------------
1 files changed, 86 insertions(+), 70 deletions(-)
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 81b695d..9dc817d 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1749,6 +1749,7 @@ cifs_put_tcon(struct cifsTconInfo *tcon)
int xid;
struct cifsSesInfo *ses = tcon->ses;
+ cFYI(1, ("%s: tc_count=%d\n", __func__, tcon->tc_count));
write_lock(&cifs_tcp_ses_lock);
if (--tcon->tc_count > 0) {
write_unlock(&cifs_tcp_ses_lock);
@@ -1766,6 +1767,80 @@ cifs_put_tcon(struct cifsTconInfo *tcon)
cifs_put_smb_ses(ses);
}
+static struct cifsTconInfo *
+cifs_get_tcon(struct cifsSesInfo *ses, struct smb_vol *volume_info)
+{
+ int rc, xid;
+ struct cifsTconInfo *tcon;
+
+ tcon = cifs_find_tcon(ses, volume_info->UNC);
+ if (tcon) {
+ cFYI(1, ("Found match on UNC path"));
+ /* existing tcon already has a reference */
+ cifs_put_smb_ses(ses);
+ if (tcon->seal != volume_info->seal)
+ cERROR(1, ("transport encryption setting "
+ "conflicts with existing tid"));
+ return tcon;
+ }
+
+ tcon = tconInfoAlloc();
+ if (tcon == NULL) {
+ rc = -ENOMEM;
+ goto out_fail;
+ }
+
+ tcon->ses = ses;
+ if (volume_info->password) {
+ tcon->password = kstrdup(volume_info->password, GFP_KERNEL);
+ if (!tcon->password) {
+ rc = -ENOMEM;
+ goto out_fail;
+ }
+ }
+
+ if ((strchr(volume_info->UNC + 3, '\\') == NULL)
+ && (strchr(volume_info->UNC + 3, '/') == NULL)) {
+ cERROR(1, ("Missing share name"));
+ rc = -ENODEV;
+ goto out_fail;
+ }
+
+ /* BB Do we need to wrap session_mutex around
+ * this TCon call and Unix SetFS as
+ * we do on SessSetup and reconnect? */
+ xid = GetXid();
+ rc = CIFSTCon(xid, ses, volume_info->UNC, tcon, volume_info->local_nls);
+ FreeXid(xid);
+ cFYI(1, ("CIFS Tcon rc = %d", rc));
+ if (rc)
+ goto out_fail;
+
+ if (volume_info->nodfs) {
+ tcon->Flags &= ~SMB_SHARE_IS_IN_DFS;
+ cFYI(1, ("DFS disabled (%d)", tcon->Flags));
+ }
+ tcon->seal = volume_info->seal;
+ /* we can have only one retry value for a connection
+ to a share so for resources mounted more than once
+ to the same server share the last value passed in
+ for the retry flag is used */
+ tcon->retry = volume_info->retry;
+ tcon->nocase = volume_info->nocase;
+ tcon->local_lease = volume_info->local_lease;
+
+ write_lock(&cifs_tcp_ses_lock);
+ list_add(&tcon->tcon_list, &ses->tcon_list);
+ write_unlock(&cifs_tcp_ses_lock);
+
+ return tcon;
+
+out_fail:
+ tconInfoFree(tcon);
+ return ERR_PTR(rc);
+}
+
+
int
get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path,
const struct nls_table *nls_codepage, unsigned int *pnum_referrals,
@@ -2474,81 +2549,22 @@ try_mount_again:
goto mount_fail_check;
}
- /* search for existing tcon to this server share */
- if (!rc) {
- setup_cifs_sb(volume_info, cifs_sb);
-
- tcon = cifs_find_tcon(pSesInfo, volume_info->UNC);
- if (tcon) {
- cFYI(1, ("Found match on UNC path"));
- /* existing tcon already has a reference */
- cifs_put_smb_ses(pSesInfo);
- if (tcon->seal != volume_info->seal)
- cERROR(1, ("transport encryption setting "
- "conflicts with existing tid"));
- } else {
- tcon = tconInfoAlloc();
- if (tcon == NULL) {
- rc = -ENOMEM;
- goto mount_fail_check;
- }
-
- tcon->ses = pSesInfo;
- if (volume_info->password) {
- tcon->password = kstrdup(volume_info->password,
- GFP_KERNEL);
- if (!tcon->password) {
- rc = -ENOMEM;
- goto mount_fail_check;
- }
- }
-
- if ((strchr(volume_info->UNC + 3, '\\') == NULL)
- && (strchr(volume_info->UNC + 3, '/') == NULL)) {
- cERROR(1, ("Missing share name"));
- rc = -ENODEV;
- goto mount_fail_check;
- } else {
- /* BB Do we need to wrap sesSem around
- * this TCon call and Unix SetFS as
- * we do on SessSetup and reconnect? */
- rc = CIFSTCon(xid, pSesInfo, volume_info->UNC,
- tcon, cifs_sb->local_nls);
- cFYI(1, ("CIFS Tcon rc = %d", rc));
- if (volume_info->nodfs) {
- tcon->Flags &= ~SMB_SHARE_IS_IN_DFS;
- cFYI(1, ("DFS disabled (%d)",
- tcon->Flags));
- }
- }
- if (rc)
- goto remote_path_check;
- tcon->seal = volume_info->seal;
- write_lock(&cifs_tcp_ses_lock);
- list_add(&tcon->tcon_list, &pSesInfo->tcon_list);
- write_unlock(&cifs_tcp_ses_lock);
- }
-
- /* we can have only one retry value for a connection
- to a share so for resources mounted more than once
- to the same server share the last value passed in
- for the retry flag is used */
- tcon->retry = volume_info->retry;
- tcon->nocase = volume_info->nocase;
- tcon->local_lease = volume_info->local_lease;
- }
- if (pSesInfo) {
- if (pSesInfo->capabilities & CAP_LARGE_FILES)
- sb->s_maxbytes = MAX_LFS_FILESIZE;
- else
- sb->s_maxbytes = MAX_NON_LFS;
- }
+ setup_cifs_sb(volume_info, cifs_sb);
+ if (pSesInfo->capabilities & CAP_LARGE_FILES)
+ sb->s_maxbytes = MAX_LFS_FILESIZE;
+ else
+ sb->s_maxbytes = MAX_NON_LFS;
/* BB FIXME fix time_gran to be larger for LANMAN sessions */
sb->s_time_gran = 100;
- if (rc)
+ /* search for existing tcon to this server share */
+ tcon = cifs_get_tcon(pSesInfo, volume_info);
+ if (IS_ERR(tcon)) {
+ rc = PTR_ERR(tcon);
+ tcon = NULL;
goto remote_path_check;
+ }
cifs_sb->tcon = tcon;
--
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 ` Jeff Layton [this message]
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 ` [PATCH 11/15] cifs: have cifs_new_fileinfo take a tcon arg Jeff Layton
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-6-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).