[CIFS] Fix cifs reconnection flags

In preparation for Jeff's big umount/mount fixes to remove the possibility of
various races in cifs mount and linked list handling of sessions, sockets and
tree connections, this patch cleans up some repetitive code in cifs_mount,
and addresses a problem with ses->status and tcon->tidStatus in which we
were overloading the "need_reconnect" state with other status in that
field.  So the "need_reconnect" flag has been broken out from those
two state fields (need reconnect was not mutually exclusive from some of the
other possible tid and ses states).  In addition, a few exit cases in
cifs_mount were cleaned up, and a problem with a tcon flag (for lease support)
was not being set consistently for the 2nd mount of the same share

CC: Jeff Layton <jlayton@redhat.com>
CC: Shirish Pargaonkar <shirishp@us.ibm.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
Steve French 2008-11-13 19:45:32 +00:00
parent c527c8a7ff
commit 3b79521093
5 changed files with 159 additions and 150 deletions

View file

@ -1013,7 +1013,7 @@ static int cifs_oplock_thread(void *dummyarg)
not bother sending an oplock release if session not bother sending an oplock release if session
to server still is disconnected since oplock to server still is disconnected since oplock
already released by the server in that case */ already released by the server in that case */
if (pTcon->tidStatus != CifsNeedReconnect) { if (!pTcon->need_reconnect) {
rc = CIFSSMBLock(0, pTcon, netfid, rc = CIFSSMBLock(0, pTcon, netfid,
0 /* len */ , 0 /* offset */, 0, 0 /* len */ , 0 /* offset */, 0,
0, LOCKING_ANDX_OPLOCK_RELEASE, 0, LOCKING_ANDX_OPLOCK_RELEASE,

View file

@ -122,6 +122,8 @@ struct cifs_cred {
*/ */
struct TCP_Server_Info { struct TCP_Server_Info {
struct list_head tcp_ses_list;
struct list_head smb_ses_list;
/* 15 character server name + 0x20 16th byte indicating type = srv */ /* 15 character server name + 0x20 16th byte indicating type = srv */
char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL]; char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL];
char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2]; char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2];
@ -195,6 +197,7 @@ struct cifsUidInfo {
*/ */
struct cifsSesInfo { struct cifsSesInfo {
struct list_head cifsSessionList; struct list_head cifsSessionList;
struct list_head tcon_list;
struct semaphore sesSem; struct semaphore sesSem;
#if 0 #if 0
struct cifsUidInfo *uidInfo; /* pointer to user info */ struct cifsUidInfo *uidInfo; /* pointer to user info */
@ -216,6 +219,7 @@ struct cifsSesInfo {
char userName[MAX_USERNAME_SIZE + 1]; char userName[MAX_USERNAME_SIZE + 1];
char *domainName; char *domainName;
char *password; char *password;
bool need_reconnect:1; /* connection reset, uid now invalid */
}; };
/* no more than one of the following three session flags may be set */ /* no more than one of the following three session flags may be set */
#define CIFS_SES_NT4 1 #define CIFS_SES_NT4 1
@ -288,6 +292,7 @@ struct cifsTconInfo {
bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol
for this mount even if server would support */ for this mount even if server would support */
bool local_lease:1; /* check leases (only) on local system not remote */ bool local_lease:1; /* check leases (only) on local system not remote */
bool need_reconnect:1; /* connection reset, tid now invalid */
/* BB add field for back pointer to sb struct(s)? */ /* BB add field for back pointer to sb struct(s)? */
}; };

View file

@ -190,10 +190,10 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
/* need to prevent multiple threads trying to /* need to prevent multiple threads trying to
simultaneously reconnect the same SMB session */ simultaneously reconnect the same SMB session */
down(&tcon->ses->sesSem); down(&tcon->ses->sesSem);
if (tcon->ses->status == CifsNeedReconnect) if (tcon->ses->need_reconnect)
rc = cifs_setup_session(0, tcon->ses, rc = cifs_setup_session(0, tcon->ses,
nls_codepage); nls_codepage);
if (!rc && (tcon->tidStatus == CifsNeedReconnect)) { if (!rc && (tcon->need_reconnect)) {
mark_open_files_invalid(tcon); mark_open_files_invalid(tcon);
rc = CIFSTCon(0, tcon->ses, tcon->treeName, rc = CIFSTCon(0, tcon->ses, tcon->treeName,
tcon, nls_codepage); tcon, nls_codepage);
@ -295,7 +295,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
check for tcp and smb session status done differently check for tcp and smb session status done differently
for those three - in the calling routine */ for those three - in the calling routine */
if (tcon) { if (tcon) {
if (tcon->tidStatus == CifsExiting) { if (tcon->need_reconnect) {
/* only tree disconnect, open, and write, /* only tree disconnect, open, and write,
(and ulogoff which does not have tcon) (and ulogoff which does not have tcon)
are allowed as we start force umount */ are allowed as we start force umount */
@ -337,10 +337,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
/* need to prevent multiple threads trying to /* need to prevent multiple threads trying to
simultaneously reconnect the same SMB session */ simultaneously reconnect the same SMB session */
down(&tcon->ses->sesSem); down(&tcon->ses->sesSem);
if (tcon->ses->status == CifsNeedReconnect) if (tcon->ses->need_reconnect)
rc = cifs_setup_session(0, tcon->ses, rc = cifs_setup_session(0, tcon->ses,
nls_codepage); nls_codepage);
if (!rc && (tcon->tidStatus == CifsNeedReconnect)) { if (!rc && (tcon->need_reconnect)) {
mark_open_files_invalid(tcon); mark_open_files_invalid(tcon);
rc = CIFSTCon(0, tcon->ses, tcon->treeName, rc = CIFSTCon(0, tcon->ses, tcon->treeName,
tcon, nls_codepage); tcon, nls_codepage);
@ -759,7 +759,7 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
/* No need to return error on this operation if tid invalidated and /* No need to return error on this operation if tid invalidated and
closed on server already e.g. due to tcp session crashing */ closed on server already e.g. due to tcp session crashing */
if (tcon->tidStatus == CifsNeedReconnect) { if (tcon->need_reconnect) {
up(&tcon->tconSem); up(&tcon->tconSem);
return 0; return 0;
} }
@ -806,32 +806,36 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
up(&ses->sesSem); up(&ses->sesSem);
return -EBUSY; return -EBUSY;
} }
if (ses->server == NULL)
return -EIO;
if (ses->need_reconnect)
goto session_already_dead; /* no need to send SMBlogoff if uid
already closed due to reconnect */
rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB); rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB);
if (rc) { if (rc) {
up(&ses->sesSem); up(&ses->sesSem);
return rc; return rc;
} }
if (ses->server) { pSMB->hdr.Mid = GetNextMid(ses->server);
pSMB->hdr.Mid = GetNextMid(ses->server);
if (ses->server->secMode & if (ses->server->secMode &
(SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
}
pSMB->hdr.Uid = ses->Suid; pSMB->hdr.Uid = ses->Suid;
pSMB->AndXCommand = 0xFF; pSMB->AndXCommand = 0xFF;
rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0); rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0);
if (ses->server) { session_already_dead:
atomic_dec(&ses->server->socketUseCount); atomic_dec(&ses->server->socketUseCount);
if (atomic_read(&ses->server->socketUseCount) == 0) { if (atomic_read(&ses->server->socketUseCount) == 0) {
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
ses->server->tcpStatus = CifsExiting; ses->server->tcpStatus = CifsExiting;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
rc = -ESHUTDOWN; rc = -ESHUTDOWN;
}
} }
up(&ses->sesSem); up(&ses->sesSem);

View file

@ -149,7 +149,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
if (ses->server) { if (ses->server) {
if (ses->server == server) { if (ses->server == server) {
ses->status = CifsNeedReconnect; ses->need_reconnect = true;
ses->ipc_tid = 0; ses->ipc_tid = 0;
} }
} }
@ -158,7 +158,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
list_for_each(tmp, &GlobalTreeConnectionList) { list_for_each(tmp, &GlobalTreeConnectionList) {
tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
if ((tcon->ses) && (tcon->ses->server == server)) if ((tcon->ses) && (tcon->ses->server == server))
tcon->tidStatus = CifsNeedReconnect; tcon->need_reconnect = true;
} }
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
/* do not want to be sending data on a socket we are freeing */ /* do not want to be sending data on a socket we are freeing */
@ -1891,6 +1891,92 @@ kill_cifsd(struct TCP_Server_Info *server)
force_sig(SIGKILL, task); force_sig(SIGKILL, task);
} }
static void setup_cifs_sb(struct smb_vol *pvolume_info,
struct cifs_sb_info *cifs_sb)
{
if (pvolume_info->rsize > CIFSMaxBufSize) {
cERROR(1, ("rsize %d too large, using MaxBufSize",
pvolume_info->rsize));
cifs_sb->rsize = CIFSMaxBufSize;
} else if ((pvolume_info->rsize) &&
(pvolume_info->rsize <= CIFSMaxBufSize))
cifs_sb->rsize = pvolume_info->rsize;
else /* default */
cifs_sb->rsize = CIFSMaxBufSize;
if (pvolume_info->wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) {
cERROR(1, ("wsize %d too large, using 4096 instead",
pvolume_info->wsize));
cifs_sb->wsize = 4096;
} else if (pvolume_info->wsize)
cifs_sb->wsize = pvolume_info->wsize;
else
cifs_sb->wsize = min_t(const int,
PAGEVEC_SIZE * PAGE_CACHE_SIZE,
127*1024);
/* old default of CIFSMaxBufSize was too small now
that SMB Write2 can send multiple pages in kvec.
RFC1001 does not describe what happens when frame
bigger than 128K is sent so use that as max in
conjunction with 52K kvec constraint on arch with 4K
page size */
if (cifs_sb->rsize < 2048) {
cifs_sb->rsize = 2048;
/* Windows ME may prefer this */
cFYI(1, ("readsize set to minimum: 2048"));
}
/* calculate prepath */
cifs_sb->prepath = pvolume_info->prepath;
if (cifs_sb->prepath) {
cifs_sb->prepathlen = strlen(cifs_sb->prepath);
/* we can not convert the / to \ in the path
separators in the prefixpath yet because we do not
know (until reset_cifs_unix_caps is called later)
whether POSIX PATH CAP is available. We normalize
the / to \ after reset_cifs_unix_caps is called */
pvolume_info->prepath = NULL;
} else
cifs_sb->prepathlen = 0;
cifs_sb->mnt_uid = pvolume_info->linux_uid;
cifs_sb->mnt_gid = pvolume_info->linux_gid;
cifs_sb->mnt_file_mode = pvolume_info->file_mode;
cifs_sb->mnt_dir_mode = pvolume_info->dir_mode;
cFYI(1, ("file mode: 0x%x dir mode: 0x%x",
cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode));
if (pvolume_info->noperm)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
if (pvolume_info->setuids)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;
if (pvolume_info->server_ino)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;
if (pvolume_info->remap)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR;
if (pvolume_info->no_xattr)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR;
if (pvolume_info->sfu_emul)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL;
if (pvolume_info->nobrl)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;
if (pvolume_info->cifs_acl)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
if (pvolume_info->override_uid)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
if (pvolume_info->override_gid)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID;
if (pvolume_info->dynperm)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM;
if (pvolume_info->direct_io) {
cFYI(1, ("mounting share using direct i/o"));
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
}
if ((pvolume_info->cifs_acl) && (pvolume_info->dynperm))
cERROR(1, ("mount option dynperm ignored if cifsacl "
"mount option supported"));
}
int int
cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
char *mount_data, const char *devname) char *mount_data, const char *devname)
@ -1996,9 +2082,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
goto out; goto out;
} }
if (srvTcp) { if (!srvTcp) { /* create socket */
cFYI(1, ("Existing tcp session with server found"));
} else { /* create socket */
if (volume_info.port) if (volume_info.port)
sin_server.sin_port = htons(volume_info.port); sin_server.sin_port = htons(volume_info.port);
else else
@ -2074,7 +2158,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
cFYI(1, ("Existing smb sess found (status=%d)", cFYI(1, ("Existing smb sess found (status=%d)",
pSesInfo->status)); pSesInfo->status));
down(&pSesInfo->sesSem); down(&pSesInfo->sesSem);
if (pSesInfo->status == CifsNeedReconnect) { if (pSesInfo->need_reconnect) {
cFYI(1, ("Session needs reconnect")); cFYI(1, ("Session needs reconnect"));
rc = cifs_setup_session(xid, pSesInfo, rc = cifs_setup_session(xid, pSesInfo,
cifs_sb->local_nls); cifs_sb->local_nls);
@ -2124,146 +2208,59 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
/* search for existing tcon to this server share */ /* search for existing tcon to this server share */
if (!rc) { if (!rc) {
if (volume_info.rsize > CIFSMaxBufSize) { setup_cifs_sb(&volume_info, cifs_sb);
cERROR(1, ("rsize %d too large, using MaxBufSize",
volume_info.rsize));
cifs_sb->rsize = CIFSMaxBufSize;
} else if ((volume_info.rsize) &&
(volume_info.rsize <= CIFSMaxBufSize))
cifs_sb->rsize = volume_info.rsize;
else /* default */
cifs_sb->rsize = CIFSMaxBufSize;
if (volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) {
cERROR(1, ("wsize %d too large, using 4096 instead",
volume_info.wsize));
cifs_sb->wsize = 4096;
} else if (volume_info.wsize)
cifs_sb->wsize = volume_info.wsize;
else
cifs_sb->wsize =
min_t(const int, PAGEVEC_SIZE * PAGE_CACHE_SIZE,
127*1024);
/* old default of CIFSMaxBufSize was too small now
that SMB Write2 can send multiple pages in kvec.
RFC1001 does not describe what happens when frame
bigger than 128K is sent so use that as max in
conjunction with 52K kvec constraint on arch with 4K
page size */
if (cifs_sb->rsize < 2048) {
cifs_sb->rsize = 2048;
/* Windows ME may prefer this */
cFYI(1, ("readsize set to minimum: 2048"));
}
/* calculate prepath */
cifs_sb->prepath = volume_info.prepath;
if (cifs_sb->prepath) {
cifs_sb->prepathlen = strlen(cifs_sb->prepath);
/* we can not convert the / to \ in the path
separators in the prefixpath yet because we do not
know (until reset_cifs_unix_caps is called later)
whether POSIX PATH CAP is available. We normalize
the / to \ after reset_cifs_unix_caps is called */
volume_info.prepath = NULL;
} else
cifs_sb->prepathlen = 0;
cifs_sb->mnt_uid = volume_info.linux_uid;
cifs_sb->mnt_gid = volume_info.linux_gid;
cifs_sb->mnt_file_mode = volume_info.file_mode;
cifs_sb->mnt_dir_mode = volume_info.dir_mode;
cFYI(1, ("file mode: 0x%x dir mode: 0x%x",
cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode));
if (volume_info.noperm)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
if (volume_info.setuids)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;
if (volume_info.server_ino)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;
if (volume_info.remap)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR;
if (volume_info.no_xattr)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR;
if (volume_info.sfu_emul)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL;
if (volume_info.nobrl)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;
if (volume_info.cifs_acl)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
if (volume_info.override_uid)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
if (volume_info.override_gid)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID;
if (volume_info.dynperm)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM;
if (volume_info.direct_io) {
cFYI(1, ("mounting share using direct i/o"));
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
}
if ((volume_info.cifs_acl) && (volume_info.dynperm))
cERROR(1, ("mount option dynperm ignored if cifsacl "
"mount option supported"));
tcon = tcon =
find_unc(sin_server.sin_addr.s_addr, volume_info.UNC, find_unc(sin_server.sin_addr.s_addr, volume_info.UNC,
volume_info.username); volume_info.username);
if (tcon) { if (tcon) {
cFYI(1, ("Found match on UNC path")); cFYI(1, ("Found match on UNC path"));
/* 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 (tcon->seal != volume_info.seal) if (tcon->seal != volume_info.seal)
cERROR(1, ("transport encryption setting " cERROR(1, ("transport encryption setting "
"conflicts with existing tid")); "conflicts with existing tid"));
} else { } else {
tcon = tconInfoAlloc(); tcon = tconInfoAlloc();
if (tcon == NULL) if (tcon == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
else { goto mount_fail_check;
/* check for null share name ie connecting to }
* dfs root */
/* BB check if this works for exactly length /* check for null share name ie connect to dfs root */
* three strings */
if ((strchr(volume_info.UNC + 3, '\\') == NULL) /* BB check if works for exactly length 3 strings */
&& (strchr(volume_info.UNC + 3, '/') == if ((strchr(volume_info.UNC + 3, '\\') == NULL)
NULL)) { && (strchr(volume_info.UNC + 3, '/') == NULL)) {
/* rc = connect_to_dfs_path(xid, pSesInfo, /* rc = connect_to_dfs_path(...) */
"", cifs_sb->local_nls, cFYI(1, ("DFS root not supported"));
cifs_sb->mnt_cifs_flags & rc = -ENODEV;
CIFS_MOUNT_MAP_SPECIAL_CHR);*/ goto mount_fail_check;
cFYI(1, ("DFS root not supported")); } else {
rc = -ENODEV; /* BB Do we need to wrap sesSem around
goto out; * this TCon call and Unix SetFS as
} else { * we do on SessSetup and reconnect? */
/* BB Do we need to wrap sesSem around rc = CIFSTCon(xid, pSesInfo, volume_info.UNC,
* this TCon call and Unix SetFS as tcon, cifs_sb->local_nls);
* we do on SessSetup and reconnect? */ cFYI(1, ("CIFS Tcon rc = %d", rc));
rc = CIFSTCon(xid, pSesInfo, if (volume_info.nodfs) {
volume_info.UNC, tcon->Flags &= ~SMB_SHARE_IS_IN_DFS;
tcon, cifs_sb->local_nls); cFYI(1, ("DFS disabled (%d)",
cFYI(1, ("CIFS Tcon rc = %d", rc)); tcon->Flags));
if (volume_info.nodfs) {
tcon->Flags &=
~SMB_SHARE_IS_IN_DFS;
cFYI(1, ("DFS disabled (%d)",
tcon->Flags));
}
}
if (!rc) {
atomic_inc(&pSesInfo->inUse);
tcon->retry = volume_info.retry;
tcon->nocase = volume_info.nocase;
tcon->seal = volume_info.seal;
} }
} }
if (!rc) {
atomic_inc(&pSesInfo->inUse);
tcon->seal = volume_info.seal;
} else
goto mount_fail_check;
} }
/* 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) {
if (pSesInfo->capabilities & CAP_LARGE_FILES) { if (pSesInfo->capabilities & CAP_LARGE_FILES) {
@ -2276,6 +2273,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
sb->s_time_gran = 100; sb->s_time_gran = 100;
/* on error free sesinfo and tcon struct if needed */ /* on error free sesinfo and tcon struct if needed */
mount_fail_check:
if (rc) { if (rc) {
/* if session setup failed, use count is zero but /* if session setup failed, use count is zero but
we still need to free cifsd thread */ we still need to free cifsd thread */
@ -3518,6 +3516,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
/* above now done in SendReceive */ /* above now done in SendReceive */
if ((rc == 0) && (tcon != NULL)) { if ((rc == 0) && (tcon != NULL)) {
tcon->tidStatus = CifsGood; tcon->tidStatus = CifsGood;
tcon->need_reconnect = false;
tcon->tid = smb_buffer_response->Tid; tcon->tid = smb_buffer_response->Tid;
bcc_ptr = pByteArea(smb_buffer_response); bcc_ptr = pByteArea(smb_buffer_response);
length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2);
@ -3746,6 +3745,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
cFYI(1, ("CIFS Session Established successfully")); cFYI(1, ("CIFS Session Established successfully"));
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
pSesInfo->status = CifsGood; pSesInfo->status = CifsGood;
pSesInfo->need_reconnect = false;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
} }

View file

@ -493,7 +493,7 @@ int cifs_close(struct inode *inode, struct file *file)
if (pTcon) { if (pTcon) {
/* no sense reconnecting to close a file that is /* no sense reconnecting to close a file that is
already closed */ already closed */
if (pTcon->tidStatus != CifsNeedReconnect) { if (!pTcon->need_reconnect) {
timeout = 2; timeout = 2;
while ((atomic_read(&pSMBFile->wrtPending) != 0) while ((atomic_read(&pSMBFile->wrtPending) != 0)
&& (timeout <= 2048)) { && (timeout <= 2048)) {