Skip to content

Commit 3067bf8

Browse files
committed
rxrpc: Move the call completion handling out of line
Move the handling of call completion out of line so that the next patch can add more code in that area. Signed-off-by: David Howells <[email protected]> Reviewed-by: Marc Dionne <[email protected]>
1 parent bdc48fa commit 3067bf8

File tree

3 files changed

+103
-98
lines changed

3 files changed

+103
-98
lines changed

net/rxrpc/ar-internal.h

Lines changed: 25 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -809,100 +809,6 @@ static inline bool rxrpc_is_client_call(const struct rxrpc_call *call)
809809
return !rxrpc_is_service_call(call);
810810
}
811811

812-
/*
813-
* Transition a call to the complete state.
814-
*/
815-
static inline bool __rxrpc_set_call_completion(struct rxrpc_call *call,
816-
enum rxrpc_call_completion compl,
817-
u32 abort_code,
818-
int error)
819-
{
820-
if (call->state < RXRPC_CALL_COMPLETE) {
821-
call->abort_code = abort_code;
822-
call->error = error;
823-
call->completion = compl,
824-
call->state = RXRPC_CALL_COMPLETE;
825-
trace_rxrpc_call_complete(call);
826-
wake_up(&call->waitq);
827-
return true;
828-
}
829-
return false;
830-
}
831-
832-
static inline bool rxrpc_set_call_completion(struct rxrpc_call *call,
833-
enum rxrpc_call_completion compl,
834-
u32 abort_code,
835-
int error)
836-
{
837-
bool ret;
838-
839-
write_lock_bh(&call->state_lock);
840-
ret = __rxrpc_set_call_completion(call, compl, abort_code, error);
841-
write_unlock_bh(&call->state_lock);
842-
return ret;
843-
}
844-
845-
/*
846-
* Record that a call successfully completed.
847-
*/
848-
static inline bool __rxrpc_call_completed(struct rxrpc_call *call)
849-
{
850-
return __rxrpc_set_call_completion(call, RXRPC_CALL_SUCCEEDED, 0, 0);
851-
}
852-
853-
static inline bool rxrpc_call_completed(struct rxrpc_call *call)
854-
{
855-
bool ret;
856-
857-
write_lock_bh(&call->state_lock);
858-
ret = __rxrpc_call_completed(call);
859-
write_unlock_bh(&call->state_lock);
860-
return ret;
861-
}
862-
863-
/*
864-
* Record that a call is locally aborted.
865-
*/
866-
static inline bool __rxrpc_abort_call(const char *why, struct rxrpc_call *call,
867-
rxrpc_seq_t seq,
868-
u32 abort_code, int error)
869-
{
870-
trace_rxrpc_abort(call->debug_id, why, call->cid, call->call_id, seq,
871-
abort_code, error);
872-
return __rxrpc_set_call_completion(call, RXRPC_CALL_LOCALLY_ABORTED,
873-
abort_code, error);
874-
}
875-
876-
static inline bool rxrpc_abort_call(const char *why, struct rxrpc_call *call,
877-
rxrpc_seq_t seq, u32 abort_code, int error)
878-
{
879-
bool ret;
880-
881-
write_lock_bh(&call->state_lock);
882-
ret = __rxrpc_abort_call(why, call, seq, abort_code, error);
883-
write_unlock_bh(&call->state_lock);
884-
return ret;
885-
}
886-
887-
/*
888-
* Abort a call due to a protocol error.
889-
*/
890-
static inline bool __rxrpc_abort_eproto(struct rxrpc_call *call,
891-
struct sk_buff *skb,
892-
const char *eproto_why,
893-
const char *why,
894-
u32 abort_code)
895-
{
896-
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
897-
898-
trace_rxrpc_rx_eproto(call, sp->hdr.serial, eproto_why);
899-
return rxrpc_abort_call(why, call, sp->hdr.seq, abort_code, -EPROTO);
900-
}
901-
902-
#define rxrpc_abort_eproto(call, skb, eproto_why, abort_why, abort_code) \
903-
__rxrpc_abort_eproto((call), (skb), tracepoint_string(eproto_why), \
904-
(abort_why), (abort_code))
905-
906812
/*
907813
* conn_client.c
908814
*/
@@ -1101,8 +1007,33 @@ extern const struct seq_operations rxrpc_peer_seq_ops;
11011007
* recvmsg.c
11021008
*/
11031009
void rxrpc_notify_socket(struct rxrpc_call *);
1010+
bool __rxrpc_set_call_completion(struct rxrpc_call *, enum rxrpc_call_completion, u32, int);
1011+
bool rxrpc_set_call_completion(struct rxrpc_call *, enum rxrpc_call_completion, u32, int);
1012+
bool __rxrpc_call_completed(struct rxrpc_call *);
1013+
bool rxrpc_call_completed(struct rxrpc_call *);
1014+
bool __rxrpc_abort_call(const char *, struct rxrpc_call *, rxrpc_seq_t, u32, int);
1015+
bool rxrpc_abort_call(const char *, struct rxrpc_call *, rxrpc_seq_t, u32, int);
11041016
int rxrpc_recvmsg(struct socket *, struct msghdr *, size_t, int);
11051017

