Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
7e06b53d
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看板
提交
7e06b53d
编写于
6月 22, 2005
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[PATCH] RPC: fix accounting bug in the case of a truncated RPC message
Signed-off-by:
N
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
上级
e053d1ab
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
17 deletion
+42
-17
include/linux/sunrpc/xdr.h
include/linux/sunrpc/xdr.h
+1
-1
net/sunrpc/xdr.c
net/sunrpc/xdr.c
+14
-8
net/sunrpc/xprt.c
net/sunrpc/xprt.c
+27
-8
未找到文件。
include/linux/sunrpc/xdr.h
浏览文件 @
7e06b53d
...
...
@@ -160,7 +160,7 @@ typedef struct {
typedef
size_t
(
*
skb_read_actor_t
)(
skb_reader_t
*
desc
,
void
*
to
,
size_t
len
);
extern
in
t
xdr_partial_copy_from_skb
(
struct
xdr_buf
*
,
unsigned
int
,
extern
ssize_
t
xdr_partial_copy_from_skb
(
struct
xdr_buf
*
,
unsigned
int
,
skb_reader_t
*
,
skb_read_actor_t
);
struct
socket
;
...
...
net/sunrpc/xdr.c
浏览文件 @
7e06b53d
...
...
@@ -176,21 +176,23 @@ xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset,
xdr
->
buflen
+=
len
;
}
in
t
ssize_
t
xdr_partial_copy_from_skb
(
struct
xdr_buf
*
xdr
,
unsigned
int
base
,
skb_reader_t
*
desc
,
skb_read_actor_t
copy_actor
)
{
struct
page
**
ppage
=
xdr
->
pages
;
unsigned
int
len
,
pglen
=
xdr
->
page_len
;
ssize_t
copied
=
0
;
int
ret
;
len
=
xdr
->
head
[
0
].
iov_len
;
if
(
base
<
len
)
{
len
-=
base
;
ret
=
copy_actor
(
desc
,
(
char
*
)
xdr
->
head
[
0
].
iov_base
+
base
,
len
);
copied
+=
ret
;
if
(
ret
!=
len
||
!
desc
->
count
)
return
0
;
goto
out
;
base
=
0
;
}
else
base
-=
len
;
...
...
@@ -214,8 +216,11 @@ xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base,
* are small by default but can get huge. */
if
(
unlikely
(
*
ppage
==
NULL
))
{
*
ppage
=
alloc_page
(
GFP_ATOMIC
);
if
(
unlikely
(
*
ppage
==
NULL
))
return
-
ENOMEM
;
if
(
unlikely
(
*
ppage
==
NULL
))
{
if
(
copied
==
0
)
copied
=
-
ENOMEM
;
goto
out
;
}
}
len
=
PAGE_CACHE_SIZE
;
...
...
@@ -233,16 +238,17 @@ xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base,
}
flush_dcache_page
(
*
ppage
);
kunmap_atomic
(
kaddr
,
KM_SKB_SUNRPC_DATA
);
copied
+=
ret
;
if
(
ret
!=
len
||
!
desc
->
count
)
return
0
;
goto
out
;
ppage
++
;
}
while
((
pglen
-=
len
)
!=
0
);
copy_tail:
len
=
xdr
->
tail
[
0
].
iov_len
;
if
(
base
<
len
)
copy_actor
(
desc
,
(
char
*
)
xdr
->
tail
[
0
].
iov_base
+
base
,
len
-
base
);
return
0
;
cop
ied
+=
cop
y_actor
(
desc
,
(
char
*
)
xdr
->
tail
[
0
].
iov_base
+
base
,
len
-
base
);
out:
return
copied
;
}
...
...
net/sunrpc/xprt.c
浏览文件 @
7e06b53d
...
...
@@ -823,10 +823,15 @@ tcp_copy_data(skb_reader_t *desc, void *p, size_t len)
{
if
(
len
>
desc
->
count
)
len
=
desc
->
count
;
if
(
skb_copy_bits
(
desc
->
skb
,
desc
->
offset
,
p
,
len
))
if
(
skb_copy_bits
(
desc
->
skb
,
desc
->
offset
,
p
,
len
))
{
dprintk
(
"RPC: failed to copy %zu bytes from skb. %zu bytes remain
\n
"
,
len
,
desc
->
count
);
return
0
;
}
desc
->
offset
+=
len
;
desc
->
count
-=
len
;
dprintk
(
"RPC: copied %zu bytes from skb. %zu bytes remain
\n
"
,
len
,
desc
->
count
);
return
len
;
}
...
...
@@ -865,6 +870,8 @@ tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc)
static
void
tcp_check_recm
(
struct
rpc_xprt
*
xprt
)
{
dprintk
(
"RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u, tcp_flags = %lx
\n
"
,
xprt
,
xprt
->
tcp_copied
,
xprt
->
tcp_offset
,
xprt
->
tcp_reclen
,
xprt
->
tcp_flags
);
if
(
xprt
->
tcp_offset
==
xprt
->
tcp_reclen
)
{
xprt
->
tcp_flags
|=
XPRT_COPY_RECM
;
xprt
->
tcp_offset
=
0
;
...
...
@@ -909,7 +916,7 @@ tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc)
struct
rpc_rqst
*
req
;
struct
xdr_buf
*
rcvbuf
;
size_t
len
;
in
t
r
;
ssize_
t
r
;
/* Find and lock the request corresponding to this xid */
spin_lock
(
&
xprt
->
sock_lock
);
...
...
@@ -932,15 +939,17 @@ tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc)
my_desc
.
count
=
len
;
r
=
xdr_partial_copy_from_skb
(
rcvbuf
,
xprt
->
tcp_copied
,
&
my_desc
,
tcp_copy_data
);
desc
->
count
-=
len
;
desc
->
offset
+=
len
;
desc
->
count
-=
r
;
desc
->
offset
+=
r
;
}
else
r
=
xdr_partial_copy_from_skb
(
rcvbuf
,
xprt
->
tcp_copied
,
desc
,
tcp_copy_data
);
xprt
->
tcp_copied
+=
len
;
xprt
->
tcp_offset
+=
len
;
if
(
r
<
0
)
{
if
(
r
>
0
)
{
xprt
->
tcp_copied
+=
r
;
xprt
->
tcp_offset
+=
r
;
}
if
(
r
!=
len
)
{
/* Error when copying to the receive buffer,
* usually because we weren't able to allocate
* additional buffer pages. All we can do now
...
...
@@ -951,9 +960,18 @@ tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc)
* be discarded.
*/
xprt
->
tcp_flags
&=
~
XPRT_COPY_DATA
;
dprintk
(
"RPC: XID %08x truncated request
\n
"
,
ntohl
(
xprt
->
tcp_xid
));
dprintk
(
"RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u
\n
"
,
xprt
,
xprt
->
tcp_copied
,
xprt
->
tcp_offset
,
xprt
->
tcp_reclen
);
goto
out
;
}
dprintk
(
"RPC: XID %08x read %u bytes
\n
"
,
ntohl
(
xprt
->
tcp_xid
),
r
);
dprintk
(
"RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u
\n
"
,
xprt
,
xprt
->
tcp_copied
,
xprt
->
tcp_offset
,
xprt
->
tcp_reclen
);
if
(
xprt
->
tcp_copied
==
req
->
rq_private_buf
.
buflen
)
xprt
->
tcp_flags
&=
~
XPRT_COPY_DATA
;
else
if
(
xprt
->
tcp_offset
==
xprt
->
tcp_reclen
)
{
...
...
@@ -961,12 +979,12 @@ tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc)
xprt
->
tcp_flags
&=
~
XPRT_COPY_DATA
;
}
out:
if
(
!
(
xprt
->
tcp_flags
&
XPRT_COPY_DATA
))
{
dprintk
(
"RPC: %4d received reply complete
\n
"
,
req
->
rq_task
->
tk_pid
);
xprt_complete_rqst
(
xprt
,
req
,
xprt
->
tcp_copied
);
}
out:
spin_unlock
(
&
xprt
->
sock_lock
);
tcp_check_recm
(
xprt
);
}
...
...
@@ -985,6 +1003,7 @@ tcp_read_discard(struct rpc_xprt *xprt, skb_reader_t *desc)
desc
->
count
-=
len
;
desc
->
offset
+=
len
;
xprt
->
tcp_offset
+=
len
;
dprintk
(
"RPC: discarded %u bytes
\n
"
,
len
);
tcp_check_recm
(
xprt
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录