提交 789e6661 编写于 作者: S Steve French

[CIFS] Cleanup use of CONFIG_CIFS_STATS2 ifdef to make transport routines more readable

Christoph had requested that the stats related code (in
CONFIG_CIFS_STATS2) be moved into helpers to make code flow more
readable.   This patch should help.   For example the following
section from transport.c

                       spin_unlock(&GlobalMid_Lock);
                       atomic_inc(&ses->server->num_waiters);
                       wait_event(ses->server->request_q,
                                  atomic_read(&ses->server->inFlight)
                                    < cifs_max_pending);
                       atomic_dec(&ses->server->num_waiters);
                       spin_lock(&GlobalMid_Lock);

becomes simpler (with the patch below):
                       spin_unlock(&GlobalMid_Lock);
                       cifs_num_waiters_inc(server);
                       wait_event(server->request_q,
                                  atomic_read(&server->inFlight)
                                    < cifs_max_pending);
                       cifs_num_waiters_dec(server);
                       spin_lock(&GlobalMid_Lock);
Reviewed-by: NJeff Layton <jlayton@redhat.com>
CC: Christoph Hellwig <hch@infradead.org>
Signed-off-by: NSteve French <sfrench@us.ibm.com>
Reviewed-by: NPavel Shilovsky <piastry@etersoft.ru>
上级 e6a99d31
...@@ -176,7 +176,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) ...@@ -176,7 +176,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
seq_printf(m, " In Send: %d In MaxReq Wait: %d", seq_printf(m, " In Send: %d In MaxReq Wait: %d",
atomic_read(&server->inSend), atomic_read(&server->in_send),
atomic_read(&server->num_waiters)); atomic_read(&server->num_waiters));
#endif #endif
......
...@@ -291,7 +291,7 @@ struct TCP_Server_Info { ...@@ -291,7 +291,7 @@ struct TCP_Server_Info {
struct fscache_cookie *fscache; /* client index cache cookie */ struct fscache_cookie *fscache; /* client index cache cookie */
#endif #endif
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
atomic_t inSend; /* requests trying to send */ atomic_t in_send; /* requests trying to send */
atomic_t num_waiters; /* blocked waiting to get in sendrecv */ atomic_t num_waiters; /* blocked waiting to get in sendrecv */
#endif #endif
}; };
...@@ -672,12 +672,54 @@ struct mid_q_entry { ...@@ -672,12 +672,54 @@ struct mid_q_entry {
bool multiEnd:1; /* both received */ bool multiEnd:1; /* both received */
}; };
struct oplock_q_entry { /* Make code in transport.c a little cleaner by moving
struct list_head qhead; update of optional stats into function below */
struct inode *pinode; #ifdef CONFIG_CIFS_STATS2
struct cifs_tcon *tcon;
__u16 netfid; static inline void cifs_in_send_inc(struct TCP_Server_Info *server)
}; {
atomic_inc(&server->in_send);
}
static inline void cifs_in_send_dec(struct TCP_Server_Info *server)
{
atomic_dec(&server->in_send);
}
static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server)
{
atomic_inc(&server->num_waiters);
}
static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server)
{
atomic_dec(&server->num_waiters);
}
static inline void cifs_save_when_sent(struct mid_q_entry *mid)
{
mid->when_sent = jiffies;
}
#else
static inline void cifs_in_send_inc(struct TCP_Server_Info *server)
{
}
static inline void cifs_in_send_dec(struct TCP_Server_Info *server)
{
}
static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server)
{
}
static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server)
{
}
static inline void cifs_save_when_sent(struct mid_q_entry *mid)
{
}
#endif
/* for pending dnotify requests */ /* for pending dnotify requests */
struct dir_notify_req { struct dir_notify_req {
......
...@@ -266,15 +266,11 @@ static int wait_for_free_request(struct TCP_Server_Info *server, ...@@ -266,15 +266,11 @@ static int wait_for_free_request(struct TCP_Server_Info *server,
while (1) { while (1) {
if (atomic_read(&server->inFlight) >= cifs_max_pending) { if (atomic_read(&server->inFlight) >= cifs_max_pending) {
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
#ifdef CONFIG_CIFS_STATS2 cifs_num_waiters_inc(server);
atomic_inc(&server->num_waiters);
#endif
wait_event(server->request_q, wait_event(server->request_q,
atomic_read(&server->inFlight) atomic_read(&server->inFlight)
< cifs_max_pending); < cifs_max_pending);
#ifdef CONFIG_CIFS_STATS2 cifs_num_waiters_dec(server);
atomic_dec(&server->num_waiters);
#endif
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
} else { } else {
if (server->tcpStatus == CifsExiting) { if (server->tcpStatus == CifsExiting) {
...@@ -381,15 +377,13 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, ...@@ -381,15 +377,13 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
mid->callback = callback; mid->callback = callback;
mid->callback_data = cbdata; mid->callback_data = cbdata;
mid->midState = MID_REQUEST_SUBMITTED; mid->midState = MID_REQUEST_SUBMITTED;
#ifdef CONFIG_CIFS_STATS2
atomic_inc(&server->inSend); cifs_in_send_inc(server);
#endif
rc = smb_sendv(server, iov, nvec); rc = smb_sendv(server, iov, nvec);
#ifdef CONFIG_CIFS_STATS2 cifs_in_send_dec(server);
atomic_dec(&server->inSend); cifs_save_when_sent(mid);
mid->when_sent = jiffies;
#endif
mutex_unlock(&server->srv_mutex); mutex_unlock(&server->srv_mutex);
if (rc) if (rc)
goto out_err; goto out_err;
...@@ -575,14 +569,10 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, ...@@ -575,14 +569,10 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
} }
midQ->midState = MID_REQUEST_SUBMITTED; midQ->midState = MID_REQUEST_SUBMITTED;
#ifdef CONFIG_CIFS_STATS2 cifs_in_send_inc(ses->server);
atomic_inc(&ses->server->inSend);
#endif
rc = smb_sendv(ses->server, iov, n_vec); rc = smb_sendv(ses->server, iov, n_vec);
#ifdef CONFIG_CIFS_STATS2 cifs_in_send_dec(ses->server);
atomic_dec(&ses->server->inSend); cifs_save_when_sent(midQ);
midQ->when_sent = jiffies;
#endif
mutex_unlock(&ses->server->srv_mutex); mutex_unlock(&ses->server->srv_mutex);
...@@ -703,14 +693,11 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, ...@@ -703,14 +693,11 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
} }
midQ->midState = MID_REQUEST_SUBMITTED; midQ->midState = MID_REQUEST_SUBMITTED;
#ifdef CONFIG_CIFS_STATS2
atomic_inc(&ses->server->inSend); cifs_in_send_inc(ses->server);
#endif
rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
#ifdef CONFIG_CIFS_STATS2 cifs_in_send_dec(ses->server);
atomic_dec(&ses->server->inSend); cifs_save_when_sent(midQ);
midQ->when_sent = jiffies;
#endif
mutex_unlock(&ses->server->srv_mutex); mutex_unlock(&ses->server->srv_mutex);
if (rc < 0) if (rc < 0)
...@@ -843,14 +830,10 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -843,14 +830,10 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
} }
midQ->midState = MID_REQUEST_SUBMITTED; midQ->midState = MID_REQUEST_SUBMITTED;
#ifdef CONFIG_CIFS_STATS2 cifs_in_send_inc(ses->server);
atomic_inc(&ses->server->inSend);
#endif
rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
#ifdef CONFIG_CIFS_STATS2 cifs_in_send_dec(ses->server);
atomic_dec(&ses->server->inSend); cifs_save_when_sent(midQ);
midQ->when_sent = jiffies;
#endif
mutex_unlock(&ses->server->srv_mutex); mutex_unlock(&ses->server->srv_mutex);
if (rc < 0) { if (rc < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册