Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
1b17f1f2
K
Kernel
项目概览
openeuler
/
Kernel
大约 1 年 前同步成功
通知
6
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1b17f1f2
编写于
11月 27, 2014
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
iov_iter.c: convert iov_iter_get_pages_alloc() to iterate_all_kinds
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
e5393fae
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
62 deletion
+45
-62
mm/iov_iter.c
mm/iov_iter.c
+45
-62
未找到文件。
mm/iov_iter.c
浏览文件 @
1b17f1f2
...
...
@@ -428,43 +428,6 @@ void iov_iter_init(struct iov_iter *i, int direction,
}
EXPORT_SYMBOL
(
iov_iter_init
);
static
ssize_t
get_pages_alloc_iovec
(
struct
iov_iter
*
i
,
struct
page
***
pages
,
size_t
maxsize
,
size_t
*
start
)
{
size_t
offset
=
i
->
iov_offset
;
const
struct
iovec
*
iov
=
i
->
iov
;
size_t
len
;
unsigned
long
addr
;
void
*
p
;
int
n
;
int
res
;
len
=
iov
->
iov_len
-
offset
;
if
(
len
>
i
->
count
)
len
=
i
->
count
;
if
(
len
>
maxsize
)
len
=
maxsize
;
addr
=
(
unsigned
long
)
iov
->
iov_base
+
offset
;
len
+=
*
start
=
addr
&
(
PAGE_SIZE
-
1
);
addr
&=
~
(
PAGE_SIZE
-
1
);
n
=
(
len
+
PAGE_SIZE
-
1
)
/
PAGE_SIZE
;
p
=
kmalloc
(
n
*
sizeof
(
struct
page
*
),
GFP_KERNEL
);
if
(
!
p
)
p
=
vmalloc
(
n
*
sizeof
(
struct
page
*
));
if
(
!
p
)
return
-
ENOMEM
;
res
=
get_user_pages_fast
(
addr
,
n
,
(
i
->
type
&
WRITE
)
!=
WRITE
,
p
);
if
(
unlikely
(
res
<
0
))
{
kvfree
(
p
);
return
res
;
}
*
pages
=
p
;
return
(
res
==
n
?
len
:
res
*
PAGE_SIZE
)
-
*
start
;
}
static
void
memcpy_from_page
(
char
*
to
,
struct
page
*
page
,
size_t
offset
,
size_t
len
)
{
char
*
from
=
kmap_atomic
(
page
);
...
...
@@ -622,27 +585,6 @@ static size_t zero_bvec(size_t bytes, struct iov_iter *i)
return
wanted
-
bytes
;
}
static
ssize_t
get_pages_alloc_bvec
(
struct
iov_iter
*
i
,
struct
page
***
pages
,
size_t
maxsize
,
size_t
*
start
)
{
const
struct
bio_vec
*
bvec
=
i
->
bvec
;
size_t
len
=
bvec
->
bv_len
-
i
->
iov_offset
;
if
(
len
>
i
->
count
)
len
=
i
->
count
;
if
(
len
>
maxsize
)
len
=
maxsize
;
*
start
=
bvec
->
bv_offset
+
i
->
iov_offset
;
*
pages
=
kmalloc
(
sizeof
(
struct
page
*
),
GFP_KERNEL
);
if
(
!*
pages
)
return
-
ENOMEM
;
get_page
(
**
pages
=
bvec
->
bv_page
);
return
len
;
}
size_t
copy_page_to_iter
(
struct
page
*
page
,
size_t
offset
,
size_t
bytes
,
struct
iov_iter
*
i
)
{
...
...
@@ -777,14 +719,55 @@ ssize_t iov_iter_get_pages(struct iov_iter *i,
}
EXPORT_SYMBOL
(
iov_iter_get_pages
);
static
struct
page
**
get_pages_array
(
size_t
n
)
{
struct
page
**
p
=
kmalloc
(
n
*
sizeof
(
struct
page
*
),
GFP_KERNEL
);
if
(
!
p
)
p
=
vmalloc
(
n
*
sizeof
(
struct
page
*
));
return
p
;
}
ssize_t
iov_iter_get_pages_alloc
(
struct
iov_iter
*
i
,
struct
page
***
pages
,
size_t
maxsize
,
size_t
*
start
)
{
if
(
i
->
type
&
ITER_BVEC
)
return
get_pages_alloc_bvec
(
i
,
pages
,
maxsize
,
start
);
else
return
get_pages_alloc_iovec
(
i
,
pages
,
maxsize
,
start
);
struct
page
**
p
;
if
(
maxsize
>
i
->
count
)
maxsize
=
i
->
count
;
if
(
!
maxsize
)
return
0
;
iterate_all_kinds
(
i
,
maxsize
,
v
,
({
unsigned
long
addr
=
(
unsigned
long
)
v
.
iov_base
;
size_t
len
=
v
.
iov_len
+
(
*
start
=
addr
&
(
PAGE_SIZE
-
1
));
int
n
;
int
res
;
addr
&=
~
(
PAGE_SIZE
-
1
);
n
=
DIV_ROUND_UP
(
len
,
PAGE_SIZE
);
p
=
get_pages_array
(
n
);
if
(
!
p
)
return
-
ENOMEM
;
res
=
get_user_pages_fast
(
addr
,
n
,
(
i
->
type
&
WRITE
)
!=
WRITE
,
p
);
if
(
unlikely
(
res
<
0
))
{
kvfree
(
p
);
return
res
;
}
*
pages
=
p
;
return
(
res
==
n
?
len
:
res
*
PAGE_SIZE
)
-
*
start
;
0
;}),({
/* can't be more than PAGE_SIZE */
*
start
=
v
.
bv_offset
;
*
pages
=
p
=
get_pages_array
(
1
);
if
(
!
p
)
return
-
ENOMEM
;
get_page
(
*
p
=
v
.
bv_page
);
return
v
.
bv_len
;
})
)
return
0
;
}
EXPORT_SYMBOL
(
iov_iter_get_pages_alloc
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录