aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2011-01-11 07:24:02 -0500
committerSteve French <sfrench@us.ibm.com>2011-01-19 12:52:42 -0500
commitddc8cf8fc718587a3788330bf4f32b379f08b250 (patch)
tree16d19dfa8f98404ab453e8bb2ef765ec4d67a467 /fs
parent8097531a5cb55c6472118da094dc88caf9be66ac (diff)
cifs: move locked sections out of DeleteMidQEntry and AllocMidQEntry
In later patches, we're going to need to have finer-grained control over the addition and removal of these structs from the pending_mid_q and we'll need to be able to call the destructor while holding the spinlock. Move the locked sections out of both routines and into the callers. Fix up current callers of DeleteMidQEntry to call a new routine that dequeues the entry and then destroys it. Reviewed-by: Suresh Jayaraman <sjayaraman@suse.de> Reviewed-by: Pavel Shilovsky <piastryyy@gmail.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/transport.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index b9eb0cffa003..801726b11e1e 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -63,9 +63,6 @@ AllocMidQEntry(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server)
63 63
64 atomic_inc(&midCount); 64 atomic_inc(&midCount);
65 temp->midState = MID_REQUEST_ALLOCATED; 65 temp->midState = MID_REQUEST_ALLOCATED;
66 spin_lock(&GlobalMid_Lock);
67 list_add_tail(&temp->qhead, &server->pending_mid_q);
68 spin_unlock(&GlobalMid_Lock);
69 return temp; 66 return temp;
70} 67}
71 68
@@ -75,10 +72,7 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
75#ifdef CONFIG_CIFS_STATS2 72#ifdef CONFIG_CIFS_STATS2
76 unsigned long now; 73 unsigned long now;
77#endif 74#endif
78 spin_lock(&GlobalMid_Lock);
79 midEntry->midState = MID_FREE; 75 midEntry->midState = MID_FREE;
80 list_del(&midEntry->qhead);
81 spin_unlock(&GlobalMid_Lock);
82 atomic_dec(&midCount); 76 atomic_dec(&midCount);
83 if (midEntry->largeBuf) 77 if (midEntry->largeBuf)
84 cifs_buf_release(midEntry->resp_buf); 78 cifs_buf_release(midEntry->resp_buf);
@@ -103,6 +97,16 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
103 mempool_free(midEntry, cifs_mid_poolp); 97 mempool_free(midEntry, cifs_mid_poolp);
104} 98}
105 99
100static void
101delete_mid(struct mid_q_entry *mid)
102{
103 spin_lock(&GlobalMid_Lock);
104 list_del(&mid->qhead);
105 spin_unlock(&GlobalMid_Lock);
106
107 DeleteMidQEntry(mid);
108}
109
106static int 110static int
107smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec) 111smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
108{ 112{
@@ -308,6 +312,9 @@ static int allocate_mid(struct cifsSesInfo *ses, struct smb_hdr *in_buf,
308 *ppmidQ = AllocMidQEntry(in_buf, ses->server); 312 *ppmidQ = AllocMidQEntry(in_buf, ses->server);
309 if (*ppmidQ == NULL) 313 if (*ppmidQ == NULL)
310 return -ENOMEM; 314 return -ENOMEM;
315 spin_lock(&GlobalMid_Lock);
316 list_add_tail(&(*ppmidQ)->qhead, &ses->server->pending_mid_q);
317 spin_unlock(&GlobalMid_Lock);
311 return 0; 318 return 0;
312} 319}
313 320
@@ -508,7 +515,7 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
508 } 515 }
509 } 516 }
510 spin_unlock(&GlobalMid_Lock); 517 spin_unlock(&GlobalMid_Lock);
511 DeleteMidQEntry(midQ); 518 delete_mid(midQ);
512 /* Update # of requests on wire to server */ 519 /* Update # of requests on wire to server */
513 atomic_dec(&ses->server->inFlight); 520 atomic_dec(&ses->server->inFlight);
514 wake_up(&ses->server->request_q); 521 wake_up(&ses->server->request_q);
@@ -564,14 +571,14 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
564 if ((flags & CIFS_NO_RESP) == 0) 571 if ((flags & CIFS_NO_RESP) == 0)
565 midQ->resp_buf = NULL; /* mark it so buf will 572 midQ->resp_buf = NULL; /* mark it so buf will
566 not be freed by 573 not be freed by
567 DeleteMidQEntry */ 574 delete_mid */
568 } else { 575 } else {
569 rc = -EIO; 576 rc = -EIO;
570 cFYI(1, "Bad MID state?"); 577 cFYI(1, "Bad MID state?");
571 } 578 }
572 579
573out: 580out:
574 DeleteMidQEntry(midQ); 581 delete_mid(midQ);
575 atomic_dec(&ses->server->inFlight); 582 atomic_dec(&ses->server->inFlight);
576 wake_up(&ses->server->request_q); 583 wake_up(&ses->server->request_q);
577 584
@@ -699,7 +706,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
699 } 706 }
700 } 707 }
701 spin_unlock(&GlobalMid_Lock); 708 spin_unlock(&GlobalMid_Lock);
702 DeleteMidQEntry(midQ); 709 delete_mid(midQ);
703 /* Update # of requests on wire to server */ 710 /* Update # of requests on wire to server */
704 atomic_dec(&ses->server->inFlight); 711 atomic_dec(&ses->server->inFlight);
705 wake_up(&ses->server->request_q); 712 wake_up(&ses->server->request_q);
@@ -755,7 +762,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
755 } 762 }
756 763
757out: 764out:
758 DeleteMidQEntry(midQ); 765 delete_mid(midQ);
759 atomic_dec(&ses->server->inFlight); 766 atomic_dec(&ses->server->inFlight);
760 wake_up(&ses->server->request_q); 767 wake_up(&ses->server->request_q);
761 768
@@ -863,7 +870,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon,
863 870
864 rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number); 871 rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
865 if (rc) { 872 if (rc) {
866 DeleteMidQEntry(midQ); 873 delete_mid(midQ);
867 mutex_unlock(&ses->server->srv_mutex); 874 mutex_unlock(&ses->server->srv_mutex);
868 return rc; 875 return rc;
869 } 876 }
@@ -880,7 +887,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon,
880 mutex_unlock(&ses->server->srv_mutex); 887 mutex_unlock(&ses->server->srv_mutex);
881 888
882 if (rc < 0) { 889 if (rc < 0) {
883 DeleteMidQEntry(midQ); 890 delete_mid(midQ);
884 return rc; 891 return rc;
885 } 892 }
886 893
@@ -902,7 +909,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon,
902 909
903 rc = send_nt_cancel(tcon, in_buf, midQ); 910 rc = send_nt_cancel(tcon, in_buf, midQ);
904 if (rc) { 911 if (rc) {
905 DeleteMidQEntry(midQ); 912 delete_mid(midQ);
906 return rc; 913 return rc;
907 } 914 }
908 } else { 915 } else {
@@ -914,7 +921,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon,
914 /* If we get -ENOLCK back the lock may have 921 /* If we get -ENOLCK back the lock may have
915 already been removed. Don't exit in this case. */ 922 already been removed. Don't exit in this case. */
916 if (rc && rc != -ENOLCK) { 923 if (rc && rc != -ENOLCK) {
917 DeleteMidQEntry(midQ); 924 delete_mid(midQ);
918 return rc; 925 return rc;
919 } 926 }
920 } 927 }
@@ -951,7 +958,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon,
951 } 958 }
952 } 959 }
953 spin_unlock(&GlobalMid_Lock); 960 spin_unlock(&GlobalMid_Lock);
954 DeleteMidQEntry(midQ); 961 delete_mid(midQ);
955 return rc; 962 return rc;
956 } 963 }
957 964
@@ -1001,7 +1008,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon,
1001 BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf)); 1008 BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf));
1002 1009
1003out: 1010out:
1004 DeleteMidQEntry(midQ); 1011 delete_mid(midQ);
1005 if (rstart && rc == -EACCES) 1012 if (rstart && rc == -EACCES)
1006 return -ERESTARTSYS; 1013 return -ERESTARTSYS;
1007 return rc; 1014 return rc;