diff options
Diffstat (limited to 'fs/smb/client/connect.c')
-rw-r--r-- | fs/smb/client/connect.c | 100 |
1 files changed, 34 insertions, 66 deletions
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 89bd1b71ba2e..7dc9ea6cceb7 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -416,7 +416,7 @@ static int __cifs_reconnect(struct TCP_Server_Info *server, msleep(3000); } else { atomic_inc(&tcpSesReconnectCount); - set_credits(server, 1); + smb2_set_credits(server, 1); spin_lock(&server->srv_lock); if (server->tcpStatus != CifsExiting) server->tcpStatus = CifsNeedNegotiate; @@ -547,7 +547,7 @@ static int reconnect_dfs_server(struct TCP_Server_Info *server) * through the reconnected target server. */ atomic_inc(&tcpSesReconnectCount); - set_credits(server, 1); + smb2_set_credits(server, 1); spin_lock(&server->srv_lock); if (server->tcpStatus != CifsExiting) server->tcpStatus = CifsNeedNegotiate; @@ -605,11 +605,11 @@ cifs_echo_request(struct work_struct *work) if (server->tcpStatus == CifsNeedReconnect || server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew || - (server->ops->can_echo && !server->ops->can_echo(server)) || + (!smb2_can_echo(server)) || time_before(jiffies, server->lstrp + server->echo_interval - HZ)) goto requeue_echo; - rc = server->ops->echo ? server->ops->echo(server) : -ENOSYS; + rc = SMB2_echo(server); cifs_server_dbg(FYI, "send echo request: rc = %d\n", rc); /* Check witness registrations */ @@ -681,7 +681,7 @@ server_unresponsive(struct TCP_Server_Info *server) */ if ((server->tcpStatus == CifsGood || server->tcpStatus == CifsNeedNegotiate) && - (!server->ops->can_echo || server->ops->can_echo(server)) && + smb2_can_echo(server) && time_after(jiffies, server->lstrp + 3 * server->echo_interval)) { spin_unlock(&server->srv_lock); cifs_server_dbg(VFS, "has not responded in %lu seconds. Reconnecting...\n", @@ -899,9 +899,6 @@ static void handle_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server, char *buf, int malformed) { - if (server->ops->check_trans2 && - server->ops->check_trans2(mid, server, buf, malformed)) - return; mid->credits_received = smb2_get_credits_from_hdr(buf, server); mid->resp_buf = buf; mid->large_buf = server->large_buf; @@ -1104,19 +1101,17 @@ cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid) * 48 bytes is enough to display the header and a little bit * into the payload for debugging purposes. */ - rc = server->ops->check_message(buf, server->total_read, server); + rc = smb2_check_message(buf, server->total_read, server); if (rc) cifs_dump_mem("Bad SMB: ", buf, min_t(unsigned int, server->total_read, 48)); - if (server->ops->is_session_expired && - server->ops->is_session_expired(buf)) { + if (smb2_is_session_expired(buf)) { cifs_reconnect(server, true); return -1; } - if (server->ops->is_status_pending && - server->ops->is_status_pending(buf, server)) + if (smb2_is_status_pending(buf, server)) return -1; if (!mid) @@ -1220,16 +1215,14 @@ next_pdu: continue; server->total_read += length; - if (server->ops->next_header) { - if (server->ops->next_header(server, buf, &next_offset)) { - cifs_dbg(VFS, "%s: malformed response (next_offset=%u)\n", - __func__, next_offset); - cifs_reconnect(server, true); - continue; - } - if (next_offset) - server->pdu_size = next_offset; + if (smb2_next_header(server, buf, &next_offset)) { + cifs_dbg(VFS, "%s: malformed response (next_offset=%u)\n", + __func__, next_offset); + cifs_reconnect(server, true); + continue; } + if (next_offset) + server->pdu_size = next_offset; memset(mids, 0, sizeof(mids)); memset(bufs, 0, sizeof(bufs)); @@ -1243,7 +1236,7 @@ next_pdu: bufs, &num_mids); } else { - mids[0] = server->ops->find_mid(server, buf); + mids[0] = smb2_find_mid(server, buf); bufs[0] = buf; num_mids = 1; @@ -1260,8 +1253,7 @@ next_pdu: continue; } - if (server->ops->is_status_io_timeout && - server->ops->is_status_io_timeout(buf)) { + if (smb2_is_status_io_timeout(buf)) { num_io_timeout++; if (num_io_timeout > MAX_STATUS_IO_TIMEOUT) { cifs_server_dbg(VFS, @@ -1280,11 +1272,8 @@ next_pdu: mids[i]->resp_buf_size = server->pdu_size; if (bufs[i] != NULL) { - if (server->ops->is_network_name_deleted && - server->ops->is_network_name_deleted(bufs[i], - server)) { - cifs_server_dbg(FYI, - "Share deleted. Reconnect needed"); + if (smb2_is_network_name_deleted(bufs[i], server)) { + cifs_server_dbg(FYI, "Share deleted. Reconnect needed"); } } @@ -1292,9 +1281,7 @@ next_pdu: mids[i]->callback(mids[i]); release_mid(mids[i]); - } else if (server->ops->is_oplock_break && - server->ops->is_oplock_break(bufs[i], - server)) { + } else if (smb2_is_valid_oplock_break(bufs[i], server)) { smb2_add_credits_from_hdr(bufs[i], server); cifs_dbg(FYI, "Received oplock break\n"); } else { @@ -1304,9 +1291,7 @@ next_pdu: HEADER_SIZE(server)); smb2_add_credits_from_hdr(bufs[i], server); #ifdef CONFIG_CIFS_DEBUG2 - if (server->ops->dump_detail) - server->ops->dump_detail(bufs[i], - server); + smb2_dump_detail(bufs[i], server); cifs_dump_mids(server); #endif /* CIFS_DEBUG2 */ } @@ -1484,8 +1469,7 @@ match_security(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) * that was specified, or "Unspecified" if that sectype was not * compatible with the given NEGOTIATE request. */ - if (server->ops->select_sectype(server, ctx->sectype) - == Unspecified) + if (smb2_select_sectype(server, ctx->sectype) == Unspecified) return false; /* @@ -1951,7 +1935,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb3_fs_context *ctx) tcon->ses = ses; tcon->ipc = true; tcon->seal = seal; - rc = server->ops->tree_connect(xid, ses, unc, tcon, ctx->local_nls); + rc = SMB2_tcon(xid, ses, unc, tcon, ctx->local_nls); free_xid(xid); if (rc) { @@ -2024,7 +2008,7 @@ void __cifs_put_smb_ses(struct cifs_ses *ses) cifs_chan_clear_need_reconnect(ses, server); spin_unlock(&ses->chan_lock); - do_logoff = ses->ses_status == SES_GOOD && server->ops->logoff; + do_logoff = ses->ses_status == SES_GOOD && SMB2_logoff; ses->ses_status = SES_EXITING; tcon = ses->tcon_ipc; ses->tcon_ipc = NULL; @@ -2042,7 +2026,7 @@ void __cifs_put_smb_ses(struct cifs_ses *ses) tconInfoFree(tcon, netfs_trace_tcon_ref_free_ipc); if (do_logoff) { xid = get_xid(); - rc = server->ops->logoff(xid, ses); + rc = SMB2_logoff(xid, ses); if (rc) cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n", __func__, rc); @@ -2487,8 +2471,7 @@ cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace) } xid = get_xid(); - if (ses->server->ops->tree_disconnect) - ses->server->ops->tree_disconnect(xid, tcon); + SMB2_tdis(xid, tcon); _free_xid(xid); cifs_fscache_release_super_cookie(tcon); @@ -2536,11 +2519,6 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) return tcon; } - if (!ses->server->ops->tree_connect) { - rc = -ENOSYS; - goto out_fail; - } - if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING) nohandlecache = ctx->nohandlecache; else @@ -2618,8 +2596,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) } xid = get_xid(); - rc = ses->server->ops->tree_connect(xid, ses, ctx->UNC, tcon, - ctx->local_nls); + rc = SMB2_tcon(xid, ses, ctx->UNC, tcon, ctx->local_nls); free_xid(xid); cifs_dbg(FYI, "Tcon rc = %d\n", rc); if (rc) @@ -3392,7 +3369,7 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, sep = CIFS_DIR_SEP(cifs_sb); s = full_path; - rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, ""); + rc = smb2_is_path_accessible(xid, tcon, cifs_sb, ""); while (rc == 0) { /* skip separators */ while (*s == sep) @@ -3416,7 +3393,7 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, */ tmp = *s; *s = 0; - rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, + rc = smb2_is_path_accessible(xid, tcon, cifs_sb, full_path); *s = tmp; } @@ -3438,9 +3415,6 @@ int cifs_is_path_remote(struct cifs_mount_ctx *mnt_ctx) struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; char *full_path; - if (!server->ops->is_path_accessible) - return -EOPNOTSUPP; - /* * cifs_build_path_to_root works only when we have a valid tcon */ @@ -3450,7 +3424,7 @@ int cifs_is_path_remote(struct cifs_mount_ctx *mnt_ctx) cifs_dbg(FYI, "%s: full_path: %s\n", __func__, full_path); - rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, + rc = smb2_is_path_accessible(xid, tcon, cifs_sb, full_path); if (rc != 0 && rc != -EREMOTE) goto out; @@ -3597,9 +3571,6 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses, { int rc = 0; - if (!server->ops->need_neg || !server->ops->negotiate) - return -ENOSYS; - /* only send once per connect */ spin_lock(&server->srv_lock); if (server->tcpStatus != CifsGood && @@ -3609,8 +3580,7 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses, return -EHOSTDOWN; } - if (!server->ops->need_neg(server) && - server->tcpStatus == CifsGood) { + if (!smb2_need_neg(server) && server->tcpStatus == CifsGood) { spin_unlock(&server->srv_lock); return 0; } @@ -3618,7 +3588,7 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses, server->tcpStatus = CifsInNegotiate; spin_unlock(&server->srv_lock); - rc = server->ops->negotiate(xid, ses, server); + rc = smb2_negotiate(xid, ses, server); if (rc == 0) { spin_lock(&server->srv_lock); if (server->tcpStatus == CifsInNegotiate) @@ -3705,8 +3675,7 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, cifs_dbg(FYI, "Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d\n", server->sec_mode, server->capabilities, server->timeAdj); - if (server->ops->sess_setup) - rc = server->ops->sess_setup(xid, ses, server, nls_info); + rc = SMB2_sess_setup(xid, ses, server, nls_info); if (rc) { cifs_server_dbg(VFS, "Send error in SessSetup = %d\n", rc); @@ -4039,7 +4008,6 @@ cifs_prune_tlinks(struct work_struct *work) int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const struct nls_table *nlsc) { int rc; - const struct smb_version_operations *ops = tcon->ses->server->ops; /* only send once per connect */ spin_lock(&tcon->tc_lock); @@ -4062,7 +4030,7 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru tcon->status = TID_IN_TCON; spin_unlock(&tcon->tc_lock); - rc = ops->tree_connect(xid, tcon->ses, tcon->tree_name, tcon, nlsc); + rc = SMB2_tcon(xid, tcon->ses, tcon->tree_name, tcon, nlsc); if (rc) { spin_lock(&tcon->tc_lock); if (tcon->status == TID_IN_TCON) |