1018+
/*
1019+
* Abort a call due to a protocol error.
1020+
*/
1021+
static inline bool __rxrpc_abort_eproto(struct rxrpc_call *call,
1022+
struct sk_buff *skb,
1023+
const char *eproto_why,
1024+
const char *why,
1025+
u32 abort_code)
1026+
{
1027+
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
1028+
1029+
trace_rxrpc_rx_eproto(call, sp->hdr.serial, eproto_why);
1030+
return rxrpc_abort_call(why, call, sp->hdr.seq, abort_code, -EPROTO);
1031+
}
1032+
1033+
#define rxrpc_abort_eproto(call, skb, eproto_why, abort_why, abort_code) \
1034+
__rxrpc_abort_eproto((call), (skb), tracepoint_string(eproto_why), \
1035+
(abort_why), (abort_code))
1036+
11061037
/*
11071038
* rtt.c
11081039
*/

net/rxrpc/recvmsg.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,80 @@ void rxrpc_notify_socket(struct rxrpc_call *call)
5858
_leave("");
5959
}
6060

61+
/*
62+
* Transition a call to the complete state.
63+
*/
64+
bool __rxrpc_set_call_completion(struct rxrpc_call *call,
65+
enum rxrpc_call_completion compl,
66+
u32 abort_code,
67+
int error)
68+
{
69+
if (call->state < RXRPC_CALL_COMPLETE) {
70+
call->abort_code = abort_code;
71+
call->error = error;
72+
call->completion = compl,
73+
call->state = RXRPC_CALL_COMPLETE;
74+
trace_rxrpc_call_complete(call);
75+
wake_up(&call->waitq);
76+
return true;
77+
}
78+
return false;
79+
}
80+
81+
bool rxrpc_set_call_completion(struct rxrpc_call *call,
82+
enum rxrpc_call_completion compl,
83+
u32 abort_code,
84+
int error)
85+
{
86+
bool ret;
87+
88+
write_lock_bh(&call->state_lock);
89+
ret = __rxrpc_set_call_completion(call, compl, abort_code, error);
90+
write_unlock_bh(&call->state_lock);
91+
return ret;
92+
}
93+
94+
/*
95+
* Record that a call successfully completed.
96+
*/
97+
bool __rxrpc_call_completed(struct rxrpc_call *call)
98+
{
99+
return __rxrpc_set_call_completion(call, RXRPC_CALL_SUCCEEDED, 0, 0);
100+
}
101+
102+
bool rxrpc_call_completed(struct rxrpc_call *call)
103+
{
104+
bool ret;
105+
106+
write_lock_bh(&call->state_lock);
107+
ret = __rxrpc_call_completed(call);
108+
write_unlock_bh(&call->state_lock);
109+
return ret;
110+
}
111+
112+
/*
113+
* Record that a call is locally aborted.
114+
*/
115+
bool __rxrpc_abort_call(const char *why, struct rxrpc_call *call,
116+
rxrpc_seq_t seq, u32 abort_code, int error)
117+
{
118+
trace_rxrpc_abort(call->debug_id, why, call->cid, call->call_id, seq,
119+
abort_code, error);
120+
return __rxrpc_set_call_completion(call, RXRPC_CALL_LOCALLY_ABORTED,
121+
abort_code, error);
122+
}
123+
124+
bool rxrpc_abort_call(const char *why, struct rxrpc_call *call,
125+
rxrpc_seq_t seq, u32 abort_code, int error)
126+
{
127+
bool ret;
128+
129+
write_lock_bh(&call->state_lock);
130+
ret = __rxrpc_abort_call(why, call, seq, abort_code, error);
131+
write_unlock_bh(&call->state_lock);
132+
return ret;
133+
}
134+
61135
/*
62136
* Pass a call terminating message to userspace.
63137
*/

net/rxrpc/sendmsg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ static int rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
261261
case -ENETUNREACH:
262262
case -EHOSTUNREACH:
263263
case -ECONNREFUSED:
264-
rxrpc_set_call_completion(call,
265-
RXRPC_CALL_LOCAL_ERROR,
266-
0, ret);
267-
rxrpc_notify_socket(call);
264+
if (rxrpc_set_call_completion(call,
265+
RXRPC_CALL_LOCAL_ERROR,
266+
0, ret))
267+
rxrpc_notify_socket(call);
268268
goto out;
269269
}
270270
_debug("need instant resend %d", ret);

0 commit comments

Comments
 (0)