2010-03-06 03:46:52

by Bian Naimeng

[permalink] [raw]
Subject: [PATCH]rpc client can not deal with ENOSOCK, so translate it into ENOCONN

If NFSv4 client send a request before connect, or the old connection was broken
because a ETIMEOUT error catched by call_status, ->send_request will return
ENOSOCK, but rpc layer can not deal with it, so translate it into ENOCONN.

Signed-off-by: Bian Naimeng <[email protected]>

---
net/sunrpc/xprtsock.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 3d739e5..45e5fd8 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -549,14 +549,13 @@ static int xs_udp_send_request(struct rpc_task *task)
/* Still some bytes left; set up for a retry later. */
status = -EAGAIN;
}
- if (!transport->sock)
+ if (!transport->sock || status == -ENOTSOCK) {
+ /* Should we call xs_close() here? */
+ status = -ENOTCONN;
goto out;
+ }

switch (status) {
- case -ENOTSOCK:
- status = -ENOTCONN;
- /* Should we call xs_close() here? */
- break;
case -EAGAIN:
status = xs_nospace(task);
break;
@@ -652,14 +651,13 @@ static int xs_tcp_send_request(struct rpc_task *task)
status = -EAGAIN;
break;
}
- if (!transport->sock)
+ if (!transport->sock || status == -ENOTSOCK) {
+ /* Should we call xs_close() here? */
+ status = -ENOTCONN;
goto out;
+ }

switch (status) {
- case -ENOTSOCK:
- status = -ENOTCONN;
- /* Should we call xs_close() here? */
- break;
case -EAGAIN:
status = xs_nospace(task);
break;
--
1.6.4



2010-03-08 01:13:22

by Bian Naimeng

[permalink] [raw]
Subject: Re: [PATCH]rpc client can not deal with ENOSOCK, so translate it into ENOCONN



Trond Myklebust =8E=CA=93=B9:
> On Sat, 2010-03-06 at 11:46 +0800, Bian Naimeng wrote:=20
>> If NFSv4 client send a request before connect, or the old connection=
was broken
>> because a ETIMEOUT error catched by call_status, ->send_request will=
return
>> ENOSOCK, but rpc layer can not deal with it, so translate it into EN=
OCONN.
>>
>> Signed-off-by: Bian Naimeng <[email protected]>
>>
>> ---

=2E.. snip...

>> - if (!transport->sock)
>> + if (!transport->sock || status =3D=3D -ENOTSOCK) {
>> + /* Should we call xs_close() here? */
>> + status =3D -ENOTCONN;
>> goto out;
>> + }
>> =20
>> switch (status) {
>> - case -ENOTSOCK:
>> - status =3D -ENOTCONN;
>> - /* Should we call xs_close() here? */
>> - break;
>> case -EAGAIN:
>> status =3D xs_nospace(task);
>> break;
>=20
> The only case where xs_sendpages() will return ENOTSOCK is if
> transport->sock =3D=3D NULL, so the correct fix here is to just remov=
e that
> redundant test. There is no need to move the test for ENOTSOCK out of
> the switch statement.

Yes. Thanks for your suggestion.

Best Regards
Bian

>=20
> Cheers
> Trond