Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
b293f02e
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看板
提交
b293f02e
编写于
11月 01, 2007
作者:
C
Chris Mason
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: Add writepages support
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
944746ec
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
124 addition
and
25 deletion
+124
-25
fs/btrfs/extent_map.c
fs/btrfs/extent_map.c
+110
-25
fs/btrfs/extent_map.h
fs/btrfs/extent_map.h
+4
-0
fs/btrfs/inode.c
fs/btrfs/inode.c
+10
-0
未找到文件。
fs/btrfs/extent_map.c
浏览文件 @
b293f02e
...
...
@@ -10,6 +10,7 @@
#include <linux/blkdev.h>
#include <linux/swap.h>
#include <linux/version.h>
#include <linux/writeback.h>
#include "extent_map.h"
/* temporary define until extent_map moves out of btrfs */
...
...
@@ -35,6 +36,12 @@ struct tree_entry {
struct
rb_node
rb_node
;
};
struct
extent_page_data
{
struct
bio
*
bio
;
struct
extent_map_tree
*
tree
;
get_extent_t
*
get_extent
;
};
void
__init
extent_map_init
(
void
)
{
extent_map_cache
=
btrfs_cache_create
(
"extent_map"
,
...
...
@@ -1460,40 +1467,76 @@ static int end_bio_extent_preparewrite(struct bio *bio,
#endif
}
static
int
submit_extent_page
(
int
rw
,
struct
extent_map_tree
*
tree
,
struct
page
*
page
,
sector_t
sector
,
size_t
size
,
unsigned
long
offset
,
struct
block_device
*
bdev
,
bio_end_io_t
end_io_func
)
static
struct
bio
*
extent_bio_alloc
(
struct
block_device
*
bdev
,
u64
first_sector
,
int
nr_vecs
,
gfp_t
gfp_flags
)
{
struct
bio
*
bio
;
int
ret
=
0
;
bio
=
bio_alloc
(
GFP_NOIO
,
1
);
bio
=
bio_alloc
(
gfp_flags
,
nr_vecs
);
bio
->
bi_sector
=
sector
;
bio
->
bi_bdev
=
bdev
;
bio
->
bi_io_vec
[
0
].
bv_page
=
page
;
bio
->
bi_io_vec
[
0
].
bv_len
=
size
;
bio
->
bi_io_vec
[
0
].
bv_offset
=
offset
;
bio
->
bi_vcnt
=
1
;
bio
->
bi_idx
=
0
;
bio
->
bi_size
=
size
;
if
(
bio
==
NULL
&&
(
current
->
flags
&
PF_MEMALLOC
))
{
while
(
!
bio
&&
(
nr_vecs
/=
2
))
bio
=
bio_alloc
(
gfp_flags
,
nr_vecs
);
}
bio
->
bi_end_io
=
end_io_func
;
bio
->
bi_private
=
tree
;
if
(
bio
)
{
bio
->
bi_bdev
=
bdev
;
bio
->
bi_sector
=
first_sector
;
}
return
bio
;
}
static
int
submit_one_bio
(
int
rw
,
struct
bio
*
bio
)
{
int
ret
=
0
;
bio_get
(
bio
);
submit_bio
(
rw
,
bio
);
if
(
bio_flagged
(
bio
,
BIO_EOPNOTSUPP
))
ret
=
-
EOPNOTSUPP
;
bio_put
(
bio
);
return
ret
;
}
static
int
submit_extent_page
(
int
rw
,
struct
extent_map_tree
*
tree
,
struct
page
*
page
,
sector_t
sector
,
size_t
size
,
unsigned
long
offset
,
struct
block_device
*
bdev
,
struct
bio
**
bio_ret
,
int
max_pages
,
bio_end_io_t
end_io_func
)
{
int
ret
=
0
;
struct
bio
*
bio
;
int
nr
;
if
(
bio_ret
&&
*
bio_ret
)
{
bio
=
*
bio_ret
;
if
(
bio
->
bi_sector
+
(
bio
->
bi_size
>>
9
)
!=
sector
||
bio_add_page
(
bio
,
page
,
size
,
offset
)
<
size
)
{
ret
=
submit_one_bio
(
rw
,
bio
);
bio
=
NULL
;
}
else
{
return
0
;
}
}
nr
=
min
(
max_pages
,
bio_get_nr_vecs
(
bdev
));
bio
=
extent_bio_alloc
(
bdev
,
sector
,
nr
,
GFP_NOFS
|
__GFP_HIGH
);
if
(
!
bio
)
{
printk
(
"failed to allocate bio nr %d
\n
"
,
nr
);
}
bio_add_page
(
bio
,
page
,
size
,
offset
);
bio
->
bi_end_io
=
end_io_func
;
bio
->
bi_private
=
tree
;
if
(
bio_ret
)
{
*
bio_ret
=
bio
;
}
else
{
ret
=
submit_one_bio
(
rw
,
bio
);
}
return
ret
;
}
void
set_page_extent_mapped
(
struct
page
*
page
)
{
if
(
!
PagePrivate
(
page
))
{
...
...
@@ -1590,7 +1633,8 @@ int extent_read_full_page(struct extent_map_tree *tree, struct page *page,
if
(
!
ret
)
{
ret
=
submit_extent_page
(
READ
,
tree
,
page
,
sector
,
iosize
,
page_offset
,
bdev
,
end_bio_extent_readpage
);
bdev
,
NULL
,
1
,
end_bio_extent_readpage
);
}
if
(
ret
)
SetPageError
(
page
);
...
...
@@ -1613,11 +1657,12 @@ EXPORT_SYMBOL(extent_read_full_page);
* are found, they are marked writeback. Then the lock bits are removed
* and the end_io handler clears the writeback ranges
*/
int
extent_write_full_page
(
struct
extent_map_tree
*
tree
,
struct
page
*
page
,
get_extent_t
*
get_extent
,
struct
writeback_control
*
wbc
)
static
int
__extent_writepage
(
struct
page
*
page
,
struct
writeback_control
*
wbc
,
void
*
data
)
{
struct
inode
*
inode
=
page
->
mapping
->
host
;
struct
extent_page_data
*
epd
=
data
;
struct
extent_map_tree
*
tree
=
epd
->
tree
;
u64
start
=
(
u64
)
page
->
index
<<
PAGE_CACHE_SHIFT
;
u64
page_end
=
start
+
PAGE_CACHE_SIZE
-
1
;
u64
end
;
...
...
@@ -1691,7 +1736,7 @@ int extent_write_full_page(struct extent_map_tree *tree, struct page *page,
clear_extent_dirty
(
tree
,
cur
,
page_end
,
GFP_NOFS
);
break
;
}
em
=
get_extent
(
inode
,
page
,
page_offset
,
cur
,
end
,
1
);
em
=
epd
->
get_extent
(
inode
,
page
,
page_offset
,
cur
,
end
,
1
);
if
(
IS_ERR
(
em
)
||
!
em
)
{
SetPageError
(
page
);
break
;
...
...
@@ -1734,9 +1779,12 @@ int extent_write_full_page(struct extent_map_tree *tree, struct page *page,
if
(
ret
)
SetPageError
(
page
);
else
{
unsigned
long
nr
=
end_index
+
1
;
set_range_writeback
(
tree
,
cur
,
cur
+
iosize
-
1
);
ret
=
submit_extent_page
(
WRITE
,
tree
,
page
,
sector
,
iosize
,
page_offset
,
bdev
,
&
epd
->
bio
,
nr
,
end_bio_extent_writepage
);
if
(
ret
)
SetPageError
(
page
);
...
...
@@ -1750,8 +1798,44 @@ int extent_write_full_page(struct extent_map_tree *tree, struct page *page,
unlock_page
(
page
);
return
0
;
}
int
extent_write_full_page
(
struct
extent_map_tree
*
tree
,
struct
page
*
page
,
get_extent_t
*
get_extent
,
struct
writeback_control
*
wbc
)
{
int
ret
;
struct
extent_page_data
epd
=
{
.
bio
=
NULL
,
.
tree
=
tree
,
.
get_extent
=
get_extent
,
};
ret
=
__extent_writepage
(
page
,
wbc
,
&
epd
);
if
(
epd
.
bio
)
submit_one_bio
(
WRITE
,
epd
.
bio
);
return
ret
;
}
EXPORT_SYMBOL
(
extent_write_full_page
);
int
extent_writepages
(
struct
extent_map_tree
*
tree
,
struct
address_space
*
mapping
,
get_extent_t
*
get_extent
,
struct
writeback_control
*
wbc
)
{
int
ret
;
struct
extent_page_data
epd
=
{
.
bio
=
NULL
,
.
tree
=
tree
,
.
get_extent
=
get_extent
,
};
ret
=
write_cache_pages
(
mapping
,
wbc
,
__extent_writepage
,
&
epd
);
if
(
epd
.
bio
)
submit_one_bio
(
WRITE
,
epd
.
bio
);
return
ret
;
}
EXPORT_SYMBOL
(
extent_writepages
);
/*
* basic invalidatepage code, this waits on any locked or writeback
* ranges corresponding to the page, and then deletes any extent state
...
...
@@ -1869,6 +1953,7 @@ int extent_prepare_write(struct extent_map_tree *tree,
EXTENT_LOCKED
,
0
,
NULL
,
GFP_NOFS
);
ret
=
submit_extent_page
(
READ
,
tree
,
page
,
sector
,
iosize
,
page_offset
,
em
->
bdev
,
NULL
,
1
,
end_bio_extent_preparewrite
);
iocount
++
;
block_start
=
block_start
+
iosize
;
...
...
fs/btrfs/extent_map.h
浏览文件 @
b293f02e
...
...
@@ -136,6 +136,10 @@ int extent_invalidatepage(struct extent_map_tree *tree,
int
extent_write_full_page
(
struct
extent_map_tree
*
tree
,
struct
page
*
page
,
get_extent_t
*
get_extent
,
struct
writeback_control
*
wbc
);
int
extent_writepages
(
struct
extent_map_tree
*
tree
,
struct
address_space
*
mapping
,
get_extent_t
*
get_extent
,
struct
writeback_control
*
wbc
);
int
extent_prepare_write
(
struct
extent_map_tree
*
tree
,
struct
inode
*
inode
,
struct
page
*
page
,
unsigned
from
,
unsigned
to
,
get_extent_t
*
get_extent
);
...
...
fs/btrfs/inode.c
浏览文件 @
b293f02e
...
...
@@ -1747,6 +1747,15 @@ static int btrfs_writepage(struct page *page, struct writeback_control *wbc)
return
extent_write_full_page
(
tree
,
page
,
btrfs_get_extent
,
wbc
);
}
static
int
btrfs_writepages
(
struct
address_space
*
mapping
,
struct
writeback_control
*
wbc
)
{
struct
extent_map_tree
*
tree
;
tree
=
&
BTRFS_I
(
mapping
->
host
)
->
extent_tree
;
return
extent_writepages
(
tree
,
mapping
,
btrfs_get_extent
,
wbc
);
}
static
int
btrfs_releasepage
(
struct
page
*
page
,
gfp_t
unused_gfp_flags
)
{
struct
extent_map_tree
*
tree
;
...
...
@@ -2526,6 +2535,7 @@ static struct extent_map_ops btrfs_extent_map_ops = {
static
struct
address_space_operations
btrfs_aops
=
{
.
readpage
=
btrfs_readpage
,
.
writepage
=
btrfs_writepage
,
.
writepages
=
btrfs_writepages
,
.
sync_page
=
block_sync_page
,
.
prepare_write
=
btrfs_prepare_write
,
.
commit_write
=
btrfs_commit_write
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录