Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
b61d59ff
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
158
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b61d59ff
编写于
3月 11, 2009
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SUNRPC: xs_tcp_connect_worker{4,6}: merge common code
Signed-off-by:
N
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
上级
25fe6142
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
72 addition
and
68 deletion
+72
-68
net/sunrpc/xprtsock.c
net/sunrpc/xprtsock.c
+72
-68
未找到文件。
net/sunrpc/xprtsock.c
浏览文件 @
b61d59ff
...
...
@@ -1738,33 +1738,29 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
}
/**
* xs_tcp_connect_worker4 - connect a TCP socket to a remote endpoint
* @work: RPC transport to connect
* xs_tcp_setup_socket - create a TCP socket and connect to a remote endpoint
* @xprt: RPC transport to connect
* @transport: socket transport to connect
* @create_sock: function to create a socket of the correct type
*
* Invoked by a work queue tasklet.
*/
static
void
xs_tcp_connect_worker4
(
struct
work_struct
*
work
)
static
void
xs_tcp_setup_socket
(
struct
rpc_xprt
*
xprt
,
struct
sock_xprt
*
transport
,
struct
socket
*
(
*
create_sock
)(
struct
rpc_xprt
*
,
struct
sock_xprt
*
))
{
struct
sock_xprt
*
transport
=
container_of
(
work
,
struct
sock_xprt
,
connect_worker
.
work
);
struct
rpc_xprt
*
xprt
=
&
transport
->
xprt
;
struct
socket
*
sock
=
transport
->
sock
;
int
err
,
status
=
-
EIO
;
int
status
=
-
EIO
;
if
(
xprt
->
shutdown
)
goto
out
;
if
(
!
sock
)
{
clear_bit
(
XPRT_CONNECTION_ABORT
,
&
xprt
->
state
);
/* start from scratch */
if
((
err
=
sock_create_kern
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
,
&
sock
))
<
0
)
{
dprintk
(
"RPC: can't create TCP transport socket (%d).
\n
"
,
-
err
);
goto
out
;
}
xs_reclassify_socket4
(
sock
);
if
(
xs_bind4
(
transport
,
sock
)
<
0
)
{
sock_release
(
sock
);
sock
=
create_sock
(
xprt
,
transport
);
if
(
IS_ERR
(
sock
))
{
status
=
PTR_ERR
(
sock
);
goto
out
;
}
}
else
{
...
...
@@ -1808,74 +1804,82 @@ static void xs_tcp_connect_worker4(struct work_struct *work)
xprt_wake_pending_tasks
(
xprt
,
status
);
}
static
struct
socket
*
xs_create_tcp_sock4
(
struct
rpc_xprt
*
xprt
,
struct
sock_xprt
*
transport
)
{
struct
socket
*
sock
;
int
err
;
/* start from scratch */
err
=
sock_create_kern
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
,
&
sock
);
if
(
err
<
0
)
{
dprintk
(
"RPC: can't create TCP transport socket (%d).
\n
"
,
-
err
);
goto
out_err
;
}
xs_reclassify_socket4
(
sock
);
if
(
xs_bind4
(
transport
,
sock
)
<
0
)
{
sock_release
(
sock
);
goto
out_err
;
}
return
sock
;
out_err:
return
ERR_PTR
(
-
EIO
);
}
/**
* xs_tcp_connect_worker
6
- connect a TCP socket to a remote endpoint
* xs_tcp_connect_worker
4
- connect a TCP socket to a remote endpoint
* @work: RPC transport to connect
*
* Invoked by a work queue tasklet.
*/
static
void
xs_tcp_connect_worker
6
(
struct
work_struct
*
work
)
static
void
xs_tcp_connect_worker
4
(
struct
work_struct
*
work
)
{
struct
sock_xprt
*
transport
=
container_of
(
work
,
struct
sock_xprt
,
connect_worker
.
work
);
struct
rpc_xprt
*
xprt
=
&
transport
->
xprt
;
struct
socket
*
sock
=
transport
->
sock
;
int
err
,
status
=
-
EIO
;
if
(
xprt
->
shutdown
)
goto
out
;
if
(
!
sock
)
{
clear_bit
(
XPRT_CONNECTION_ABORT
,
&
xprt
->
state
);
/* start from scratch */
if
((
err
=
sock_create_kern
(
PF_INET6
,
SOCK_STREAM
,
IPPROTO_TCP
,
&
sock
))
<
0
)
{
dprintk
(
"RPC: can't create TCP transport socket (%d).
\n
"
,
-
err
);
goto
out
;
}
xs_reclassify_socket6
(
sock
);
xs_tcp_setup_socket
(
xprt
,
transport
,
xs_create_tcp_sock4
);
}
if
(
xs_bind6
(
transport
,
sock
)
<
0
)
{
sock_release
(
sock
);
goto
out
;
}
}
else
{
int
abort_and_exit
;
static
struct
socket
*
xs_create_tcp_sock6
(
struct
rpc_xprt
*
xprt
,
struct
sock_xprt
*
transport
)
{
struct
socket
*
sock
;
int
err
;
abort_and_exit
=
test_and_clear_bit
(
XPRT_CONNECTION_ABORT
,
&
xprt
->
state
);
/* "close" the socket, preserving the local port */
xs_tcp_reuse_connection
(
xprt
,
transport
);
/* start from scratch */
err
=
sock_create_kern
(
PF_INET6
,
SOCK_STREAM
,
IPPROTO_TCP
,
&
sock
);
if
(
err
<
0
)
{
dprintk
(
"RPC: can't create TCP transport socket (%d).
\n
"
,
-
err
);
goto
out_err
;
}
xs_reclassify_socket6
(
sock
);
if
(
abort_and_exit
)
goto
out_eagain
;
if
(
xs_bind6
(
transport
,
sock
)
<
0
)
{
sock_release
(
sock
);
goto
out_err
;
}
return
sock
;
out_err:
return
ERR_PTR
(
-
EIO
);
}
dprintk
(
"RPC: worker connecting xprt %p to address: %s
\n
"
,
xprt
,
xprt
->
address_strings
[
RPC_DISPLAY_ALL
]);
/**
* xs_tcp_connect_worker6 - connect a TCP socket to a remote endpoint
* @work: RPC transport to connect
*
* Invoked by a work queue tasklet.
*/
static
void
xs_tcp_connect_worker6
(
struct
work_struct
*
work
)
{
struct
sock_xprt
*
transport
=
container_of
(
work
,
struct
sock_xprt
,
connect_worker
.
work
);
struct
rpc_xprt
*
xprt
=
&
transport
->
xprt
;
status
=
xs_tcp_finish_connecting
(
xprt
,
sock
);
dprintk
(
"RPC: %p connect status %d connected %d sock state %d
\n
"
,
xprt
,
-
status
,
xprt_connected
(
xprt
),
sock
->
sk
->
sk_state
);
switch
(
status
)
{
case
-
ECONNREFUSED
:
case
-
ECONNRESET
:
case
-
ENETUNREACH
:
/* retry with existing socket, after a delay */
case
0
:
case
-
EINPROGRESS
:
case
-
EALREADY
:
xprt_clear_connecting
(
xprt
);
return
;
}
/* get rid of existing socket, and retry */
xs_tcp_shutdown
(
xprt
);
printk
(
"%s: connect returned unhandled error %d
\n
"
,
__func__
,
status
);
out_eagain:
status
=
-
EAGAIN
;
out:
xprt_clear_connecting
(
xprt
);
xprt_wake_pending_tasks
(
xprt
,
status
);
xs_tcp_setup_socket
(
xprt
,
transport
,
xs_create_tcp_sock6
);
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录