diff options
author | Steve French <sfrench@us.ibm.com> | 2011-08-09 14:44:44 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2011-08-11 14:23:45 -0400 |
commit | 789e66612367f9975d704c9e4990025cbbbb45ec (patch) | |
tree | a3c466f3137ac319b9e15656a1d72aabd7050126 /fs/cifs/transport.c | |
parent | e6a99d312687a42c077a9b8cb5e757f186edb1b9 (diff) |
[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: Jeff Layton <jlayton@redhat.com>
CC: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Reviewed-by: Pavel Shilovsky <piastry@etersoft.ru>
Diffstat (limited to 'fs/cifs/transport.c')
-rw-r--r-- | fs/cifs/transport.c | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index c1b9c4b10739..10ca6b2c26b7 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -266,15 +266,11 @@ static int wait_for_free_request(struct TCP_Server_Info *server, | |||
266 | while (1) { | 266 | while (1) { |
267 | if (atomic_read(&server->inFlight) >= cifs_max_pending) { | 267 | if (atomic_read(&server->inFlight) >= cifs_max_pending) { |
268 | spin_unlock(&GlobalMid_Lock); | 268 | spin_unlock(&GlobalMid_Lock); |
269 | #ifdef CONFIG_CIFS_STATS2 | 269 | cifs_num_waiters_inc(server); |
270 | atomic_inc(&server->num_waiters); | ||
271 | #endif | ||
272 | wait_event(server->request_q, | 270 | wait_event(server->request_q, |
273 | atomic_read(&server->inFlight) | 271 | atomic_read(&server->inFlight) |
274 | < cifs_max_pending); | 272 | < cifs_max_pending); |
275 | #ifdef CONFIG_CIFS_STATS2 | 273 | cifs_num_waiters_dec(server); |
276 | atomic_dec(&server->num_waiters); | ||
277 | #endif | ||
278 | spin_lock(&GlobalMid_Lock); | 274 | spin_lock(&GlobalMid_Lock); |
279 | } else { | 275 | } else { |
280 | if (server->tcpStatus == CifsExiting) { | 276 | if (server->tcpStatus == CifsExiting) { |
@@ -381,15 +377,13 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, | |||
381 | mid->callback = callback; | 377 | mid->callback = callback; |
382 | mid->callback_data = cbdata; | 378 | mid->callback_data = cbdata; |
383 | mid->midState = MID_REQUEST_SUBMITTED; | 379 | mid->midState = MID_REQUEST_SUBMITTED; |
384 | #ifdef CONFIG_CIFS_STATS2 | 380 | |
385 | atomic_inc(&server->inSend); | 381 | cifs_in_send_inc(server); |
386 | #endif | ||
387 | rc = smb_sendv(server, iov, nvec); | 382 | rc = smb_sendv(server, iov, nvec); |
388 | #ifdef CONFIG_CIFS_STATS2 | 383 | cifs_in_send_dec(server); |
389 | atomic_dec(&server->inSend); | 384 | cifs_save_when_sent(mid); |
390 | mid->when_sent = jiffies; | ||
391 | #endif | ||
392 | mutex_unlock(&server->srv_mutex); | 385 | mutex_unlock(&server->srv_mutex); |
386 | |||
393 | if (rc) | 387 | if (rc) |
394 | goto out_err; | 388 | goto out_err; |
395 | 389 | ||
@@ -575,14 +569,10 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, | |||
575 | } | 569 | } |
576 | 570 | ||
577 | midQ->midState = MID_REQUEST_SUBMITTED; | 571 | midQ->midState = MID_REQUEST_SUBMITTED; |
578 | #ifdef CONFIG_CIFS_STATS2 | 572 | cifs_in_send_inc(ses->server); |
579 | atomic_inc(&ses->server->inSend); | ||
580 | #endif | ||
581 | rc = smb_sendv(ses->server, iov, n_vec); | 573 | rc = smb_sendv(ses->server, iov, n_vec); |
582 | #ifdef CONFIG_CIFS_STATS2 | 574 | cifs_in_send_dec(ses->server); |
583 | atomic_dec(&ses->server->inSend); | 575 | cifs_save_when_sent(midQ); |
584 | midQ->when_sent = jiffies; | ||
585 | #endif | ||
586 | 576 | ||
587 | mutex_unlock(&ses->server->srv_mutex); | 577 | mutex_unlock(&ses->server->srv_mutex); |
588 | 578 | ||
@@ -703,14 +693,11 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
703 | } | 693 | } |
704 | 694 | ||
705 | midQ->midState = MID_REQUEST_SUBMITTED; | 695 | midQ->midState = MID_REQUEST_SUBMITTED; |
706 | #ifdef CONFIG_CIFS_STATS2 | 696 | |
707 | atomic_inc(&ses->server->inSend); | 697 | cifs_in_send_inc(ses->server); |
708 | #endif | ||
709 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); | 698 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); |
710 | #ifdef CONFIG_CIFS_STATS2 | 699 | cifs_in_send_dec(ses->server); |
711 | atomic_dec(&ses->server->inSend); | 700 | cifs_save_when_sent(midQ); |
712 | midQ->when_sent = jiffies; | ||
713 | #endif | ||
714 | mutex_unlock(&ses->server->srv_mutex); | 701 | mutex_unlock(&ses->server->srv_mutex); |
715 | 702 | ||
716 | if (rc < 0) | 703 | if (rc < 0) |
@@ -843,14 +830,10 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
843 | } | 830 | } |
844 | 831 | ||
845 | midQ->midState = MID_REQUEST_SUBMITTED; | 832 | midQ->midState = MID_REQUEST_SUBMITTED; |
846 | #ifdef CONFIG_CIFS_STATS2 | 833 | cifs_in_send_inc(ses->server); |
847 | atomic_inc(&ses->server->inSend); | ||
848 | #endif | ||
849 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); | 834 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); |
850 | #ifdef CONFIG_CIFS_STATS2 | 835 | cifs_in_send_dec(ses->server); |
851 | atomic_dec(&ses->server->inSend); | 836 | cifs_save_when_sent(midQ); |
852 | midQ->when_sent = jiffies; | ||
853 | #endif | ||
854 | mutex_unlock(&ses->server->srv_mutex); | 837 | mutex_unlock(&ses->server->srv_mutex); |
855 | 838 | ||
856 | if (rc < 0) { | 839 | if (rc < 0) { |