@@ -25,7 +25,7 @@ static void afs_wake_up_call_waiter(struct afs_call *);
25
25
static int afs_wait_for_call_to_complete (struct afs_call * );
26
26
static void afs_wake_up_async_call (struct afs_call * );
27
27
static int afs_dont_wait_for_call_to_complete (struct afs_call * );
28
- static void afs_process_async_call (struct work_struct * );
28
+ static void afs_process_async_call (struct afs_call * );
29
29
static void afs_rx_interceptor (struct sock * , unsigned long , struct sk_buff * );
30
30
static int afs_deliver_cm_op_id (struct afs_call * , struct sk_buff * , bool );
31
31
@@ -58,6 +58,13 @@ static void afs_collect_incoming_call(struct work_struct *);
58
58
static struct sk_buff_head afs_incoming_calls ;
59
59
static DECLARE_WORK (afs_collect_incoming_call_work , afs_collect_incoming_call ) ;
60
60
61
+ static void afs_async_workfn (struct work_struct * work )
62
+ {
63
+ struct afs_call * call = container_of (work , struct afs_call , async_work );
64
+
65
+ call -> async_workfn (call );
66
+ }
67
+
61
68
/*
62
69
* open an RxRPC socket and bind it to be a server for callback notifications
63
70
* - the socket is left in blocking mode and non-blocking ops use MSG_DONTWAIT
@@ -183,6 +190,28 @@ static void afs_free_call(struct afs_call *call)
183
190
kfree (call );
184
191
}
185
192
193
+ /*
194
+ * End a call but do not free it
195
+ */
196
+ static void afs_end_call_nofree (struct afs_call * call )
197
+ {
198
+ if (call -> rxcall ) {
199
+ rxrpc_kernel_end_call (call -> rxcall );
200
+ call -> rxcall = NULL ;
201
+ }
202
+ if (call -> type -> destructor )
203
+ call -> type -> destructor (call );
204
+ }
205
+
206
+ /*
207
+ * End a call and free it
208
+ */
209
+ static void afs_end_call (struct afs_call * call )
210
+ {
211
+ afs_end_call_nofree (call );
212
+ afs_free_call (call );
213
+ }
214
+
186
215
/*
187
216
* allocate a call with flat request and reply buffers
188
217
*/
@@ -326,7 +355,8 @@ int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp,
326
355
atomic_read (& afs_outstanding_calls ));
327
356
328
357
call -> wait_mode = wait_mode ;
329
- INIT_WORK (& call -> async_work , afs_process_async_call );
358
+ call -> async_workfn = afs_process_async_call ;
359
+ INIT_WORK (& call -> async_work , afs_async_workfn );
330
360
331
361
memset (& srx , 0 , sizeof (srx ));
332
362
srx .srx_family = AF_RXRPC ;
@@ -383,11 +413,8 @@ int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp,
383
413
rxrpc_kernel_abort_call (rxcall , RX_USER_ABORT );
384
414
while ((skb = skb_dequeue (& call -> rx_queue )))
385
415
afs_free_skb (skb );
386
- rxrpc_kernel_end_call (rxcall );
387
- call -> rxcall = NULL ;
388
416
error_kill_call :
389
- call -> type -> destructor (call );
390
- afs_free_call (call );
417
+ afs_end_call (call );
391
418
_leave (" = %d" , ret );
392
419
return ret ;
393
420
}
@@ -509,12 +536,8 @@ static void afs_deliver_to_call(struct afs_call *call)
509
536
if (call -> state >= AFS_CALL_COMPLETE ) {
510
537
while ((skb = skb_dequeue (& call -> rx_queue )))
511
538
afs_free_skb (skb );
512
- if (call -> incoming ) {
513
- rxrpc_kernel_end_call (call -> rxcall );
514
- call -> rxcall = NULL ;
515
- call -> type -> destructor (call );
516
- afs_free_call (call );
517
- }
539
+ if (call -> incoming )
540
+ afs_end_call (call );
518
541
}
519
542
520
543
_leave ("" );
@@ -564,10 +587,7 @@ static int afs_wait_for_call_to_complete(struct afs_call *call)
564
587
}
565
588
566
589
_debug ("call complete" );
567
- rxrpc_kernel_end_call (call -> rxcall );
568
- call -> rxcall = NULL ;
569
- call -> type -> destructor (call );
570
- afs_free_call (call );
590
+ afs_end_call (call );
571
591
_leave (" = %d" , ret );
572
592
return ret ;
573
593
}
@@ -603,11 +623,8 @@ static int afs_dont_wait_for_call_to_complete(struct afs_call *call)
603
623
/*
604
624
* delete an asynchronous call
605
625
*/
606
- static void afs_delete_async_call (struct work_struct * work )
626
+ static void afs_delete_async_call (struct afs_call * call )
607
627
{
608
- struct afs_call * call =
609
- container_of (work , struct afs_call , async_work );
610
-
611
628
_enter ("" );
612
629
613
630
afs_free_call (call );
@@ -620,11 +637,8 @@ static void afs_delete_async_call(struct work_struct *work)
620
637
* - on a multiple-thread workqueue this work item may try to run on several
621
638
* CPUs at the same time
622
639
*/
623
- static void afs_process_async_call (struct work_struct * work )
640
+ static void afs_process_async_call (struct afs_call * call )
624
641
{
625
- struct afs_call * call =
626
- container_of (work , struct afs_call , async_work );
627
-
628
642
_enter ("" );
629
643
630
644
if (!skb_queue_empty (& call -> rx_queue ))
@@ -637,10 +651,7 @@ static void afs_process_async_call(struct work_struct *work)
637
651
call -> reply = NULL ;
638
652
639
653
/* kill the call */
640
- rxrpc_kernel_end_call (call -> rxcall );
641
- call -> rxcall = NULL ;
642
- if (call -> type -> destructor )
643
- call -> type -> destructor (call );
654
+ afs_end_call_nofree (call );
644
655
645
656
/* we can't just delete the call because the work item may be
646
657
* queued */
@@ -663,13 +674,6 @@ void afs_transfer_reply(struct afs_call *call, struct sk_buff *skb)
663
674
call -> reply_size += len ;
664
675
}
665
676
666
- static void afs_async_workfn (struct work_struct * work )
667
- {
668
- struct afs_call * call = container_of (work , struct afs_call , async_work );
669
-
670
- call -> async_workfn (work );
671
- }
672
-
673
677
/*
674
678
* accept the backlog of incoming calls
675
679
*/
@@ -790,10 +794,7 @@ void afs_send_empty_reply(struct afs_call *call)
790
794
_debug ("oom" );
791
795
rxrpc_kernel_abort_call (call -> rxcall , RX_USER_ABORT );
792
796
default :
793
- rxrpc_kernel_end_call (call -> rxcall );
794
- call -> rxcall = NULL ;
795
- call -> type -> destructor (call );
796
- afs_free_call (call );
797
+ afs_end_call (call );
797
798
_leave (" [error]" );
798
799
return ;
799
800
}
@@ -823,17 +824,16 @@ void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len)
823
824
call -> state = AFS_CALL_AWAIT_ACK ;
824
825
n = rxrpc_kernel_send_data (call -> rxcall , & msg , len );
825
826
if (n >= 0 ) {
827
+ /* Success */
826
828
_leave (" [replied]" );
827
829
return ;
828
830
}
831
+
829
832
if (n == - ENOMEM ) {
830
833
_debug ("oom" );
831
834
rxrpc_kernel_abort_call (call -> rxcall , RX_USER_ABORT );
832
835
}
833
- rxrpc_kernel_end_call (call -> rxcall );
834
- call -> rxcall = NULL ;
835
- call -> type -> destructor (call );
836
- afs_free_call (call );
836
+ afs_end_call (call );
837
837
_leave (" [error]" );
838
838
}
839
839
0 commit comments