CIFS: Move add/set_credits and get_credits_field to ops structure
Acked-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
8aa26f3ed8
commit
452757897a
|
@ -169,6 +169,9 @@ struct smb_version_operations {
|
||||||
/* check response: verify signature, map error */
|
/* check response: verify signature, map error */
|
||||||
int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
|
int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
|
||||||
bool);
|
bool);
|
||||||
|
void (*add_credits)(struct TCP_Server_Info *, const unsigned int);
|
||||||
|
void (*set_credits)(struct TCP_Server_Info *, const int);
|
||||||
|
int * (*get_credits_field)(struct TCP_Server_Info *);
|
||||||
/* data offset from read response message */
|
/* data offset from read response message */
|
||||||
unsigned int (*read_data_offset)(char *);
|
unsigned int (*read_data_offset)(char *);
|
||||||
/* data length from read response message */
|
/* data length from read response message */
|
||||||
|
@ -372,16 +375,6 @@ in_flight(struct TCP_Server_Info *server)
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int*
|
|
||||||
get_credits_field(struct TCP_Server_Info *server)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* This will change to switch statement when we reserve slots for echos
|
|
||||||
* and oplock breaks.
|
|
||||||
*/
|
|
||||||
return &server->credits;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
has_credits(struct TCP_Server_Info *server, int *credits)
|
has_credits(struct TCP_Server_Info *server, int *credits)
|
||||||
{
|
{
|
||||||
|
@ -392,6 +385,18 @@ has_credits(struct TCP_Server_Info *server, int *credits)
|
||||||
return num > 0;
|
return num > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
add_credits(struct TCP_Server_Info *server, const unsigned int add)
|
||||||
|
{
|
||||||
|
server->ops->add_credits(server, add);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
set_credits(struct TCP_Server_Info *server, const int val)
|
||||||
|
{
|
||||||
|
server->ops->set_credits(server, val);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros to allow the TCP_Server_Info->net field and related code to drop out
|
* Macros to allow the TCP_Server_Info->net field and related code to drop out
|
||||||
* when CONFIG_NET_NS isn't set.
|
* when CONFIG_NET_NS isn't set.
|
||||||
|
|
|
@ -90,9 +90,6 @@ extern int SendReceiveBlockingLock(const unsigned int xid,
|
||||||
struct smb_hdr *in_buf ,
|
struct smb_hdr *in_buf ,
|
||||||
struct smb_hdr *out_buf,
|
struct smb_hdr *out_buf,
|
||||||
int *bytes_returned);
|
int *bytes_returned);
|
||||||
extern void cifs_add_credits(struct TCP_Server_Info *server,
|
|
||||||
const unsigned int add);
|
|
||||||
extern void cifs_set_credits(struct TCP_Server_Info *server, const int val);
|
|
||||||
extern int checkSMB(char *buf, unsigned int length);
|
extern int checkSMB(char *buf, unsigned int length);
|
||||||
extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *);
|
extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *);
|
||||||
extern bool backup_cred(struct cifs_sb_info *);
|
extern bool backup_cred(struct cifs_sb_info *);
|
||||||
|
|
|
@ -460,7 +460,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifs_ses *ses)
|
||||||
server->maxReq = min_t(unsigned int,
|
server->maxReq = min_t(unsigned int,
|
||||||
le16_to_cpu(rsp->MaxMpxCount),
|
le16_to_cpu(rsp->MaxMpxCount),
|
||||||
cifs_max_pending);
|
cifs_max_pending);
|
||||||
cifs_set_credits(server, server->maxReq);
|
set_credits(server, server->maxReq);
|
||||||
server->maxBuf = le16_to_cpu(rsp->MaxBufSize);
|
server->maxBuf = le16_to_cpu(rsp->MaxBufSize);
|
||||||
server->max_vcs = le16_to_cpu(rsp->MaxNumberVcs);
|
server->max_vcs = le16_to_cpu(rsp->MaxNumberVcs);
|
||||||
/* even though we do not use raw we might as well set this
|
/* even though we do not use raw we might as well set this
|
||||||
|
@ -568,7 +568,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifs_ses *ses)
|
||||||
little endian */
|
little endian */
|
||||||
server->maxReq = min_t(unsigned int, le16_to_cpu(pSMBr->MaxMpxCount),
|
server->maxReq = min_t(unsigned int, le16_to_cpu(pSMBr->MaxMpxCount),
|
||||||
cifs_max_pending);
|
cifs_max_pending);
|
||||||
cifs_set_credits(server, server->maxReq);
|
set_credits(server, server->maxReq);
|
||||||
/* probably no need to store and check maxvcs */
|
/* probably no need to store and check maxvcs */
|
||||||
server->maxBuf = le32_to_cpu(pSMBr->MaxBufferSize);
|
server->maxBuf = le32_to_cpu(pSMBr->MaxBufferSize);
|
||||||
server->max_rw = le32_to_cpu(pSMBr->MaxRawSize);
|
server->max_rw = le32_to_cpu(pSMBr->MaxRawSize);
|
||||||
|
@ -720,7 +720,7 @@ cifs_echo_callback(struct mid_q_entry *mid)
|
||||||
struct TCP_Server_Info *server = mid->callback_data;
|
struct TCP_Server_Info *server = mid->callback_data;
|
||||||
|
|
||||||
DeleteMidQEntry(mid);
|
DeleteMidQEntry(mid);
|
||||||
cifs_add_credits(server, 1);
|
add_credits(server, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1563,7 +1563,7 @@ cifs_readv_callback(struct mid_q_entry *mid)
|
||||||
|
|
||||||
queue_work(cifsiod_wq, &rdata->work);
|
queue_work(cifsiod_wq, &rdata->work);
|
||||||
DeleteMidQEntry(mid);
|
DeleteMidQEntry(mid);
|
||||||
cifs_add_credits(server, 1);
|
add_credits(server, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cifs_async_readv - send an async write, and set up mid to handle result */
|
/* cifs_async_readv - send an async write, and set up mid to handle result */
|
||||||
|
@ -2010,7 +2010,7 @@ cifs_writev_callback(struct mid_q_entry *mid)
|
||||||
|
|
||||||
queue_work(cifsiod_wq, &wdata->work);
|
queue_work(cifsiod_wq, &wdata->work);
|
||||||
DeleteMidQEntry(mid);
|
DeleteMidQEntry(mid);
|
||||||
cifs_add_credits(tcon->ses->server, 1);
|
add_credits(tcon->ses->server, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cifs_async_writev - send an async write, and set up mid to handle result */
|
/* cifs_async_writev - send an async write, and set up mid to handle result */
|
||||||
|
|
|
@ -4099,11 +4099,11 @@ int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses)
|
||||||
if (server->maxBuf != 0)
|
if (server->maxBuf != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cifs_set_credits(server, 1);
|
set_credits(server, 1);
|
||||||
rc = CIFSSMBNegotiate(xid, ses);
|
rc = CIFSSMBNegotiate(xid, ses);
|
||||||
if (rc == -EAGAIN) {
|
if (rc == -EAGAIN) {
|
||||||
/* retry only once on 1st time connection */
|
/* retry only once on 1st time connection */
|
||||||
cifs_set_credits(server, 1);
|
set_credits(server, 1);
|
||||||
rc = CIFSSMBNegotiate(xid, ses);
|
rc = CIFSSMBNegotiate(xid, ses);
|
||||||
if (rc == -EAGAIN)
|
if (rc == -EAGAIN)
|
||||||
rc = -EHOSTDOWN;
|
rc = -EHOSTDOWN;
|
||||||
|
|
|
@ -653,22 +653,3 @@ backup_cred(struct cifs_sb_info *cifs_sb)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
cifs_add_credits(struct TCP_Server_Info *server, const unsigned int add)
|
|
||||||
{
|
|
||||||
spin_lock(&server->req_lock);
|
|
||||||
server->credits += add;
|
|
||||||
server->in_flight--;
|
|
||||||
spin_unlock(&server->req_lock);
|
|
||||||
wake_up(&server->request_q);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cifs_set_credits(struct TCP_Server_Info *server, const int val)
|
|
||||||
{
|
|
||||||
spin_lock(&server->req_lock);
|
|
||||||
server->credits = val;
|
|
||||||
server->oplocks = val > 1 ? enable_oplocks : false;
|
|
||||||
spin_unlock(&server->req_lock);
|
|
||||||
}
|
|
||||||
|
|
|
@ -100,11 +100,39 @@ cifs_find_mid(struct TCP_Server_Info *server, char *buffer)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cifs_add_credits(struct TCP_Server_Info *server, const unsigned int add)
|
||||||
|
{
|
||||||
|
spin_lock(&server->req_lock);
|
||||||
|
server->credits += add;
|
||||||
|
server->in_flight--;
|
||||||
|
spin_unlock(&server->req_lock);
|
||||||
|
wake_up(&server->request_q);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cifs_set_credits(struct TCP_Server_Info *server, const int val)
|
||||||
|
{
|
||||||
|
spin_lock(&server->req_lock);
|
||||||
|
server->credits = val;
|
||||||
|
server->oplocks = val > 1 ? enable_oplocks : false;
|
||||||
|
spin_unlock(&server->req_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int *
|
||||||
|
cifs_get_credits_field(struct TCP_Server_Info *server)
|
||||||
|
{
|
||||||
|
return &server->credits;
|
||||||
|
}
|
||||||
|
|
||||||
struct smb_version_operations smb1_operations = {
|
struct smb_version_operations smb1_operations = {
|
||||||
.send_cancel = send_nt_cancel,
|
.send_cancel = send_nt_cancel,
|
||||||
.compare_fids = cifs_compare_fids,
|
.compare_fids = cifs_compare_fids,
|
||||||
.setup_request = cifs_setup_request,
|
.setup_request = cifs_setup_request,
|
||||||
.check_receive = cifs_check_receive,
|
.check_receive = cifs_check_receive,
|
||||||
|
.add_credits = cifs_add_credits,
|
||||||
|
.set_credits = cifs_set_credits,
|
||||||
|
.get_credits_field = cifs_get_credits_field,
|
||||||
.read_data_offset = cifs_read_data_offset,
|
.read_data_offset = cifs_read_data_offset,
|
||||||
.read_data_length = cifs_read_data_length,
|
.read_data_length = cifs_read_data_length,
|
||||||
.map_error = map_smb_to_linux_error,
|
.map_error = map_smb_to_linux_error,
|
||||||
|
|
|
@ -304,7 +304,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int optype,
|
||||||
static int
|
static int
|
||||||
wait_for_free_request(struct TCP_Server_Info *server, const int optype)
|
wait_for_free_request(struct TCP_Server_Info *server, const int optype)
|
||||||
{
|
{
|
||||||
return wait_for_free_credits(server, optype, get_credits_field(server));
|
return wait_for_free_credits(server, optype,
|
||||||
|
server->ops->get_credits_field(server));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
|
static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
|
||||||
|
@ -396,7 +397,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
|
||||||
rc = cifs_setup_async_request(server, iov, nvec, &mid);
|
rc = cifs_setup_async_request(server, iov, nvec, &mid);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
mutex_unlock(&server->srv_mutex);
|
mutex_unlock(&server->srv_mutex);
|
||||||
cifs_add_credits(server, 1);
|
add_credits(server, 1);
|
||||||
wake_up(&server->request_q);
|
wake_up(&server->request_q);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -418,7 +419,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
|
||||||
return rc;
|
return rc;
|
||||||
out_err:
|
out_err:
|
||||||
delete_mid(mid);
|
delete_mid(mid);
|
||||||
cifs_add_credits(server, 1);
|
add_credits(server, 1);
|
||||||
wake_up(&server->request_q);
|
wake_up(&server->request_q);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -582,7 +583,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
|
||||||
mutex_unlock(&ses->server->srv_mutex);
|
mutex_unlock(&ses->server->srv_mutex);
|
||||||
cifs_small_buf_release(buf);
|
cifs_small_buf_release(buf);
|
||||||
/* Update # of requests on wire to server */
|
/* Update # of requests on wire to server */
|
||||||
cifs_add_credits(ses->server, 1);
|
add_credits(ses->server, 1);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +613,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
|
||||||
midQ->callback = DeleteMidQEntry;
|
midQ->callback = DeleteMidQEntry;
|
||||||
spin_unlock(&GlobalMid_Lock);
|
spin_unlock(&GlobalMid_Lock);
|
||||||
cifs_small_buf_release(buf);
|
cifs_small_buf_release(buf);
|
||||||
cifs_add_credits(ses->server, 1);
|
add_credits(ses->server, 1);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
spin_unlock(&GlobalMid_Lock);
|
spin_unlock(&GlobalMid_Lock);
|
||||||
|
@ -622,7 +623,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
|
||||||
|
|
||||||
rc = cifs_sync_mid_result(midQ, ses->server);
|
rc = cifs_sync_mid_result(midQ, ses->server);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
cifs_add_credits(ses->server, 1);
|
add_credits(ses->server, 1);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,7 +649,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
|
||||||
midQ->resp_buf = NULL;
|
midQ->resp_buf = NULL;
|
||||||
out:
|
out:
|
||||||
delete_mid(midQ);
|
delete_mid(midQ);
|
||||||
cifs_add_credits(ses->server, 1);
|
add_credits(ses->server, 1);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -698,7 +699,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
|
||||||
if (rc) {
|
if (rc) {
|
||||||
mutex_unlock(&ses->server->srv_mutex);
|
mutex_unlock(&ses->server->srv_mutex);
|
||||||
/* Update # of requests on wire to server */
|
/* Update # of requests on wire to server */
|
||||||
cifs_add_credits(ses->server, 1);
|
add_credits(ses->server, 1);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +731,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
|
||||||
/* no longer considered to be "in-flight" */
|
/* no longer considered to be "in-flight" */
|
||||||
midQ->callback = DeleteMidQEntry;
|
midQ->callback = DeleteMidQEntry;
|
||||||
spin_unlock(&GlobalMid_Lock);
|
spin_unlock(&GlobalMid_Lock);
|
||||||
cifs_add_credits(ses->server, 1);
|
add_credits(ses->server, 1);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
spin_unlock(&GlobalMid_Lock);
|
spin_unlock(&GlobalMid_Lock);
|
||||||
|
@ -738,7 +739,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
|
||||||
|
|
||||||
rc = cifs_sync_mid_result(midQ, ses->server);
|
rc = cifs_sync_mid_result(midQ, ses->server);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
cifs_add_credits(ses->server, 1);
|
add_credits(ses->server, 1);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +755,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
|
||||||
rc = cifs_check_receive(midQ, ses->server, 0);
|
rc = cifs_check_receive(midQ, ses->server, 0);
|
||||||
out:
|
out:
|
||||||
delete_mid(midQ);
|
delete_mid(midQ);
|
||||||
cifs_add_credits(ses->server, 1);
|
add_credits(ses->server, 1);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue