Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
3b93f911
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看板
提交
3b93f911
编写于
2月 11, 2014
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
export generic_perform_write(), start getting rid of generic_file_buffer_write()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
5cb6c6c7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
16 deletion
+23
-16
include/linux/fs.h
include/linux/fs.h
+2
-0
mm/filemap.c
mm/filemap.c
+21
-16
未找到文件。
include/linux/fs.h
浏览文件 @
3b93f911
...
...
@@ -48,6 +48,7 @@ struct cred;
struct
swap_info_struct
;
struct
seq_file
;
struct
workqueue_struct
;
struct
iov_iter
;
extern
void
__init
inode_init
(
void
);
extern
void
__init
inode_init_early
(
void
);
...
...
@@ -2396,6 +2397,7 @@ extern ssize_t __generic_file_aio_write(struct kiocb *, const struct iovec *, un
extern
ssize_t
generic_file_aio_write
(
struct
kiocb
*
,
const
struct
iovec
*
,
unsigned
long
,
loff_t
);
extern
ssize_t
generic_file_direct_write
(
struct
kiocb
*
,
const
struct
iovec
*
,
unsigned
long
*
,
loff_t
,
size_t
,
size_t
);
extern
ssize_t
generic_perform_write
(
struct
file
*
,
struct
iov_iter
*
,
loff_t
);
extern
ssize_t
generic_file_buffered_write
(
struct
kiocb
*
,
const
struct
iovec
*
,
unsigned
long
,
loff_t
,
size_t
,
ssize_t
);
extern
ssize_t
do_sync_read
(
struct
file
*
filp
,
char
__user
*
buf
,
size_t
len
,
loff_t
*
ppos
);
...
...
mm/filemap.c
浏览文件 @
3b93f911
...
...
@@ -2092,7 +2092,7 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
}
EXPORT_SYMBOL
(
grab_cache_page_write_begin
);
s
tatic
s
size_t
generic_perform_write
(
struct
file
*
file
,
ssize_t
generic_perform_write
(
struct
file
*
file
,
struct
iov_iter
*
i
,
loff_t
pos
)
{
struct
address_space
*
mapping
=
file
->
f_mapping
;
...
...
@@ -2180,6 +2180,7 @@ static ssize_t generic_perform_write(struct file *file,
return
written
?
written
:
status
;
}
EXPORT_SYMBOL
(
generic_perform_write
);
ssize_t
generic_file_buffered_write
(
struct
kiocb
*
iocb
,
const
struct
iovec
*
iov
,
...
...
@@ -2230,8 +2231,10 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
size_t
count
;
/* after file limit checks */
struct
inode
*
inode
=
mapping
->
host
;
loff_t
pos
=
iocb
->
ki_pos
;
ssize_t
written
;
ssize_t
written
=
0
;
ssize_t
err
;
ssize_t
status
;
struct
iov_iter
from
;
ocount
=
0
;
err
=
generic_segment_checks
(
iov
,
&
nr_segs
,
&
ocount
,
VERIFY_READ
);
...
...
@@ -2242,8 +2245,6 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
/* We can write back this queue in page reclaim */
current
->
backing_dev_info
=
mapping
->
backing_dev_info
;
written
=
0
;
err
=
generic_write_checks
(
file
,
&
pos
,
&
count
,
S_ISBLK
(
inode
->
i_mode
));
if
(
err
)
goto
out
;
...
...
@@ -2259,44 +2260,47 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
if
(
err
)
goto
out
;
iov_iter_init
(
&
from
,
iov
,
nr_segs
,
count
,
0
);
/* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
if
(
unlikely
(
file
->
f_flags
&
O_DIRECT
))
{
loff_t
endbyte
;
ssize_t
written_buffered
;
written
=
generic_file_direct_write
(
iocb
,
iov
,
&
nr_segs
,
pos
,
written
=
generic_file_direct_write
(
iocb
,
iov
,
&
from
.
nr_segs
,
pos
,
count
,
ocount
);
if
(
written
<
0
||
written
==
count
)
goto
out
;
iov_iter_advance
(
&
from
,
written
);
/*
* direct-io write to a hole: fall through to buffered I/O
* for completing the rest of the request.
*/
pos
+=
written
;
count
-=
written
;
written_buffered
=
generic_file_buffered_write
(
iocb
,
iov
,
nr_segs
,
pos
,
count
,
written
);
status
=
generic_perform_write
(
file
,
&
from
,
pos
);
/*
* If generic_
file_buffered_write() retu
ned a synchronous error
* If generic_
perform_write() retur
ned a synchronous error
* then we want to return the number of bytes which were
* direct-written, or the error code if that was zero. Note
* that this differs from normal direct-io semantics, which
* will return -EFOO even if some bytes were written.
*/
if
(
written_buffered
<
0
)
{
err
=
written_buffered
;
if
(
unlikely
(
status
<
0
)
&&
!
written
)
{
err
=
status
;
goto
out
;
}
iocb
->
ki_pos
=
pos
+
status
;
/*
* We need to ensure that the page cache pages are written to
* disk and invalidated to preserve the expected O_DIRECT
* semantics.
*/
endbyte
=
pos
+
written_buffered
-
written
-
1
;
endbyte
=
pos
+
status
-
1
;
err
=
filemap_write_and_wait_range
(
file
->
f_mapping
,
pos
,
endbyte
);
if
(
err
==
0
)
{
written
=
written_buffered
;
written
+=
status
;
invalidate_mapping_pages
(
mapping
,
pos
>>
PAGE_CACHE_SHIFT
,
endbyte
>>
PAGE_CACHE_SHIFT
);
...
...
@@ -2307,8 +2311,9 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
*/
}
}
else
{
written
=
generic_file_buffered_write
(
iocb
,
iov
,
nr_segs
,
pos
,
count
,
written
);
written
=
generic_perform_write
(
file
,
&
from
,
pos
);
if
(
likely
(
written
>=
0
))
iocb
->
ki_pos
=
pos
+
written
;
}
out:
current
->
backing_dev_info
=
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录