Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
1dddda86
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
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看板
提交
1dddda86
编写于
6月 01, 2015
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SUNRPC: Clean up allocation and freeing of back channel requests
Signed-off-by:
N
Trond Myklebust
<
trond.myklebust@primarydata.com
>
上级
0f419791
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
40 deletion
+55
-40
net/sunrpc/backchannel_rqst.c
net/sunrpc/backchannel_rqst.c
+55
-40
未找到文件。
net/sunrpc/backchannel_rqst.c
浏览文件 @
1dddda86
...
...
@@ -67,6 +67,55 @@ static void xprt_free_allocation(struct rpc_rqst *req)
kfree
(
req
);
}
static
int
xprt_alloc_xdr_buf
(
struct
xdr_buf
*
buf
,
gfp_t
gfp_flags
)
{
struct
page
*
page
;
/* Preallocate one XDR receive buffer */
page
=
alloc_page
(
gfp_flags
);
if
(
page
==
NULL
)
return
-
ENOMEM
;
buf
->
head
[
0
].
iov_base
=
page_address
(
page
);
buf
->
head
[
0
].
iov_len
=
PAGE_SIZE
;
buf
->
tail
[
0
].
iov_base
=
NULL
;
buf
->
tail
[
0
].
iov_len
=
0
;
buf
->
page_len
=
0
;
buf
->
len
=
0
;
buf
->
buflen
=
PAGE_SIZE
;
return
0
;
}
static
struct
rpc_rqst
*
xprt_alloc_bc_req
(
struct
rpc_xprt
*
xprt
,
gfp_t
gfp_flags
)
{
struct
rpc_rqst
*
req
;
/* Pre-allocate one backchannel rpc_rqst */
req
=
kzalloc
(
sizeof
(
*
req
),
gfp_flags
);
if
(
req
==
NULL
)
return
NULL
;
req
->
rq_xprt
=
xprt
;
INIT_LIST_HEAD
(
&
req
->
rq_list
);
INIT_LIST_HEAD
(
&
req
->
rq_bc_list
);
/* Preallocate one XDR receive buffer */
if
(
xprt_alloc_xdr_buf
(
&
req
->
rq_rcv_buf
,
gfp_flags
)
<
0
)
{
printk
(
KERN_ERR
"Failed to create bc receive xbuf
\n
"
);
goto
out_free
;
}
req
->
rq_rcv_buf
.
len
=
PAGE_SIZE
;
/* Preallocate one XDR send buffer */
if
(
xprt_alloc_xdr_buf
(
&
req
->
rq_snd_buf
,
gfp_flags
)
<
0
)
{
printk
(
KERN_ERR
"Failed to create bc snd xbuf
\n
"
);
goto
out_free
;
}
return
req
;
out_free:
xprt_free_allocation
(
req
);
return
NULL
;
}
/*
* Preallocate up to min_reqs structures and related buffers for use
* by the backchannel. This function can be called multiple times
...
...
@@ -87,9 +136,7 @@ static void xprt_free_allocation(struct rpc_rqst *req)
*/
int
xprt_setup_backchannel
(
struct
rpc_xprt
*
xprt
,
unsigned
int
min_reqs
)
{
struct
page
*
page_rcv
=
NULL
,
*
page_snd
=
NULL
;
struct
xdr_buf
*
xbufp
=
NULL
;
struct
rpc_rqst
*
req
,
*
tmp
;
struct
rpc_rqst
*
req
;
struct
list_head
tmp_list
;
int
i
;
...
...
@@ -106,7 +153,7 @@ int xprt_setup_backchannel(struct rpc_xprt *xprt, unsigned int min_reqs)
INIT_LIST_HEAD
(
&
tmp_list
);
for
(
i
=
0
;
i
<
min_reqs
;
i
++
)
{
/* Pre-allocate one backchannel rpc_rqst */
req
=
kzalloc
(
sizeof
(
struct
rpc_rqst
)
,
GFP_KERNEL
);
req
=
xprt_alloc_bc_req
(
xprt
,
GFP_KERNEL
);
if
(
req
==
NULL
)
{
printk
(
KERN_ERR
"Failed to create bc rpc_rqst
\n
"
);
goto
out_free
;
...
...
@@ -115,41 +162,6 @@ int xprt_setup_backchannel(struct rpc_xprt *xprt, unsigned int min_reqs)
/* Add the allocated buffer to the tmp list */
dprintk
(
"RPC: adding req= %p
\n
"
,
req
);
list_add
(
&
req
->
rq_bc_pa_list
,
&
tmp_list
);
req
->
rq_xprt
=
xprt
;
INIT_LIST_HEAD
(
&
req
->
rq_list
);
INIT_LIST_HEAD
(
&
req
->
rq_bc_list
);
/* Preallocate one XDR receive buffer */
page_rcv
=
alloc_page
(
GFP_KERNEL
);
if
(
page_rcv
==
NULL
)
{
printk
(
KERN_ERR
"Failed to create bc receive xbuf
\n
"
);
goto
out_free
;
}
xbufp
=
&
req
->
rq_rcv_buf
;
xbufp
->
head
[
0
].
iov_base
=
page_address
(
page_rcv
);
xbufp
->
head
[
0
].
iov_len
=
PAGE_SIZE
;
xbufp
->
tail
[
0
].
iov_base
=
NULL
;
xbufp
->
tail
[
0
].
iov_len
=
0
;
xbufp
->
page_len
=
0
;
xbufp
->
len
=
PAGE_SIZE
;
xbufp
->
buflen
=
PAGE_SIZE
;
/* Preallocate one XDR send buffer */
page_snd
=
alloc_page
(
GFP_KERNEL
);
if
(
page_snd
==
NULL
)
{
printk
(
KERN_ERR
"Failed to create bc snd xbuf
\n
"
);
goto
out_free
;
}
xbufp
=
&
req
->
rq_snd_buf
;
xbufp
->
head
[
0
].
iov_base
=
page_address
(
page_snd
);
xbufp
->
head
[
0
].
iov_len
=
0
;
xbufp
->
tail
[
0
].
iov_base
=
NULL
;
xbufp
->
tail
[
0
].
iov_len
=
0
;
xbufp
->
page_len
=
0
;
xbufp
->
len
=
0
;
xbufp
->
buflen
=
PAGE_SIZE
;
}
/*
...
...
@@ -167,7 +179,10 @@ int xprt_setup_backchannel(struct rpc_xprt *xprt, unsigned int min_reqs)
/*
* Memory allocation failed, free the temporary list
*/
list_for_each_entry_safe
(
req
,
tmp
,
&
tmp_list
,
rq_bc_pa_list
)
{
while
(
!
list_empty
(
&
tmp_list
))
{
req
=
list_first_entry
(
&
tmp_list
,
struct
rpc_rqst
,
rq_bc_pa_list
);
list_del
(
&
req
->
rq_bc_pa_list
);
xprt_free_allocation
(
req
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录