rxrpc.c (39c6aceae961776a11a3767553b0e295fc9d413b) | rxrpc.c (8e8d7f13b6d5a93b3d2cf9a4ceaaf923809fd5ac) |
---|---|
1/* Maintain an RxRPC server socket to do AFS communications through 2 * 3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 4 * Written by David Howells (dhowells@redhat.com) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 235 unchanged lines hidden (view full) --- 244 call->request = NULL; 245 kfree(call->buffer); 246 call->buffer = NULL; 247} 248 249/* 250 * attach the data from a bunch of pages on an inode to a call 251 */ | 1/* Maintain an RxRPC server socket to do AFS communications through 2 * 3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 4 * Written by David Howells (dhowells@redhat.com) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 235 unchanged lines hidden (view full) --- 244 call->request = NULL; 245 kfree(call->buffer); 246 call->buffer = NULL; 247} 248 249/* 250 * attach the data from a bunch of pages on an inode to a call 251 */ |
252static int afs_send_pages(struct afs_call *call, struct msghdr *msg) | 252static int afs_send_pages(struct afs_call *call, struct msghdr *msg, 253 struct kvec *iov) |
253{ 254 struct page *pages[8]; 255 unsigned count, n, loop, offset, to; 256 pgoff_t first = call->first, last = call->last; 257 int ret; 258 259 _enter(""); 260 --- 6 unchanged lines hidden (view full) --- 267 count = last - first + 1; 268 if (count > ARRAY_SIZE(pages)) 269 count = ARRAY_SIZE(pages); 270 n = find_get_pages_contig(call->mapping, first, count, pages); 271 ASSERTCMP(n, ==, count); 272 273 loop = 0; 274 do { | 254{ 255 struct page *pages[8]; 256 unsigned count, n, loop, offset, to; 257 pgoff_t first = call->first, last = call->last; 258 int ret; 259 260 _enter(""); 261 --- 6 unchanged lines hidden (view full) --- 268 count = last - first + 1; 269 if (count > ARRAY_SIZE(pages)) 270 count = ARRAY_SIZE(pages); 271 n = find_get_pages_contig(call->mapping, first, count, pages); 272 ASSERTCMP(n, ==, count); 273 274 loop = 0; 275 do { |
275 struct bio_vec bvec = {.bv_page = pages[loop], 276 .bv_offset = offset}; | |
277 msg->msg_flags = 0; 278 to = PAGE_SIZE; 279 if (first + loop >= last) 280 to = call->last_to; 281 else 282 msg->msg_flags = MSG_MORE; | 276 msg->msg_flags = 0; 277 to = PAGE_SIZE; 278 if (first + loop >= last) 279 to = call->last_to; 280 else 281 msg->msg_flags = MSG_MORE; |
283 bvec.bv_len = to - offset; | 282 iov->iov_base = kmap(pages[loop]) + offset; 283 iov->iov_len = to - offset; |
284 offset = 0; 285 286 _debug("- range %u-%u%s", 287 offset, to, msg->msg_flags ? " [more]" : ""); | 284 offset = 0; 285 286 _debug("- range %u-%u%s", 287 offset, to, msg->msg_flags ? " [more]" : ""); |
288 iov_iter_bvec(&msg->msg_iter, WRITE | ITER_BVEC, 289 &bvec, 1, to - offset); | 288 iov_iter_kvec(&msg->msg_iter, WRITE | ITER_KVEC, 289 iov, 1, to - offset); |
290 291 /* have to change the state *before* sending the last 292 * packet as RxRPC might give us the reply before it 293 * returns from sending the request */ 294 if (first + loop >= last) 295 call->state = AFS_CALL_AWAIT_REPLY; 296 ret = rxrpc_kernel_send_data(afs_socket, call->rxcall, 297 msg, to - offset); | 290 291 /* have to change the state *before* sending the last 292 * packet as RxRPC might give us the reply before it 293 * returns from sending the request */ 294 if (first + loop >= last) 295 call->state = AFS_CALL_AWAIT_REPLY; 296 ret = rxrpc_kernel_send_data(afs_socket, call->rxcall, 297 msg, to - offset); |
298 kunmap(pages[loop]); |
|
298 if (ret < 0) 299 break; 300 } while (++loop < count); 301 first += count; 302 303 for (loop = 0; loop < count; loop++) 304 put_page(pages[loop]); 305 if (ret < 0) --- 67 unchanged lines hidden (view full) --- 373 if (!call->send_pages) 374 call->state = AFS_CALL_AWAIT_REPLY; 375 ret = rxrpc_kernel_send_data(afs_socket, rxcall, 376 &msg, call->request_size); 377 if (ret < 0) 378 goto error_do_abort; 379 380 if (call->send_pages) { | 299 if (ret < 0) 300 break; 301 } while (++loop < count); 302 first += count; 303 304 for (loop = 0; loop < count; loop++) 305 put_page(pages[loop]); 306 if (ret < 0) --- 67 unchanged lines hidden (view full) --- 374 if (!call->send_pages) 375 call->state = AFS_CALL_AWAIT_REPLY; 376 ret = rxrpc_kernel_send_data(afs_socket, rxcall, 377 &msg, call->request_size); 378 if (ret < 0) 379 goto error_do_abort; 380 381 if (call->send_pages) { |
381 ret = afs_send_pages(call, &msg); | 382 ret = afs_send_pages(call, &msg, iov); |
382 if (ret < 0) 383 goto error_do_abort; 384 } 385 386 /* at this point, an async call may no longer exist as it may have 387 * already completed */ 388 return wait_mode->wait(call); 389 --- 20 unchanged lines hidden (view full) --- 410 call->state == AFS_CALL_AWAIT_REQUEST || 411 call->state == AFS_CALL_AWAIT_ACK 412 ) { 413 if (call->state == AFS_CALL_AWAIT_ACK) { 414 size_t offset = 0; 415 ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall, 416 NULL, 0, &offset, false, 417 &call->abort_code); | 383 if (ret < 0) 384 goto error_do_abort; 385 } 386 387 /* at this point, an async call may no longer exist as it may have 388 * already completed */ 389 return wait_mode->wait(call); 390 --- 20 unchanged lines hidden (view full) --- 411 call->state == AFS_CALL_AWAIT_REQUEST || 412 call->state == AFS_CALL_AWAIT_ACK 413 ) { 414 if (call->state == AFS_CALL_AWAIT_ACK) { 415 size_t offset = 0; 416 ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall, 417 NULL, 0, &offset, false, 418 &call->abort_code); |
419 trace_afs_recv_data(call, 0, offset, false, ret); 420 |
|
418 if (ret == -EINPROGRESS || ret == -EAGAIN) 419 return; 420 if (ret == 1 || ret < 0) { 421 call->state = AFS_CALL_COMPLETE; 422 goto done; 423 } 424 return; 425 } --- 109 unchanged lines hidden (view full) --- 535/* 536 * wake up an asynchronous call 537 */ 538static void afs_wake_up_async_call(struct sock *sk, struct rxrpc_call *rxcall, 539 unsigned long call_user_ID) 540{ 541 struct afs_call *call = (struct afs_call *)call_user_ID; 542 | 421 if (ret == -EINPROGRESS || ret == -EAGAIN) 422 return; 423 if (ret == 1 || ret < 0) { 424 call->state = AFS_CALL_COMPLETE; 425 goto done; 426 } 427 return; 428 } --- 109 unchanged lines hidden (view full) --- 538/* 539 * wake up an asynchronous call 540 */ 541static void afs_wake_up_async_call(struct sock *sk, struct rxrpc_call *rxcall, 542 unsigned long call_user_ID) 543{ 544 struct afs_call *call = (struct afs_call *)call_user_ID; 545 |
546 trace_afs_notify_call(rxcall, call); |
|
543 call->need_attention = true; 544 queue_work(afs_async_calls, &call->async_work); 545} 546 547/* 548 * put a call into asynchronous mode 549 * - mustn't touch the call descriptor as the call my have completed by the 550 * time we get here --- 132 unchanged lines hidden (view full) --- 683 call->state = AFS_CALL_AWAIT_REQUEST; 684 call->offset = 0; 685 686 /* ask the cache manager to route the call (it'll change the call type 687 * if successful) */ 688 if (!afs_cm_incoming_call(call)) 689 return -ENOTSUPP; 690 | 547 call->need_attention = true; 548 queue_work(afs_async_calls, &call->async_work); 549} 550 551/* 552 * put a call into asynchronous mode 553 * - mustn't touch the call descriptor as the call my have completed by the 554 * time we get here --- 132 unchanged lines hidden (view full) --- 687 call->state = AFS_CALL_AWAIT_REQUEST; 688 call->offset = 0; 689 690 /* ask the cache manager to route the call (it'll change the call type 691 * if successful) */ 692 if (!afs_cm_incoming_call(call)) 693 return -ENOTSUPP; 694 |
695 trace_afs_cb_call(call); 696 |
|
691 /* pass responsibility for the remainer of this message off to the 692 * cache manager op */ 693 return call->type->deliver(call); 694} 695 696/* 697 * send an empty reply 698 */ --- 75 unchanged lines hidden (view full) --- 774 _enter("{%s,%zu},,%zu,%d", 775 call->type->name, call->offset, count, want_more); 776 777 ASSERTCMP(call->offset, <=, count); 778 779 ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall, 780 buf, count, &call->offset, 781 want_more, &call->abort_code); | 697 /* pass responsibility for the remainer of this message off to the 698 * cache manager op */ 699 return call->type->deliver(call); 700} 701 702/* 703 * send an empty reply 704 */ --- 75 unchanged lines hidden (view full) --- 780 _enter("{%s,%zu},,%zu,%d", 781 call->type->name, call->offset, count, want_more); 782 783 ASSERTCMP(call->offset, <=, count); 784 785 ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall, 786 buf, count, &call->offset, 787 want_more, &call->abort_code); |
788 trace_afs_recv_data(call, count, call->offset, want_more, ret); |
|
782 if (ret == 0 || ret == -EAGAIN) 783 return ret; 784 785 if (ret == 1) { 786 switch (call->state) { 787 case AFS_CALL_AWAIT_REPLY: 788 call->state = AFS_CALL_COMPLETE; 789 break; --- 16 unchanged lines hidden --- | 789 if (ret == 0 || ret == -EAGAIN) 790 return ret; 791 792 if (ret == 1) { 793 switch (call->state) { 794 case AFS_CALL_AWAIT_REPLY: 795 call->state = AFS_CALL_COMPLETE; 796 break; --- 16 unchanged lines hidden --- |