diff options
author | Pavel Shilovsky <piastry@etersoft.ru> | 2012-02-17 09:09:12 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2012-03-21 12:27:35 -0400 |
commit | fc40f9cf828908e91d9af820e9300a9d42fbbd72 (patch) | |
tree | 1d0aa12f099ea9c759321d5e75967e152fcf4b11 /fs/cifs/transport.c | |
parent | 1daaae8fa4afe3df78ca34e724ed7e8187e4eb32 (diff) |
CIFS: Simplify inFlight logic
by making it as unsigned integer and surround access with req_lock
from server structure.
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/transport.c')
-rw-r--r-- | fs/cifs/transport.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 99a27cfa6cd2..e2673aa34381 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -254,28 +254,29 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer, | |||
254 | return smb_sendv(server, &iov, 1); | 254 | return smb_sendv(server, &iov, 1); |
255 | } | 255 | } |
256 | 256 | ||
257 | static int wait_for_free_request(struct TCP_Server_Info *server, | 257 | static int |
258 | const int long_op) | 258 | wait_for_free_request(struct TCP_Server_Info *server, const int long_op) |
259 | { | 259 | { |
260 | spin_lock(&server->req_lock); | ||
261 | |||
260 | if (long_op == CIFS_ASYNC_OP) { | 262 | if (long_op == CIFS_ASYNC_OP) { |
261 | /* oplock breaks must not be held up */ | 263 | /* oplock breaks must not be held up */ |
262 | atomic_inc(&server->inFlight); | 264 | server->in_flight++; |
265 | spin_unlock(&server->req_lock); | ||
263 | return 0; | 266 | return 0; |
264 | } | 267 | } |
265 | 268 | ||
266 | spin_lock(&GlobalMid_Lock); | ||
267 | while (1) { | 269 | while (1) { |
268 | if (atomic_read(&server->inFlight) >= server->maxReq) { | 270 | if (server->in_flight >= server->maxReq) { |
269 | spin_unlock(&GlobalMid_Lock); | 271 | spin_unlock(&server->req_lock); |
270 | cifs_num_waiters_inc(server); | 272 | cifs_num_waiters_inc(server); |
271 | wait_event(server->request_q, | 273 | wait_event(server->request_q, |
272 | atomic_read(&server->inFlight) | 274 | in_flight(server) < server->maxReq); |
273 | < server->maxReq); | ||
274 | cifs_num_waiters_dec(server); | 275 | cifs_num_waiters_dec(server); |
275 | spin_lock(&GlobalMid_Lock); | 276 | spin_lock(&server->req_lock); |
276 | } else { | 277 | } else { |
277 | if (server->tcpStatus == CifsExiting) { | 278 | if (server->tcpStatus == CifsExiting) { |
278 | spin_unlock(&GlobalMid_Lock); | 279 | spin_unlock(&server->req_lock); |
279 | return -ENOENT; | 280 | return -ENOENT; |
280 | } | 281 | } |
281 | 282 | ||
@@ -284,8 +285,8 @@ static int wait_for_free_request(struct TCP_Server_Info *server, | |||
284 | 285 | ||
285 | /* update # of requests on the wire to server */ | 286 | /* update # of requests on the wire to server */ |
286 | if (long_op != CIFS_BLOCKING_OP) | 287 | if (long_op != CIFS_BLOCKING_OP) |
287 | atomic_inc(&server->inFlight); | 288 | server->in_flight++; |
288 | spin_unlock(&GlobalMid_Lock); | 289 | spin_unlock(&server->req_lock); |
289 | break; | 290 | break; |
290 | } | 291 | } |
291 | } | 292 | } |
@@ -359,7 +360,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, | |||
359 | mid = AllocMidQEntry(hdr, server); | 360 | mid = AllocMidQEntry(hdr, server); |
360 | if (mid == NULL) { | 361 | if (mid == NULL) { |
361 | mutex_unlock(&server->srv_mutex); | 362 | mutex_unlock(&server->srv_mutex); |
362 | atomic_dec(&server->inFlight); | 363 | dec_in_flight(server); |
363 | wake_up(&server->request_q); | 364 | wake_up(&server->request_q); |
364 | return -ENOMEM; | 365 | return -ENOMEM; |
365 | } | 366 | } |
@@ -392,7 +393,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, | |||
392 | return rc; | 393 | return rc; |
393 | out_err: | 394 | out_err: |
394 | delete_mid(mid); | 395 | delete_mid(mid); |
395 | atomic_dec(&server->inFlight); | 396 | dec_in_flight(server); |
396 | wake_up(&server->request_q); | 397 | wake_up(&server->request_q); |
397 | return rc; | 398 | return rc; |
398 | } | 399 | } |
@@ -564,7 +565,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, | |||
564 | mutex_unlock(&ses->server->srv_mutex); | 565 | mutex_unlock(&ses->server->srv_mutex); |
565 | cifs_small_buf_release(in_buf); | 566 | cifs_small_buf_release(in_buf); |
566 | /* Update # of requests on wire to server */ | 567 | /* Update # of requests on wire to server */ |
567 | atomic_dec(&ses->server->inFlight); | 568 | dec_in_flight(ses->server); |
568 | wake_up(&ses->server->request_q); | 569 | wake_up(&ses->server->request_q); |
569 | return rc; | 570 | return rc; |
570 | } | 571 | } |
@@ -601,7 +602,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, | |||
601 | midQ->callback = DeleteMidQEntry; | 602 | midQ->callback = DeleteMidQEntry; |
602 | spin_unlock(&GlobalMid_Lock); | 603 | spin_unlock(&GlobalMid_Lock); |
603 | cifs_small_buf_release(in_buf); | 604 | cifs_small_buf_release(in_buf); |
604 | atomic_dec(&ses->server->inFlight); | 605 | dec_in_flight(ses->server); |
605 | wake_up(&ses->server->request_q); | 606 | wake_up(&ses->server->request_q); |
606 | return rc; | 607 | return rc; |
607 | } | 608 | } |
@@ -612,7 +613,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, | |||
612 | 613 | ||
613 | rc = cifs_sync_mid_result(midQ, ses->server); | 614 | rc = cifs_sync_mid_result(midQ, ses->server); |
614 | if (rc != 0) { | 615 | if (rc != 0) { |
615 | atomic_dec(&ses->server->inFlight); | 616 | dec_in_flight(ses->server); |
616 | wake_up(&ses->server->request_q); | 617 | wake_up(&ses->server->request_q); |
617 | return rc; | 618 | return rc; |
618 | } | 619 | } |
@@ -637,7 +638,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, | |||
637 | midQ->resp_buf = NULL; | 638 | midQ->resp_buf = NULL; |
638 | out: | 639 | out: |
639 | delete_mid(midQ); | 640 | delete_mid(midQ); |
640 | atomic_dec(&ses->server->inFlight); | 641 | dec_in_flight(ses->server); |
641 | wake_up(&ses->server->request_q); | 642 | wake_up(&ses->server->request_q); |
642 | 643 | ||
643 | return rc; | 644 | return rc; |
@@ -688,7 +689,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
688 | if (rc) { | 689 | if (rc) { |
689 | mutex_unlock(&ses->server->srv_mutex); | 690 | mutex_unlock(&ses->server->srv_mutex); |
690 | /* Update # of requests on wire to server */ | 691 | /* Update # of requests on wire to server */ |
691 | atomic_dec(&ses->server->inFlight); | 692 | dec_in_flight(ses->server); |
692 | wake_up(&ses->server->request_q); | 693 | wake_up(&ses->server->request_q); |
693 | return rc; | 694 | return rc; |
694 | } | 695 | } |
@@ -721,7 +722,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
721 | /* no longer considered to be "in-flight" */ | 722 | /* no longer considered to be "in-flight" */ |
722 | midQ->callback = DeleteMidQEntry; | 723 | midQ->callback = DeleteMidQEntry; |
723 | spin_unlock(&GlobalMid_Lock); | 724 | spin_unlock(&GlobalMid_Lock); |
724 | atomic_dec(&ses->server->inFlight); | 725 | dec_in_flight(ses->server); |
725 | wake_up(&ses->server->request_q); | 726 | wake_up(&ses->server->request_q); |
726 | return rc; | 727 | return rc; |
727 | } | 728 | } |
@@ -730,7 +731,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
730 | 731 | ||
731 | rc = cifs_sync_mid_result(midQ, ses->server); | 732 | rc = cifs_sync_mid_result(midQ, ses->server); |
732 | if (rc != 0) { | 733 | if (rc != 0) { |
733 | atomic_dec(&ses->server->inFlight); | 734 | dec_in_flight(ses->server); |
734 | wake_up(&ses->server->request_q); | 735 | wake_up(&ses->server->request_q); |
735 | return rc; | 736 | return rc; |
736 | } | 737 | } |
@@ -747,7 +748,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
747 | rc = cifs_check_receive(midQ, ses->server, 0); | 748 | rc = cifs_check_receive(midQ, ses->server, 0); |
748 | out: | 749 | out: |
749 | delete_mid(midQ); | 750 | delete_mid(midQ); |
750 | atomic_dec(&ses->server->inFlight); | 751 | dec_in_flight(ses->server); |
751 | wake_up(&ses->server->request_q); | 752 | wake_up(&ses->server->request_q); |
752 | 753 | ||
753 | return rc; | 754 | return rc; |