Skip to content

Commit 686c1a0

Browse files
committed
rxrpc: Split out the call state changing functions into their own file
jira LE-1907 Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2 commit-author David Howells <dhowells@redhat.com> commit 0b9bb32 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-rt-5.14.0-284.30.1.rt14.315.el9_2/0b9bb322.failed Split out the functions that change the state of an rxrpc call into their own file. The idea being to remove anything to do with changing the state of a call directly from the rxrpc sendmsg() and recvmsg() paths and have all that done in the I/O thread only, with the ultimate aim of removing the state lock entirely. Moving the code out of sendmsg.c and recvmsg.c makes that easier to manage. Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: linux-afs@lists.infradead.org (cherry picked from commit 0b9bb32) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # net/rxrpc/ar-internal.h # net/rxrpc/recvmsg.c
1 parent a61249c commit 686c1a0

File tree

1 file changed

+248
-0
lines changed

1 file changed

+248
-0
lines changed
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
rxrpc: Split out the call state changing functions into their own file
2+
3+
jira LE-1907
4+
Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2
5+
commit-author David Howells <dhowells@redhat.com>
6+
commit 0b9bb322f13d486d5b8630264ccbfb4794bb43a9
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-rt-5.14.0-284.30.1.rt14.315.el9_2/0b9bb322.failed
10+
11+
Split out the functions that change the state of an rxrpc call into their
12+
own file. The idea being to remove anything to do with changing the state
13+
of a call directly from the rxrpc sendmsg() and recvmsg() paths and have
14+
all that done in the I/O thread only, with the ultimate aim of removing the
15+
state lock entirely. Moving the code out of sendmsg.c and recvmsg.c makes
16+
that easier to manage.
17+
18+
Signed-off-by: David Howells <dhowells@redhat.com>
19+
cc: Marc Dionne <marc.dionne@auristor.com>
20+
cc: linux-afs@lists.infradead.org
21+
(cherry picked from commit 0b9bb322f13d486d5b8630264ccbfb4794bb43a9)
22+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
23+
24+
# Conflicts:
25+
# net/rxrpc/ar-internal.h
26+
# net/rxrpc/recvmsg.c
27+
diff --cc net/rxrpc/ar-internal.h
28+
index 46ce41afb431,203e0354d86b..000000000000
29+
--- a/net/rxrpc/ar-internal.h
30+
+++ b/net/rxrpc/ar-internal.h
31+
@@@ -1049,12 -1134,6 +1067,15 @@@ extern const struct seq_operations rxrp
32+
* recvmsg.c
33+
*/
34+
void rxrpc_notify_socket(struct rxrpc_call *);
35+
++<<<<<<< HEAD
36+
+bool __rxrpc_set_call_completion(struct rxrpc_call *, enum rxrpc_call_completion, u32, int);
37+
+bool rxrpc_set_call_completion(struct rxrpc_call *, enum rxrpc_call_completion, u32, int);
38+
+bool __rxrpc_call_completed(struct rxrpc_call *);
39+
+bool rxrpc_call_completed(struct rxrpc_call *);
40+
+bool __rxrpc_abort_call(const char *, struct rxrpc_call *, rxrpc_seq_t, u32, int);
41+
+bool rxrpc_abort_call(const char *, struct rxrpc_call *, rxrpc_seq_t, u32, int);
42+
++=======
43+
++>>>>>>> 0b9bb322f13d (rxrpc: Split out the call state changing functions into their own file)
44+
int rxrpc_recvmsg(struct socket *, struct msghdr *, size_t, int);
45+
46+
/*
47+
diff --cc net/rxrpc/recvmsg.c
48+
index c84d2b620396,ff08f917ecda..000000000000
49+
--- a/net/rxrpc/recvmsg.c
50+
+++ b/net/rxrpc/recvmsg.c
51+
@@@ -59,85 -59,6 +59,88 @@@ void rxrpc_notify_socket(struct rxrpc_c
52+
}
53+
54+
/*
55+
++<<<<<<< HEAD
56+
+ * Transition a call to the complete state.
57+
+ */
58+
+bool __rxrpc_set_call_completion(struct rxrpc_call *call,
59+
+ enum rxrpc_call_completion compl,
60+
+ u32 abort_code,
61+
+ int error)
62+
+{
63+
+ if (call->state < RXRPC_CALL_COMPLETE) {
64+
+ call->abort_code = abort_code;
65+
+ call->error = error;
66+
+ call->completion = compl;
67+
+ call->state = RXRPC_CALL_COMPLETE;
68+
+ trace_rxrpc_call_complete(call);
69+
+ wake_up(&call->waitq);
70+
+ rxrpc_notify_socket(call);
71+
+ return true;
72+
+ }
73+
+ return false;
74+
+}
75+
+
76+
+bool rxrpc_set_call_completion(struct rxrpc_call *call,
77+
+ enum rxrpc_call_completion compl,
78+
+ u32 abort_code,
79+
+ int error)
80+
+{
81+
+ bool ret = false;
82+
+
83+
+ if (call->state < RXRPC_CALL_COMPLETE) {
84+
+ write_lock_bh(&call->state_lock);
85+
+ ret = __rxrpc_set_call_completion(call, compl, abort_code, error);
86+
+ write_unlock_bh(&call->state_lock);
87+
+ }
88+
+ return ret;
89+
+}
90+
+
91+
+/*
92+
+ * Record that a call successfully completed.
93+
+ */
94+
+bool __rxrpc_call_completed(struct rxrpc_call *call)
95+
+{
96+
+ return __rxrpc_set_call_completion(call, RXRPC_CALL_SUCCEEDED, 0, 0);
97+
+}
98+
+
99+
+bool rxrpc_call_completed(struct rxrpc_call *call)
100+
+{
101+
+ bool ret = false;
102+
+
103+
+ if (call->state < RXRPC_CALL_COMPLETE) {
104+
+ write_lock_bh(&call->state_lock);
105+
+ ret = __rxrpc_call_completed(call);
106+
+ write_unlock_bh(&call->state_lock);
107+
+ }
108+
+ return ret;
109+
+}
110+
+
111+
+/*
112+
+ * Record that a call is locally aborted.
113+
+ */
114+
+bool __rxrpc_abort_call(const char *why, struct rxrpc_call *call,
115+
+ rxrpc_seq_t seq, u32 abort_code, int error)
116+
+{
117+
+ trace_rxrpc_abort(call->debug_id, why, call->cid, call->call_id, seq,
118+
+ abort_code, error);
119+
+ return __rxrpc_set_call_completion(call, RXRPC_CALL_LOCALLY_ABORTED,
120+
+ abort_code, error);
121+
+}
122+
+
123+
+bool rxrpc_abort_call(const char *why, struct rxrpc_call *call,
124+
+ rxrpc_seq_t seq, u32 abort_code, int error)
125+
+{
126+
+ bool ret;
127+
+
128+
+ write_lock_bh(&call->state_lock);
129+
+ ret = __rxrpc_abort_call(why, call, seq, abort_code, error);
130+
+ write_unlock_bh(&call->state_lock);
131+
+ return ret;
132+
+}
133+
+
134+
+/*
135+
++=======
136+
++>>>>>>> 0b9bb322f13d (rxrpc: Split out the call state changing functions into their own file)
137+
* Pass a call terminating message to userspace.
138+
*/
139+
static int rxrpc_recvmsg_term(struct rxrpc_call *call, struct msghdr *msg)
140+
diff --git a/net/rxrpc/Makefile b/net/rxrpc/Makefile
141+
index 79687477d93c..6ed499fa2e5d 100644
142+
--- a/net/rxrpc/Makefile
143+
+++ b/net/rxrpc/Makefile
144+
@@ -10,6 +10,7 @@ rxrpc-y := \
145+
call_accept.o \
146+
call_event.o \
147+
call_object.o \
148+
+ call_state.o \
149+
conn_client.o \
150+
conn_event.o \
151+
conn_object.o \
152+
* Unmerged path net/rxrpc/ar-internal.h
153+
diff --git a/net/rxrpc/call_state.c b/net/rxrpc/call_state.c
154+
new file mode 100644
155+
index 000000000000..8fbb2112ed7e
156+
--- /dev/null
157+
+++ b/net/rxrpc/call_state.c
158+
@@ -0,0 +1,89 @@
159+
+// SPDX-License-Identifier: GPL-2.0-or-later
160+
+/* Call state changing functions.
161+
+ *
162+
+ * Copyright (C) 2022 Red Hat, Inc. All Rights Reserved.
163+
+ * Written by David Howells (dhowells@redhat.com)
164+
+ */
165+
+
166+
+#include "ar-internal.h"
167+
+
168+
+/*
169+
+ * Transition a call to the complete state.
170+
+ */
171+
+bool __rxrpc_set_call_completion(struct rxrpc_call *call,
172+
+ enum rxrpc_call_completion compl,
173+
+ u32 abort_code,
174+
+ int error)
175+
+{
176+
+ if (call->state < RXRPC_CALL_COMPLETE) {
177+
+ call->abort_code = abort_code;
178+
+ call->error = error;
179+
+ call->completion = compl;
180+
+ call->state = RXRPC_CALL_COMPLETE;
181+
+ trace_rxrpc_call_complete(call);
182+
+ wake_up(&call->waitq);
183+
+ rxrpc_notify_socket(call);
184+
+ return true;
185+
+ }
186+
+ return false;
187+
+}
188+
+
189+
+bool rxrpc_set_call_completion(struct rxrpc_call *call,
190+
+ enum rxrpc_call_completion compl,
191+
+ u32 abort_code,
192+
+ int error)
193+
+{
194+
+ bool ret = false;
195+
+
196+
+ if (call->state < RXRPC_CALL_COMPLETE) {
197+
+ write_lock(&call->state_lock);
198+
+ ret = __rxrpc_set_call_completion(call, compl, abort_code, error);
199+
+ write_unlock(&call->state_lock);
200+
+ }
201+
+ return ret;
202+
+}
203+
+
204+
+/*
205+
+ * Record that a call successfully completed.
206+
+ */
207+
+bool __rxrpc_call_completed(struct rxrpc_call *call)
208+
+{
209+
+ return __rxrpc_set_call_completion(call, RXRPC_CALL_SUCCEEDED, 0, 0);
210+
+}
211+
+
212+
+bool rxrpc_call_completed(struct rxrpc_call *call)
213+
+{
214+
+ bool ret = false;
215+
+
216+
+ if (call->state < RXRPC_CALL_COMPLETE) {
217+
+ write_lock(&call->state_lock);
218+
+ ret = __rxrpc_call_completed(call);
219+
+ write_unlock(&call->state_lock);
220+
+ }
221+
+ return ret;
222+
+}
223+
+
224+
+/*
225+
+ * Record that a call is locally aborted.
226+
+ */
227+
+bool __rxrpc_abort_call(struct rxrpc_call *call, rxrpc_seq_t seq,
228+
+ u32 abort_code, int error, enum rxrpc_abort_reason why)
229+
+{
230+
+ trace_rxrpc_abort(call->debug_id, why, call->cid, call->call_id, seq,
231+
+ abort_code, error);
232+
+ return __rxrpc_set_call_completion(call, RXRPC_CALL_LOCALLY_ABORTED,
233+
+ abort_code, error);
234+
+}
235+
+
236+
+bool rxrpc_abort_call(struct rxrpc_call *call, rxrpc_seq_t seq,
237+
+ u32 abort_code, int error, enum rxrpc_abort_reason why)
238+
+{
239+
+ bool ret;
240+
+
241+
+ write_lock(&call->state_lock);
242+
+ ret = __rxrpc_abort_call(call, seq, abort_code, error, why);
243+
+ write_unlock(&call->state_lock);
244+
+ if (ret && test_bit(RXRPC_CALL_EXPOSED, &call->flags))
245+
+ rxrpc_send_abort_packet(call);
246+
+ return ret;
247+
+}
248+
* Unmerged path net/rxrpc/recvmsg.c

0 commit comments

Comments
 (0)