diff options
-rw-r--r-- | fs/cifs/cifs_debug.c | 3 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 21 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 6 | ||||
-rw-r--r-- | fs/cifs/connect.c | 10 | ||||
-rw-r--r-- | fs/cifs/transport.c | 45 |
5 files changed, 52 insertions, 33 deletions
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 24b3dfc05282..573b899b5a5d 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c | |||
@@ -171,8 +171,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) | |||
171 | seq_printf(m, "TCP status: %d\n\tLocal Users To " | 171 | seq_printf(m, "TCP status: %d\n\tLocal Users To " |
172 | "Server: %d SecMode: 0x%x Req On Wire: %d", | 172 | "Server: %d SecMode: 0x%x Req On Wire: %d", |
173 | server->tcpStatus, server->srv_count, | 173 | server->tcpStatus, server->srv_count, |
174 | server->sec_mode, | 174 | server->sec_mode, in_flight(server)); |
175 | atomic_read(&server->inFlight)); | ||
176 | 175 | ||
177 | #ifdef CONFIG_CIFS_STATS2 | 176 | #ifdef CONFIG_CIFS_STATS2 |
178 | seq_printf(m, " In Send: %d In MaxReq Wait: %d", | 177 | seq_printf(m, " In Send: %d In MaxReq Wait: %d", |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index d47d20aac670..fb78bc903887 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -250,7 +250,8 @@ struct TCP_Server_Info { | |||
250 | bool noblocksnd; /* use blocking sendmsg */ | 250 | bool noblocksnd; /* use blocking sendmsg */ |
251 | bool noautotune; /* do not autotune send buf sizes */ | 251 | bool noautotune; /* do not autotune send buf sizes */ |
252 | bool tcp_nodelay; | 252 | bool tcp_nodelay; |
253 | atomic_t inFlight; /* number of requests on the wire to server */ | 253 | unsigned int in_flight; /* number of requests on the wire to server */ |
254 | spinlock_t req_lock; /* protect the value above */ | ||
254 | struct mutex srv_mutex; | 255 | struct mutex srv_mutex; |
255 | struct task_struct *tsk; | 256 | struct task_struct *tsk; |
256 | char server_GUID[16]; | 257 | char server_GUID[16]; |
@@ -303,6 +304,24 @@ struct TCP_Server_Info { | |||
303 | #endif | 304 | #endif |
304 | }; | 305 | }; |
305 | 306 | ||
307 | static inline unsigned int | ||
308 | in_flight(struct TCP_Server_Info *server) | ||
309 | { | ||
310 | unsigned int num; | ||
311 | spin_lock(&server->req_lock); | ||
312 | num = server->in_flight; | ||
313 | spin_unlock(&server->req_lock); | ||
314 | return num; | ||
315 | } | ||
316 | |||
317 | static inline void | ||
318 | dec_in_flight(struct TCP_Server_Info *server) | ||
319 | { | ||
320 | spin_lock(&server->req_lock); | ||
321 | server->in_flight--; | ||
322 | spin_unlock(&server->req_lock); | ||
323 | } | ||
324 | |||
306 | /* | 325 | /* |
307 | * Macros to allow the TCP_Server_Info->net field and related code to drop out | 326 | * Macros to allow the TCP_Server_Info->net field and related code to drop out |
308 | * when CONFIG_NET_NS isn't set. | 327 | * when CONFIG_NET_NS isn't set. |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index cd66b76e3282..d7cbcfa21a0c 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -721,7 +721,7 @@ cifs_echo_callback(struct mid_q_entry *mid) | |||
721 | struct TCP_Server_Info *server = mid->callback_data; | 721 | struct TCP_Server_Info *server = mid->callback_data; |
722 | 722 | ||
723 | DeleteMidQEntry(mid); | 723 | DeleteMidQEntry(mid); |
724 | atomic_dec(&server->inFlight); | 724 | dec_in_flight(server); |
725 | wake_up(&server->request_q); | 725 | wake_up(&server->request_q); |
726 | } | 726 | } |
727 | 727 | ||
@@ -1674,7 +1674,7 @@ cifs_readv_callback(struct mid_q_entry *mid) | |||
1674 | 1674 | ||
1675 | queue_work(system_nrt_wq, &rdata->work); | 1675 | queue_work(system_nrt_wq, &rdata->work); |
1676 | DeleteMidQEntry(mid); | 1676 | DeleteMidQEntry(mid); |
1677 | atomic_dec(&server->inFlight); | 1677 | dec_in_flight(server); |
1678 | wake_up(&server->request_q); | 1678 | wake_up(&server->request_q); |
1679 | } | 1679 | } |
1680 | 1680 | ||
@@ -2115,7 +2115,7 @@ cifs_writev_callback(struct mid_q_entry *mid) | |||
2115 | 2115 | ||
2116 | queue_work(system_nrt_wq, &wdata->work); | 2116 | queue_work(system_nrt_wq, &wdata->work); |
2117 | DeleteMidQEntry(mid); | 2117 | DeleteMidQEntry(mid); |
2118 | atomic_dec(&tcon->ses->server->inFlight); | 2118 | dec_in_flight(tcon->ses->server); |
2119 | wake_up(&tcon->ses->server->request_q); | 2119 | wake_up(&tcon->ses->server->request_q); |
2120 | } | 2120 | } |
2121 | 2121 | ||
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 0ac595c8c262..ed91abcce8a9 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -643,14 +643,14 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server) | |||
643 | wake_up_all(&server->response_q); | 643 | wake_up_all(&server->response_q); |
644 | 644 | ||
645 | /* Check if we have blocked requests that need to free. */ | 645 | /* Check if we have blocked requests that need to free. */ |
646 | spin_lock(&GlobalMid_Lock); | 646 | spin_lock(&server->req_lock); |
647 | if (atomic_read(&server->inFlight) >= server->maxReq) | 647 | if (server->in_flight >= server->maxReq) |
648 | atomic_set(&server->inFlight, server->maxReq - 1); | 648 | server->in_flight = server->maxReq - 1; |
649 | /* | 649 | /* |
650 | * We do not want to set the max_pending too low or we could end up | 650 | * We do not want to set the max_pending too low or we could end up |
651 | * with the counter going negative. | 651 | * with the counter going negative. |
652 | */ | 652 | */ |
653 | spin_unlock(&GlobalMid_Lock); | 653 | spin_unlock(&server->req_lock); |
654 | /* | 654 | /* |
655 | * Although there should not be any requests blocked on this queue it | 655 | * Although there should not be any requests blocked on this queue it |
656 | * can not hurt to be paranoid and try to wake up requests that may | 656 | * can not hurt to be paranoid and try to wake up requests that may |
@@ -1905,7 +1905,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) | |||
1905 | tcp_ses->noblocksnd = volume_info->noblocksnd; | 1905 | tcp_ses->noblocksnd = volume_info->noblocksnd; |
1906 | tcp_ses->noautotune = volume_info->noautotune; | 1906 | tcp_ses->noautotune = volume_info->noautotune; |
1907 | tcp_ses->tcp_nodelay = volume_info->sockopt_tcp_nodelay; | 1907 | tcp_ses->tcp_nodelay = volume_info->sockopt_tcp_nodelay; |
1908 | atomic_set(&tcp_ses->inFlight, 0); | 1908 | tcp_ses->in_flight = 0; |
1909 | tcp_ses->maxReq = 1; /* enough to send negotiate request */ | 1909 | tcp_ses->maxReq = 1; /* enough to send negotiate request */ |
1910 | init_waitqueue_head(&tcp_ses->response_q); | 1910 | init_waitqueue_head(&tcp_ses->response_q); |
1911 | init_waitqueue_head(&tcp_ses->request_q); | 1911 | init_waitqueue_head(&tcp_ses->request_q); |
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; |