@@ -91,6 +91,7 @@ struct p9_poll_wait {
91
91
* @mux_list: list link for mux to manage multiple connections (?)
92
92
* @client: reference to client instance for this connection
93
93
* @err: error state
94
+ * @req_lock: lock protecting req_list and requests statuses
94
95
* @req_list: accounting for requests which have been sent
95
96
* @unsent_req_list: accounting for requests that haven't been sent
96
97
* @rreq: read request
@@ -114,6 +115,7 @@ struct p9_conn {
114
115
struct list_head mux_list ;
115
116
struct p9_client * client ;
116
117
int err ;
118
+ spinlock_t req_lock ;
117
119
struct list_head req_list ;
118
120
struct list_head unsent_req_list ;
119
121
struct p9_req_t * rreq ;
@@ -189,10 +191,10 @@ static void p9_conn_cancel(struct p9_conn *m, int err)
189
191
190
192
p9_debug (P9_DEBUG_ERROR , "mux %p err %d\n" , m , err );
191
193
192
- spin_lock (& m -> client -> lock );
194
+ spin_lock (& m -> req_lock );
193
195
194
196
if (m -> err ) {
195
- spin_unlock (& m -> client -> lock );
197
+ spin_unlock (& m -> req_lock );
196
198
return ;
197
199
}
198
200
@@ -205,7 +207,7 @@ static void p9_conn_cancel(struct p9_conn *m, int err)
205
207
list_move (& req -> req_list , & cancel_list );
206
208
}
207
209
208
- spin_unlock (& m -> client -> lock );
210
+ spin_unlock (& m -> req_lock );
209
211
210
212
list_for_each_entry_safe (req , rtmp , & cancel_list , req_list ) {
211
213
p9_debug (P9_DEBUG_ERROR , "call back req %p\n" , req );
@@ -360,7 +362,7 @@ static void p9_read_work(struct work_struct *work)
360
362
if ((m -> rreq ) && (m -> rc .offset == m -> rc .capacity )) {
361
363
p9_debug (P9_DEBUG_TRANS , "got new packet\n" );
362
364
m -> rreq -> rc .size = m -> rc .offset ;
363
- spin_lock (& m -> client -> lock );
365
+ spin_lock (& m -> req_lock );
364
366
if (m -> rreq -> status == REQ_STATUS_SENT ) {
365
367
list_del (& m -> rreq -> req_list );
366
368
p9_client_cb (m -> client , m -> rreq , REQ_STATUS_RCVD );
@@ -369,14 +371,14 @@ static void p9_read_work(struct work_struct *work)
369
371
p9_debug (P9_DEBUG_TRANS ,
370
372
"Ignore replies associated with a cancelled request\n" );
371
373
} else {
372
- spin_unlock (& m -> client -> lock );
374
+ spin_unlock (& m -> req_lock );
373
375
p9_debug (P9_DEBUG_ERROR ,
374
376
"Request tag %d errored out while we were reading the reply\n" ,
375
377
m -> rc .tag );
376
378
err = - EIO ;
377
379
goto error ;
378
380
}
379
- spin_unlock (& m -> client -> lock );
381
+ spin_unlock (& m -> req_lock );
380
382
m -> rc .sdata = NULL ;
381
383
m -> rc .offset = 0 ;
382
384
m -> rc .capacity = 0 ;
@@ -454,10 +456,10 @@ static void p9_write_work(struct work_struct *work)
454
456
}
455
457
456
458
if (!m -> wsize ) {
457
- spin_lock (& m -> client -> lock );
459
+ spin_lock (& m -> req_lock );
458
460
if (list_empty (& m -> unsent_req_list )) {
459
461
clear_bit (Wworksched , & m -> wsched );
460
- spin_unlock (& m -> client -> lock );
462
+ spin_unlock (& m -> req_lock );
461
463
return ;
462
464
}
463
465
@@ -472,7 +474,7 @@ static void p9_write_work(struct work_struct *work)
472
474
m -> wpos = 0 ;
473
475
p9_req_get (req );
474
476
m -> wreq = req ;
475
- spin_unlock (& m -> client -> lock );
477
+ spin_unlock (& m -> req_lock );
476
478
}
477
479
478
480
p9_debug (P9_DEBUG_TRANS , "mux %p pos %d size %d\n" ,
@@ -589,6 +591,7 @@ static void p9_conn_create(struct p9_client *client)
589
591
INIT_LIST_HEAD (& m -> mux_list );
590
592
m -> client = client ;
591
593
594
+ spin_lock_init (& m -> req_lock );
592
595
INIT_LIST_HEAD (& m -> req_list );
593
596
INIT_LIST_HEAD (& m -> unsent_req_list );
594
597
INIT_WORK (& m -> rq , p9_read_work );
@@ -670,10 +673,10 @@ static int p9_fd_request(struct p9_client *client, struct p9_req_t *req)
670
673
if (m -> err < 0 )
671
674
return m -> err ;
672
675
673
- spin_lock (& client -> lock );
676
+ spin_lock (& m -> req_lock );
674
677
req -> status = REQ_STATUS_UNSENT ;
675
678
list_add_tail (& req -> req_list , & m -> unsent_req_list );
676
- spin_unlock (& client -> lock );
679
+ spin_unlock (& m -> req_lock );
677
680
678
681
if (test_and_clear_bit (Wpending , & m -> wsched ))
679
682
n = EPOLLOUT ;
@@ -688,33 +691,38 @@ static int p9_fd_request(struct p9_client *client, struct p9_req_t *req)
688
691
689
692
static int p9_fd_cancel (struct p9_client * client , struct p9_req_t * req )
690
693
{
694
+ struct p9_trans_fd * ts = client -> trans ;
695
+ struct p9_conn * m = & ts -> conn ;
691
696
int ret = 1 ;
692
697
693
698
p9_debug (P9_DEBUG_TRANS , "client %p req %p\n" , client , req );
694
699
695
- spin_lock (& client -> lock );
700
+ spin_lock (& m -> req_lock );
696
701
697
702
if (req -> status == REQ_STATUS_UNSENT ) {
698
703
list_del (& req -> req_list );
699
704
req -> status = REQ_STATUS_FLSHD ;
700
705
p9_req_put (client , req );
701
706
ret = 0 ;
702
707
}
703
- spin_unlock (& client -> lock );
708
+ spin_unlock (& m -> req_lock );
704
709
705
710
return ret ;
706
711
}
707
712
708
713
static int p9_fd_cancelled (struct p9_client * client , struct p9_req_t * req )
709
714
{
715
+ struct p9_trans_fd * ts = client -> trans ;
716
+ struct p9_conn * m = & ts -> conn ;
717
+
710
718
p9_debug (P9_DEBUG_TRANS , "client %p req %p\n" , client , req );
711
719
712
- spin_lock (& client -> lock );
720
+ spin_lock (& m -> req_lock );
713
721
/* Ignore cancelled request if message has been received
714
722
* before lock.
715
723
*/
716
724
if (req -> status == REQ_STATUS_RCVD ) {
717
- spin_unlock (& client -> lock );
725
+ spin_unlock (& m -> req_lock );
718
726
return 0 ;
719
727
}
720
728
@@ -723,7 +731,8 @@ static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req)
723
731
*/
724
732
list_del (& req -> req_list );
725
733
req -> status = REQ_STATUS_FLSHD ;
726
- spin_unlock (& client -> lock );
734
+ spin_unlock (& m -> req_lock );
735
+
727
736
p9_req_put (client , req );
728
737
729
738
return 0 ;
0 commit comments