Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
637b58c2
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看板
提交
637b58c2
编写于
2月 03, 2014
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
switch pipe_read() to copy_page_to_iter()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
74027f4a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
8 addition
and
71 deletion
+8
-71
fs/pipe.c
fs/pipe.c
+8
-71
未找到文件。
fs/pipe.c
浏览文件 @
637b58c2
...
...
@@ -142,55 +142,6 @@ pipe_iov_copy_from_user(void *to, struct iovec *iov, unsigned long len,
return
0
;
}
static
int
pipe_iov_copy_to_user
(
struct
iovec
*
iov
,
const
void
*
from
,
unsigned
long
len
,
int
atomic
)
{
unsigned
long
copy
;
while
(
len
>
0
)
{
while
(
!
iov
->
iov_len
)
iov
++
;
copy
=
min_t
(
unsigned
long
,
len
,
iov
->
iov_len
);
if
(
atomic
)
{
if
(
__copy_to_user_inatomic
(
iov
->
iov_base
,
from
,
copy
))
return
-
EFAULT
;
}
else
{
if
(
copy_to_user
(
iov
->
iov_base
,
from
,
copy
))
return
-
EFAULT
;
}
from
+=
copy
;
len
-=
copy
;
iov
->
iov_base
+=
copy
;
iov
->
iov_len
-=
copy
;
}
return
0
;
}
/*
* Attempt to pre-fault in the user memory, so we can use atomic copies.
* Returns the number of bytes not faulted in.
*/
static
int
iov_fault_in_pages_write
(
struct
iovec
*
iov
,
unsigned
long
len
)
{
while
(
!
iov
->
iov_len
)
iov
++
;
while
(
len
>
0
)
{
unsigned
long
this_len
;
this_len
=
min_t
(
unsigned
long
,
len
,
iov
->
iov_len
);
if
(
fault_in_pages_writeable
(
iov
->
iov_base
,
this_len
))
break
;
len
-=
this_len
;
iov
++
;
}
return
len
;
}
/*
* Pre-fault in the user memory, so we can use atomic copies.
*/
...
...
@@ -329,12 +280,15 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
ssize_t
ret
;
struct
iovec
*
iov
=
(
struct
iovec
*
)
_iov
;
size_t
total_len
;
struct
iov_iter
iter
;
total_len
=
iov_length
(
iov
,
nr_segs
);
/* Null read succeeds. */
if
(
unlikely
(
total_len
==
0
))
return
0
;
iov_iter_init
(
&
iter
,
iov
,
nr_segs
,
total_len
,
0
);
do_wakeup
=
0
;
ret
=
0
;
__pipe_lock
(
pipe
);
...
...
@@ -344,9 +298,9 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
int
curbuf
=
pipe
->
curbuf
;
struct
pipe_buffer
*
buf
=
pipe
->
bufs
+
curbuf
;
const
struct
pipe_buf_operations
*
ops
=
buf
->
ops
;
void
*
addr
;
size_t
chars
=
buf
->
len
;
int
error
,
atomic
;
size_t
written
;
int
error
;
if
(
chars
>
total_len
)
chars
=
total_len
;
...
...
@@ -358,27 +312,10 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
break
;
}
atomic
=
!
iov_fault_in_pages_write
(
iov
,
chars
);
redo:
if
(
atomic
)
addr
=
kmap_atomic
(
buf
->
page
);
else
addr
=
kmap
(
buf
->
page
);
error
=
pipe_iov_copy_to_user
(
iov
,
addr
+
buf
->
offset
,
chars
,
atomic
);
if
(
atomic
)
kunmap_atomic
(
addr
);
else
kunmap
(
buf
->
page
);
if
(
unlikely
(
error
))
{
/*
* Just retry with the slow path if we failed.
*/
if
(
atomic
)
{
atomic
=
0
;
goto
redo
;
}
written
=
copy_page_to_iter
(
buf
->
page
,
buf
->
offset
,
chars
,
&
iter
);
if
(
unlikely
(
written
<
chars
))
{
if
(
!
ret
)
ret
=
error
;
ret
=
-
EFAULT
;
break
;
}
ret
+=
chars
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录