Merge branch 'afs' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs

Pull AFS fixes and cleanups from David Howells:
"Here are some patches to the AFS filesystem:

1) Fix problems in the clean-up parts of the cache manager service
handler.

2) Split afs_end_call() introduced in (1) and replace some identical
code elsewhere with a call to the first half of the split function.

3) Fix an error introduced in the workqueue PREPARE_WORK() elimination
commits.

4) Clean up argument passing to functions called from the workqueue as
there's now an insulating layer between them and the workqueue.
This is possible from (3)"

* 'afs' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
AFS: Pass an afs_call* to call->async_workfn() instead of a work_struct*
AFS: Fix kafs module unloading
AFS: Part of afs_end_call() is identical to code elsewhere, so split it
AFS: Fix cache manager service handlers

Changed files
+63 -44
fs
+19
fs/afs/cmservice.c
··· 130 130 { 131 131 _enter(""); 132 132 133 + /* Break the callbacks here so that we do it after the final ACK is 134 + * received. The step number here must match the final number in 135 + * afs_deliver_cb_callback(). 136 + */ 137 + if (call->unmarshall == 6) { 138 + ASSERT(call->server && call->count && call->request); 139 + afs_break_callbacks(call->server, call->count, call->request); 140 + } 141 + 133 142 afs_put_server(call->server); 134 143 call->server = NULL; 135 144 kfree(call->buffer); ··· 281 272 _debug("trailer"); 282 273 if (skb->len != 0) 283 274 return -EBADMSG; 275 + 276 + /* Record that the message was unmarshalled successfully so 277 + * that the call destructor can know do the callback breaking 278 + * work, even if the final ACK isn't received. 279 + * 280 + * If the step number changes, then afs_cm_destructor() must be 281 + * updated also. 282 + */ 283 + call->unmarshall++; 284 + case 6: 284 285 break; 285 286 } 286 287
+1 -1
fs/afs/internal.h
··· 75 75 const struct afs_call_type *type; /* type of call */ 76 76 const struct afs_wait_mode *wait_mode; /* completion wait mode */ 77 77 wait_queue_head_t waitq; /* processes awaiting completion */ 78 - work_func_t async_workfn; 78 + void (*async_workfn)(struct afs_call *call); /* asynchronous work function */ 79 79 struct work_struct async_work; /* asynchronous work processor */ 80 80 struct work_struct work; /* actual work processor */ 81 81 struct sk_buff_head rx_queue; /* received packets */
+43 -43
fs/afs/rxrpc.c
··· 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 ··· 57 57 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 + 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 + } 60 67 61 68 /* 62 69 * open an RxRPC socket and bind it to be a server for callback notifications ··· 188 181 189 182 kfree(call->request); 190 183 kfree(call); 184 + } 185 + 186 + /* 187 + * End a call but do not free it 188 + */ 189 + static void afs_end_call_nofree(struct afs_call *call) 190 + { 191 + if (call->rxcall) { 192 + rxrpc_kernel_end_call(call->rxcall); 193 + call->rxcall = NULL; 194 + } 195 + if (call->type->destructor) 196 + call->type->destructor(call); 197 + } 198 + 199 + /* 200 + * End a call and free it 201 + */ 202 + static void afs_end_call(struct afs_call *call) 203 + { 204 + afs_end_call_nofree(call); 205 + afs_free_call(call); 191 206 } 192 207 193 208 /* ··· 355 326 atomic_read(&afs_outstanding_calls)); 356 327 357 328 call->wait_mode = wait_mode; 358 - INIT_WORK(&call->async_work, afs_process_async_call); 329 + call->async_workfn = afs_process_async_call; 330 + INIT_WORK(&call->async_work, afs_async_workfn); 359 331 360 332 memset(&srx, 0, sizeof(srx)); 361 333 srx.srx_family = AF_RXRPC; ··· 413 383 rxrpc_kernel_abort_call(rxcall, RX_USER_ABORT); 414 384 while ((skb = skb_dequeue(&call->rx_queue))) 415 385 afs_free_skb(skb); 416 - rxrpc_kernel_end_call(rxcall); 417 - call->rxcall = NULL; 418 386 error_kill_call: 419 - call->type->destructor(call); 420 - afs_free_call(call); 387 + afs_end_call(call); 421 388 _leave(" = %d", ret); 422 389 return ret; 423 390 } ··· 536 509 if (call->state >= AFS_CALL_COMPLETE) { 537 510 while ((skb = skb_dequeue(&call->rx_queue))) 538 511 afs_free_skb(skb); 539 - if (call->incoming) { 540 - rxrpc_kernel_end_call(call->rxcall); 541 - call->rxcall = NULL; 542 - call->type->destructor(call); 543 - afs_free_call(call); 544 - } 512 + if (call->incoming) 513 + afs_end_call(call); 545 514 } 546 515 547 516 _leave(""); ··· 587 564 } 588 565 589 566 _debug("call complete"); 590 - rxrpc_kernel_end_call(call->rxcall); 591 - call->rxcall = NULL; 592 - call->type->destructor(call); 593 - afs_free_call(call); 567 + afs_end_call(call); 594 568 _leave(" = %d", ret); 595 569 return ret; 596 570 } ··· 623 603 /* 624 604 * delete an asynchronous call 625 605 */ 626 - static void afs_delete_async_call(struct work_struct *work) 606 + static void afs_delete_async_call(struct afs_call *call) 627 607 { 628 - struct afs_call *call = 629 - container_of(work, struct afs_call, async_work); 630 - 631 608 _enter(""); 632 609 633 610 afs_free_call(call); ··· 637 620 * - on a multiple-thread workqueue this work item may try to run on several 638 621 * CPUs at the same time 639 622 */ 640 - static void afs_process_async_call(struct work_struct *work) 623 + static void afs_process_async_call(struct afs_call *call) 641 624 { 642 - struct afs_call *call = 643 - container_of(work, struct afs_call, async_work); 644 - 645 625 _enter(""); 646 626 647 627 if (!skb_queue_empty(&call->rx_queue)) ··· 651 637 call->reply = NULL; 652 638 653 639 /* kill the call */ 654 - rxrpc_kernel_end_call(call->rxcall); 655 - call->rxcall = NULL; 656 - if (call->type->destructor) 657 - call->type->destructor(call); 640 + afs_end_call_nofree(call); 658 641 659 642 /* we can't just delete the call because the work item may be 660 643 * queued */ ··· 672 661 if (skb_copy_bits(skb, 0, call->buffer + call->reply_size, len) < 0) 673 662 BUG(); 674 663 call->reply_size += len; 675 - } 676 - 677 - static void afs_async_workfn(struct work_struct *work) 678 - { 679 - struct afs_call *call = container_of(work, struct afs_call, async_work); 680 - 681 - call->async_workfn(work); 682 664 } 683 665 684 666 /* ··· 794 790 _debug("oom"); 795 791 rxrpc_kernel_abort_call(call->rxcall, RX_USER_ABORT); 796 792 default: 797 - rxrpc_kernel_end_call(call->rxcall); 798 - call->rxcall = NULL; 799 - call->type->destructor(call); 800 - afs_free_call(call); 793 + afs_end_call(call); 801 794 _leave(" [error]"); 802 795 return; 803 796 } ··· 824 823 call->state = AFS_CALL_AWAIT_ACK; 825 824 n = rxrpc_kernel_send_data(call->rxcall, &msg, len); 826 825 if (n >= 0) { 826 + /* Success */ 827 827 _leave(" [replied]"); 828 828 return; 829 829 } 830 + 830 831 if (n == -ENOMEM) { 831 832 _debug("oom"); 832 833 rxrpc_kernel_abort_call(call->rxcall, RX_USER_ABORT); 833 834 } 834 - rxrpc_kernel_end_call(call->rxcall); 835 - call->rxcall = NULL; 836 - call->type->destructor(call); 837 - afs_free_call(call); 835 + afs_end_call(call); 838 836 _leave(" [error]"); 839 837 } 840 838