Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45275789 authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Pavel Shilovsky
Browse files

CIFS: Move add/set_credits and get_credits_field to ops structure

parent 8aa26f3e
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -169,6 +169,9 @@ struct smb_version_operations {
	/* check response: verify signature, map error */
	int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
			     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 */
	unsigned int (*read_data_offset)(char *);
	/* data length from read response message */
@@ -372,16 +375,6 @@ in_flight(struct TCP_Server_Info *server)
	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
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;
}

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
 * when CONFIG_NET_NS isn't set.
+0 −3
Original line number Diff line number Diff line
@@ -90,9 +90,6 @@ extern int SendReceiveBlockingLock(const unsigned int xid,
			struct smb_hdr *in_buf ,
			struct smb_hdr *out_buf,
			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 bool is_valid_oplock_break(char *, struct TCP_Server_Info *);
extern bool backup_cred(struct cifs_sb_info *);
+5 −5
Original line number Diff line number Diff line
@@ -460,7 +460,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifs_ses *ses)
		server->maxReq = min_t(unsigned int,
				       le16_to_cpu(rsp->MaxMpxCount),
				       cifs_max_pending);
		cifs_set_credits(server, server->maxReq);
		set_credits(server, server->maxReq);
		server->maxBuf = le16_to_cpu(rsp->MaxBufSize);
		server->max_vcs = le16_to_cpu(rsp->MaxNumberVcs);
		/* 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 */
	server->maxReq = min_t(unsigned int, le16_to_cpu(pSMBr->MaxMpxCount),
			       cifs_max_pending);
	cifs_set_credits(server, server->maxReq);
	set_credits(server, server->maxReq);
	/* probably no need to store and check maxvcs */
	server->maxBuf = le32_to_cpu(pSMBr->MaxBufferSize);
	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;

	DeleteMidQEntry(mid);
	cifs_add_credits(server, 1);
	add_credits(server, 1);
}

int
@@ -1563,7 +1563,7 @@ cifs_readv_callback(struct mid_q_entry *mid)

	queue_work(cifsiod_wq, &rdata->work);
	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 */
@@ -2010,7 +2010,7 @@ cifs_writev_callback(struct mid_q_entry *mid)

	queue_work(cifsiod_wq, &wdata->work);
	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 */
+2 −2
Original line number Diff line number Diff line
@@ -4099,11 +4099,11 @@ int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses)
	if (server->maxBuf != 0)
		return 0;

	cifs_set_credits(server, 1);
	set_credits(server, 1);
	rc = CIFSSMBNegotiate(xid, ses);
	if (rc == -EAGAIN) {
		/* retry only once on 1st time connection */
		cifs_set_credits(server, 1);
		set_credits(server, 1);
		rc = CIFSSMBNegotiate(xid, ses);
		if (rc == -EAGAIN)
			rc = -EHOSTDOWN;
+0 −19
Original line number Diff line number Diff line
@@ -653,22 +653,3 @@ backup_cred(struct cifs_sb_info *cifs_sb)

	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);
}
Loading