call_object.c (96b4059f43ce69e9c590f77d6ce3e99888d5cfe6) | call_object.c (9d35d880e0e4a3ab32d8c12f9e4d76198aadd42d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* RxRPC individual remote procedure call handling 3 * 4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells (dhowells@redhat.com) 6 */ 7 8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt --- 136 unchanged lines hidden (view full) --- 145 */ 146 if (rx->sk.sk_kern_sock) 147 lockdep_set_class(&call->user_mutex, 148 &rxrpc_call_user_mutex_lock_class_key); 149 150 timer_setup(&call->timer, rxrpc_call_timer_expired, 0); 151 INIT_WORK(&call->destroyer, rxrpc_destroy_call); 152 INIT_LIST_HEAD(&call->link); | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* RxRPC individual remote procedure call handling 3 * 4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells (dhowells@redhat.com) 6 */ 7 8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt --- 136 unchanged lines hidden (view full) --- 145 */ 146 if (rx->sk.sk_kern_sock) 147 lockdep_set_class(&call->user_mutex, 148 &rxrpc_call_user_mutex_lock_class_key); 149 150 timer_setup(&call->timer, rxrpc_call_timer_expired, 0); 151 INIT_WORK(&call->destroyer, rxrpc_destroy_call); 152 INIT_LIST_HEAD(&call->link); |
153 INIT_LIST_HEAD(&call->chan_wait_link); | 153 INIT_LIST_HEAD(&call->wait_link); |
154 INIT_LIST_HEAD(&call->accept_link); 155 INIT_LIST_HEAD(&call->recvmsg_link); 156 INIT_LIST_HEAD(&call->sock_link); 157 INIT_LIST_HEAD(&call->attend_link); 158 INIT_LIST_HEAD(&call->tx_sendmsg); 159 INIT_LIST_HEAD(&call->tx_buffer); 160 skb_queue_head_init(&call->recvmsg_queue); 161 skb_queue_head_init(&call->rx_oos_queue); --- 75 unchanged lines hidden (view full) --- 237 238 _leave(" = %p", call); 239 return call; 240} 241 242/* 243 * Initiate the call ack/resend/expiry timer. 244 */ | 154 INIT_LIST_HEAD(&call->accept_link); 155 INIT_LIST_HEAD(&call->recvmsg_link); 156 INIT_LIST_HEAD(&call->sock_link); 157 INIT_LIST_HEAD(&call->attend_link); 158 INIT_LIST_HEAD(&call->tx_sendmsg); 159 INIT_LIST_HEAD(&call->tx_buffer); 160 skb_queue_head_init(&call->recvmsg_queue); 161 skb_queue_head_init(&call->rx_oos_queue); --- 75 unchanged lines hidden (view full) --- 237 238 _leave(" = %p", call); 239 return call; 240} 241 242/* 243 * Initiate the call ack/resend/expiry timer. 244 */ |
245static void rxrpc_start_call_timer(struct rxrpc_call *call) | 245void rxrpc_start_call_timer(struct rxrpc_call *call) |
246{ 247 unsigned long now = jiffies; 248 unsigned long j = now + MAX_JIFFY_OFFSET; 249 250 call->delay_ack_at = j; 251 call->ack_lost_at = j; 252 call->resend_at = j; 253 call->ping_at = j; --- 28 unchanged lines hidden (view full) --- 282 struct semaphore *limiter = &rxrpc_call_limiter; 283 284 if (test_bit(RXRPC_CALL_KERNEL, &call->flags)) 285 limiter = &rxrpc_kernel_call_limiter; 286 up(limiter); 287} 288 289/* | 246{ 247 unsigned long now = jiffies; 248 unsigned long j = now + MAX_JIFFY_OFFSET; 249 250 call->delay_ack_at = j; 251 call->ack_lost_at = j; 252 call->resend_at = j; 253 call->ping_at = j; --- 28 unchanged lines hidden (view full) --- 282 struct semaphore *limiter = &rxrpc_call_limiter; 283 284 if (test_bit(RXRPC_CALL_KERNEL, &call->flags)) 285 limiter = &rxrpc_kernel_call_limiter; 286 up(limiter); 287} 288 289/* |
290 * Start the process of connecting a call. We obtain a peer and a connection 291 * bundle, but the actual association of a call with a connection is offloaded 292 * to the I/O thread to simplify locking. 293 */ 294static int rxrpc_connect_call(struct rxrpc_call *call, gfp_t gfp) 295{ 296 struct rxrpc_local *local = call->local; 297 int ret = 0; 298 299 _enter("{%d,%lx},", call->debug_id, call->user_call_ID); 300 301 call->peer = rxrpc_lookup_peer(local, &call->dest_srx, gfp); 302 if (!call->peer) 303 goto error; 304 305 ret = rxrpc_look_up_bundle(call, gfp); 306 if (ret < 0) 307 goto error; 308 309 trace_rxrpc_client(NULL, -1, rxrpc_client_queue_new_call); 310 rxrpc_get_call(call, rxrpc_call_get_io_thread); 311 spin_lock(&local->client_call_lock); 312 list_add_tail(&call->wait_link, &local->new_client_calls); 313 spin_unlock(&local->client_call_lock); 314 rxrpc_wake_up_io_thread(local); 315 return 0; 316 317error: 318 __set_bit(RXRPC_CALL_DISCONNECTED, &call->flags); 319 return ret; 320} 321 322/* |
|
290 * Set up a call for the given parameters. 291 * - Called with the socket lock held, which it must release. 292 * - If it returns a call, the call's lock will need releasing by the caller. 293 */ 294struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx, 295 struct rxrpc_conn_parameters *cp, 296 struct sockaddr_rxrpc *srx, 297 struct rxrpc_call_params *p, --- 66 unchanged lines hidden (view full) --- 364 365 /* Set up or get a connection record and set the protocol parameters, 366 * including channel number and call ID. 367 */ 368 ret = rxrpc_connect_call(call, gfp); 369 if (ret < 0) 370 goto error_attached_to_socket; 371 | 323 * Set up a call for the given parameters. 324 * - Called with the socket lock held, which it must release. 325 * - If it returns a call, the call's lock will need releasing by the caller. 326 */ 327struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx, 328 struct rxrpc_conn_parameters *cp, 329 struct sockaddr_rxrpc *srx, 330 struct rxrpc_call_params *p, --- 66 unchanged lines hidden (view full) --- 397 398 /* Set up or get a connection record and set the protocol parameters, 399 * including channel number and call ID. 400 */ 401 ret = rxrpc_connect_call(call, gfp); 402 if (ret < 0) 403 goto error_attached_to_socket; 404 |
372 rxrpc_see_call(call, rxrpc_call_see_connected); 373 374 rxrpc_start_call_timer(call); 375 | |
376 _leave(" = %p [new]", call); 377 return call; 378 379 /* We unexpectedly found the user ID in the list after taking 380 * the call_lock. This shouldn't happen unless the user races 381 * with itself and tries to add the same user ID twice at the 382 * same time in different threads. 383 */ 384error_dup_user_ID: 385 write_unlock(&rx->call_lock); 386 release_sock(&rx->sk); 387 rxrpc_prefail_call(call, RXRPC_CALL_LOCAL_ERROR, -EEXIST); 388 trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), 0, 389 rxrpc_call_see_userid_exists); | 405 _leave(" = %p [new]", call); 406 return call; 407 408 /* We unexpectedly found the user ID in the list after taking 409 * the call_lock. This shouldn't happen unless the user races 410 * with itself and tries to add the same user ID twice at the 411 * same time in different threads. 412 */ 413error_dup_user_ID: 414 write_unlock(&rx->call_lock); 415 release_sock(&rx->sk); 416 rxrpc_prefail_call(call, RXRPC_CALL_LOCAL_ERROR, -EEXIST); 417 trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), 0, 418 rxrpc_call_see_userid_exists); |
390 rxrpc_release_call(rx, call); | |
391 mutex_unlock(&call->user_mutex); 392 rxrpc_put_call(call, rxrpc_call_put_userid_exists); 393 _leave(" = -EEXIST"); 394 return ERR_PTR(-EEXIST); 395 396 /* We got an error, but the call is attached to the socket and is in | 419 mutex_unlock(&call->user_mutex); 420 rxrpc_put_call(call, rxrpc_call_put_userid_exists); 421 _leave(" = -EEXIST"); 422 return ERR_PTR(-EEXIST); 423 424 /* We got an error, but the call is attached to the socket and is in |
397 * need of release. However, we might now race with recvmsg() when 398 * completing the call queues it. Return 0 from sys_sendmsg() and | 425 * need of release. However, we might now race with recvmsg() when it 426 * completion notifies the socket. Return 0 from sys_sendmsg() and |
399 * leave the error to recvmsg() to deal with. 400 */ 401error_attached_to_socket: 402 trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), ret, 403 rxrpc_call_see_connect_failed); | 427 * leave the error to recvmsg() to deal with. 428 */ 429error_attached_to_socket: 430 trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), ret, 431 rxrpc_call_see_connect_failed); |
404 set_bit(RXRPC_CALL_DISCONNECTED, &call->flags); 405 rxrpc_prefail_call(call, RXRPC_CALL_LOCAL_ERROR, ret); | 432 rxrpc_set_call_completion(call, RXRPC_CALL_LOCAL_ERROR, 0, ret); |
406 _leave(" = c=%08x [err]", call->debug_id); 407 return call; 408} 409 410/* 411 * Set up an incoming call. call->conn points to the connection. 412 * This is called in BH context and isn't allowed to fail. 413 */ --- 41 unchanged lines hidden (view full) --- 455 * only defending against the data_ready handler (which we're called 456 * from) and the RESPONSE packet parser (which is only really 457 * interested in call_counter and can cope with a disagreement with the 458 * call pointer). 459 */ 460 chan = sp->hdr.cid & RXRPC_CHANNELMASK; 461 conn->channels[chan].call_counter = call->call_id; 462 conn->channels[chan].call_id = call->call_id; | 433 _leave(" = c=%08x [err]", call->debug_id); 434 return call; 435} 436 437/* 438 * Set up an incoming call. call->conn points to the connection. 439 * This is called in BH context and isn't allowed to fail. 440 */ --- 41 unchanged lines hidden (view full) --- 482 * only defending against the data_ready handler (which we're called 483 * from) and the RESPONSE packet parser (which is only really 484 * interested in call_counter and can cope with a disagreement with the 485 * call pointer). 486 */ 487 chan = sp->hdr.cid & RXRPC_CHANNELMASK; 488 conn->channels[chan].call_counter = call->call_id; 489 conn->channels[chan].call_id = call->call_id; |
463 rcu_assign_pointer(conn->channels[chan].call, call); | 490 conn->channels[chan].call = call; |
464 spin_unlock(&conn->state_lock); 465 466 spin_lock(&conn->peer->lock); 467 hlist_add_head(&call->error_link, &conn->peer->error_targets); 468 spin_unlock(&conn->peer->lock); 469 470 rxrpc_start_call_timer(call); 471 _leave(""); --- 43 unchanged lines hidden (view full) --- 515} 516 517/* 518 * Detach a call from its owning socket. 519 */ 520void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) 521{ 522 struct rxrpc_connection *conn = call->conn; | 491 spin_unlock(&conn->state_lock); 492 493 spin_lock(&conn->peer->lock); 494 hlist_add_head(&call->error_link, &conn->peer->error_targets); 495 spin_unlock(&conn->peer->lock); 496 497 rxrpc_start_call_timer(call); 498 _leave(""); --- 43 unchanged lines hidden (view full) --- 542} 543 544/* 545 * Detach a call from its owning socket. 546 */ 547void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) 548{ 549 struct rxrpc_connection *conn = call->conn; |
523 bool put = false; | 550 bool put = false, putu = false; |
524 525 _enter("{%d,%d}", call->debug_id, refcount_read(&call->ref)); 526 527 trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), 528 call->flags, rxrpc_call_see_release); 529 530 if (test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags)) 531 BUG(); --- 18 unchanged lines hidden (view full) --- 550 if (put) 551 rxrpc_put_call(call, rxrpc_call_put_unnotify); 552 553 write_lock(&rx->call_lock); 554 555 if (test_and_clear_bit(RXRPC_CALL_HAS_USERID, &call->flags)) { 556 rb_erase(&call->sock_node, &rx->calls); 557 memset(&call->sock_node, 0xdd, sizeof(call->sock_node)); | 551 552 _enter("{%d,%d}", call->debug_id, refcount_read(&call->ref)); 553 554 trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), 555 call->flags, rxrpc_call_see_release); 556 557 if (test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags)) 558 BUG(); --- 18 unchanged lines hidden (view full) --- 577 if (put) 578 rxrpc_put_call(call, rxrpc_call_put_unnotify); 579 580 write_lock(&rx->call_lock); 581 582 if (test_and_clear_bit(RXRPC_CALL_HAS_USERID, &call->flags)) { 583 rb_erase(&call->sock_node, &rx->calls); 584 memset(&call->sock_node, 0xdd, sizeof(call->sock_node)); |
558 rxrpc_put_call(call, rxrpc_call_put_userid_exists); | 585 putu = true; |
559 } 560 561 list_del(&call->sock_link); 562 write_unlock(&rx->call_lock); 563 564 _debug("RELEASE CALL %p (%d CONN %p)", call, call->debug_id, conn); 565 | 586 } 587 588 list_del(&call->sock_link); 589 write_unlock(&rx->call_lock); 590 591 _debug("RELEASE CALL %p (%d CONN %p)", call, call->debug_id, conn); 592 |
593 if (putu) 594 rxrpc_put_call(call, rxrpc_call_put_userid); 595 |
|
566 _leave(""); 567} 568 569/* 570 * release all the calls associated with a socket 571 */ 572void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx) 573{ --- 156 unchanged lines hidden --- | 596 _leave(""); 597} 598 599/* 600 * release all the calls associated with a socket 601 */ 602void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx) 603{ --- 156 unchanged lines hidden --- |