Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
083735f4
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
083735f4
编写于
11月 20, 2014
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rds: switch rds_message_copy_from_user() to iov_iter
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
c310e72c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
33 deletion
+16
-33
net/rds/message.c
net/rds/message.c
+12
-30
net/rds/rds.h
net/rds/rds.h
+1
-2
net/rds/send.c
net/rds/send.c
+3
-1
未找到文件。
net/rds/message.c
浏览文件 @
083735f4
...
...
@@ -264,64 +264,46 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in
return
rm
;
}
int
rds_message_copy_from_user
(
struct
rds_message
*
rm
,
struct
iovec
*
first_iov
,
size_t
total_len
)
int
rds_message_copy_from_user
(
struct
rds_message
*
rm
,
struct
iov_iter
*
from
)
{
unsigned
long
to_copy
;
unsigned
long
iov_off
;
unsigned
long
sg_off
;
struct
iovec
*
iov
;
struct
scatterlist
*
sg
;
int
ret
=
0
;
rm
->
m_inc
.
i_hdr
.
h_len
=
cpu_to_be32
(
total_len
);
rm
->
m_inc
.
i_hdr
.
h_len
=
cpu_to_be32
(
iov_iter_count
(
from
)
);
/*
* now allocate and copy in the data payload.
*/
sg
=
rm
->
data
.
op_sg
;
iov
=
first_iov
;
iov_off
=
0
;
sg_off
=
0
;
/* Dear gcc, sg->page will be null from kzalloc. */
while
(
total_len
)
{
while
(
iov_iter_count
(
from
)
)
{
if
(
!
sg_page
(
sg
))
{
ret
=
rds_page_remainder_alloc
(
sg
,
total_len
,
ret
=
rds_page_remainder_alloc
(
sg
,
iov_iter_count
(
from
)
,
GFP_HIGHUSER
);
if
(
ret
)
goto
ou
t
;
return
re
t
;
rm
->
data
.
op_nents
++
;
sg_off
=
0
;
}
while
(
iov_off
==
iov
->
iov_len
)
{
iov_off
=
0
;
iov
++
;
}
to_copy
=
min
(
iov
->
iov_len
-
iov_off
,
sg
->
length
-
sg_off
);
to_copy
=
min_t
(
size_t
,
to_copy
,
total_len
);
rdsdebug
(
"copying %lu bytes from user iov [%p, %zu] + %lu to "
"sg [%p, %u, %u] + %lu
\n
"
,
to_copy
,
iov
->
iov_base
,
iov
->
iov_len
,
iov_off
,
(
void
*
)
sg_page
(
sg
),
sg
->
offset
,
sg
->
length
,
sg_off
);
to_copy
=
min_t
(
unsigned
long
,
iov_iter_count
(
from
),
sg
->
length
-
sg_off
);
r
et
=
rds_page_copy_from_user
(
sg_page
(
sg
),
sg
->
offset
+
sg_off
,
iov
->
iov_base
+
iov
_off
,
to_copy
);
if
(
ret
)
goto
out
;
r
ds_stats_add
(
s_copy_from_user
,
to_copy
);
ret
=
copy_page_from_iter
(
sg_page
(
sg
),
sg
->
offset
+
sg
_off
,
to_copy
,
from
);
if
(
ret
!=
to_copy
)
return
-
EFAULT
;
iov_off
+=
to_copy
;
total_len
-=
to_copy
;
sg_off
+=
to_copy
;
if
(
sg_off
==
sg
->
length
)
sg
++
;
}
out:
return
ret
;
}
...
...
net/rds/rds.h
浏览文件 @
083735f4
...
...
@@ -656,8 +656,7 @@ rds_conn_connecting(struct rds_connection *conn)
/* message.c */
struct
rds_message
*
rds_message_alloc
(
unsigned
int
nents
,
gfp_t
gfp
);
struct
scatterlist
*
rds_message_alloc_sgs
(
struct
rds_message
*
rm
,
int
nents
);
int
rds_message_copy_from_user
(
struct
rds_message
*
rm
,
struct
iovec
*
first_iov
,
size_t
total_len
);
int
rds_message_copy_from_user
(
struct
rds_message
*
rm
,
struct
iov_iter
*
from
);
struct
rds_message
*
rds_message_map_pages
(
unsigned
long
*
page_addrs
,
unsigned
int
total_len
);
void
rds_message_populate_header
(
struct
rds_header
*
hdr
,
__be16
sport
,
__be16
dport
,
u64
seq
);
...
...
net/rds/send.c
浏览文件 @
083735f4
...
...
@@ -934,7 +934,9 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
int
queued
=
0
,
allocated_mr
=
0
;
int
nonblock
=
msg
->
msg_flags
&
MSG_DONTWAIT
;
long
timeo
=
sock_sndtimeo
(
sk
,
nonblock
);
struct
iov_iter
from
;
iov_iter_init
(
&
from
,
WRITE
,
msg
->
msg_iov
,
msg
->
msg_iovlen
,
payload_len
);
/* Mirror Linux UDP mirror of BSD error message compatibility */
/* XXX: Perhaps MSG_MORE someday */
if
(
msg
->
msg_flags
&
~
(
MSG_DONTWAIT
|
MSG_CMSG_COMPAT
))
{
...
...
@@ -982,7 +984,7 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
ret
=
-
ENOMEM
;
goto
out
;
}
ret
=
rds_message_copy_from_user
(
rm
,
msg
->
msg_iov
,
payload_len
);
ret
=
rds_message_copy_from_user
(
rm
,
&
from
);
if
(
ret
)
goto
out
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录