Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
3ab2fb5a
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看板
提交
3ab2fb5a
编写于
11月 08, 2007
作者:
C
Chris Mason
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Btrfs: Add readpages support
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
856bf3e5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
78 addition
and
8 deletion
+78
-8
fs/btrfs/extent_map.c
fs/btrfs/extent_map.c
+63
-7
fs/btrfs/extent_map.h
fs/btrfs/extent_map.h
+4
-0
fs/btrfs/inode.c
fs/btrfs/inode.c
+11
-1
未找到文件。
fs/btrfs/extent_map.c
浏览文件 @
3ab2fb5a
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <linux/swap.h>
#include <linux/swap.h>
#include <linux/version.h>
#include <linux/version.h>
#include <linux/writeback.h>
#include <linux/writeback.h>
#include <linux/pagevec.h>
#include "extent_map.h"
#include "extent_map.h"
/* temporary define until extent_map moves out of btrfs */
/* temporary define until extent_map moves out of btrfs */
...
@@ -1503,7 +1504,7 @@ static int submit_extent_page(int rw, struct extent_map_tree *tree,
...
@@ -1503,7 +1504,7 @@ static int submit_extent_page(int rw, struct extent_map_tree *tree,
size_t
size
,
unsigned
long
offset
,
size_t
size
,
unsigned
long
offset
,
struct
block_device
*
bdev
,
struct
block_device
*
bdev
,
struct
bio
**
bio_ret
,
struct
bio
**
bio_ret
,
int
max_pages
,
unsigned
long
max_pages
,
bio_end_io_t
end_io_func
)
bio_end_io_t
end_io_func
)
{
{
int
ret
=
0
;
int
ret
=
0
;
...
@@ -1520,7 +1521,7 @@ static int submit_extent_page(int rw, struct extent_map_tree *tree,
...
@@ -1520,7 +1521,7 @@ static int submit_extent_page(int rw, struct extent_map_tree *tree,
return
0
;
return
0
;
}
}
}
}
nr
=
min
(
max_pages
,
bio_get_nr_vecs
(
bdev
));
nr
=
min
_t
(
int
,
max_pages
,
bio_get_nr_vecs
(
bdev
));
bio
=
extent_bio_alloc
(
bdev
,
sector
,
nr
,
GFP_NOFS
|
__GFP_HIGH
);
bio
=
extent_bio_alloc
(
bdev
,
sector
,
nr
,
GFP_NOFS
|
__GFP_HIGH
);
if
(
!
bio
)
{
if
(
!
bio
)
{
printk
(
"failed to allocate bio nr %d
\n
"
,
nr
);
printk
(
"failed to allocate bio nr %d
\n
"
,
nr
);
...
@@ -1552,8 +1553,10 @@ void set_page_extent_mapped(struct page *page)
...
@@ -1552,8 +1553,10 @@ void set_page_extent_mapped(struct page *page)
* into the tree that are removed when the IO is done (by the end_io
* into the tree that are removed when the IO is done (by the end_io
* handlers)
* handlers)
*/
*/
int
extent_read_full_page
(
struct
extent_map_tree
*
tree
,
struct
page
*
page
,
static
int
__extent_read_full_page
(
struct
extent_map_tree
*
tree
,
get_extent_t
*
get_extent
)
struct
page
*
page
,
get_extent_t
*
get_extent
,
struct
bio
**
bio
)
{
{
struct
inode
*
inode
=
page
->
mapping
->
host
;
struct
inode
*
inode
=
page
->
mapping
->
host
;
u64
start
=
(
u64
)
page
->
index
<<
PAGE_CACHE_SHIFT
;
u64
start
=
(
u64
)
page
->
index
<<
PAGE_CACHE_SHIFT
;
...
@@ -1631,10 +1634,12 @@ int extent_read_full_page(struct extent_map_tree *tree, struct page *page,
...
@@ -1631,10 +1634,12 @@ int extent_read_full_page(struct extent_map_tree *tree, struct page *page,
cur
+
iosize
-
1
);
cur
+
iosize
-
1
);
}
}
if
(
!
ret
)
{
if
(
!
ret
)
{
unsigned
long
nr
=
(
last_byte
>>
PAGE_CACHE_SHIFT
)
+
1
;
nr
-=
page
->
index
;
ret
=
submit_extent_page
(
READ
,
tree
,
page
,
ret
=
submit_extent_page
(
READ
,
tree
,
page
,
sector
,
iosize
,
page_offset
,
sector
,
iosize
,
page_offset
,
bdev
,
NULL
,
1
,
bdev
,
bio
,
nr
,
end_bio_extent_readpage
);
end_bio_extent_readpage
);
}
}
if
(
ret
)
if
(
ret
)
SetPageError
(
page
);
SetPageError
(
page
);
...
@@ -1649,6 +1654,18 @@ int extent_read_full_page(struct extent_map_tree *tree, struct page *page,
...
@@ -1649,6 +1654,18 @@ int extent_read_full_page(struct extent_map_tree *tree, struct page *page,
}
}
return
0
;
return
0
;
}
}
int
extent_read_full_page
(
struct
extent_map_tree
*
tree
,
struct
page
*
page
,
get_extent_t
*
get_extent
)
{
struct
bio
*
bio
=
NULL
;
int
ret
;
ret
=
__extent_read_full_page
(
tree
,
page
,
get_extent
,
&
bio
);
if
(
bio
)
submit_one_bio
(
READ
,
bio
);
return
ret
;
}
EXPORT_SYMBOL
(
extent_read_full_page
);
EXPORT_SYMBOL
(
extent_read_full_page
);
/*
/*
...
@@ -1836,6 +1853,45 @@ int extent_writepages(struct extent_map_tree *tree,
...
@@ -1836,6 +1853,45 @@ int extent_writepages(struct extent_map_tree *tree,
}
}
EXPORT_SYMBOL
(
extent_writepages
);
EXPORT_SYMBOL
(
extent_writepages
);
int
extent_readpages
(
struct
extent_map_tree
*
tree
,
struct
address_space
*
mapping
,
struct
list_head
*
pages
,
unsigned
nr_pages
,
get_extent_t
get_extent
)
{
struct
bio
*
bio
=
NULL
;
unsigned
page_idx
;
struct
pagevec
pvec
;
pagevec_init
(
&
pvec
,
0
);
for
(
page_idx
=
0
;
page_idx
<
nr_pages
;
page_idx
++
)
{
struct
page
*
page
=
list_entry
(
pages
->
prev
,
struct
page
,
lru
);
prefetchw
(
&
page
->
flags
);
list_del
(
&
page
->
lru
);
/*
* what we want to do here is call add_to_page_cache_lru,
* but that isn't exported, so we reproduce it here
*/
if
(
!
add_to_page_cache
(
page
,
mapping
,
page
->
index
,
GFP_KERNEL
))
{
/* open coding of lru_cache_add, also not exported */
page_cache_get
(
page
);
if
(
!
pagevec_add
(
&
pvec
,
page
))
__pagevec_lru_add
(
&
pvec
);
__extent_read_full_page
(
tree
,
page
,
get_extent
,
&
bio
);
}
page_cache_release
(
page
);
}
if
(
pagevec_count
(
&
pvec
))
__pagevec_lru_add
(
&
pvec
);
BUG_ON
(
!
list_empty
(
pages
));
if
(
bio
)
submit_one_bio
(
READ
,
bio
);
return
0
;
}
EXPORT_SYMBOL
(
extent_readpages
);
/*
/*
* basic invalidatepage code, this waits on any locked or writeback
* basic invalidatepage code, this waits on any locked or writeback
* ranges corresponding to the page, and then deletes any extent state
* ranges corresponding to the page, and then deletes any extent state
...
...
fs/btrfs/extent_map.h
浏览文件 @
3ab2fb5a
...
@@ -140,6 +140,10 @@ int extent_writepages(struct extent_map_tree *tree,
...
@@ -140,6 +140,10 @@ int extent_writepages(struct extent_map_tree *tree,
struct
address_space
*
mapping
,
struct
address_space
*
mapping
,
get_extent_t
*
get_extent
,
get_extent_t
*
get_extent
,
struct
writeback_control
*
wbc
);
struct
writeback_control
*
wbc
);
int
extent_readpages
(
struct
extent_map_tree
*
tree
,
struct
address_space
*
mapping
,
struct
list_head
*
pages
,
unsigned
nr_pages
,
get_extent_t
get_extent
);
int
extent_prepare_write
(
struct
extent_map_tree
*
tree
,
int
extent_prepare_write
(
struct
extent_map_tree
*
tree
,
struct
inode
*
inode
,
struct
page
*
page
,
struct
inode
*
inode
,
struct
page
*
page
,
unsigned
from
,
unsigned
to
,
get_extent_t
*
get_extent
);
unsigned
from
,
unsigned
to
,
get_extent_t
*
get_extent
);
...
...
fs/btrfs/inode.c
浏览文件 @
3ab2fb5a
...
@@ -1748,7 +1748,6 @@ static int btrfs_writepage(struct page *page, struct writeback_control *wbc)
...
@@ -1748,7 +1748,6 @@ static int btrfs_writepage(struct page *page, struct writeback_control *wbc)
return
extent_write_full_page
(
tree
,
page
,
btrfs_get_extent
,
wbc
);
return
extent_write_full_page
(
tree
,
page
,
btrfs_get_extent
,
wbc
);
}
}
static
int
btrfs_writepages
(
struct
address_space
*
mapping
,
static
int
btrfs_writepages
(
struct
address_space
*
mapping
,
struct
writeback_control
*
wbc
)
struct
writeback_control
*
wbc
)
{
{
...
@@ -1757,6 +1756,16 @@ static int btrfs_writepages(struct address_space *mapping,
...
@@ -1757,6 +1756,16 @@ static int btrfs_writepages(struct address_space *mapping,
return
extent_writepages
(
tree
,
mapping
,
btrfs_get_extent
,
wbc
);
return
extent_writepages
(
tree
,
mapping
,
btrfs_get_extent
,
wbc
);
}
}
static
int
btrfs_readpages
(
struct
file
*
file
,
struct
address_space
*
mapping
,
struct
list_head
*
pages
,
unsigned
nr_pages
)
{
struct
extent_map_tree
*
tree
;
tree
=
&
BTRFS_I
(
mapping
->
host
)
->
extent_tree
;
return
extent_readpages
(
tree
,
mapping
,
pages
,
nr_pages
,
btrfs_get_extent
);
}
static
int
btrfs_releasepage
(
struct
page
*
page
,
gfp_t
unused_gfp_flags
)
static
int
btrfs_releasepage
(
struct
page
*
page
,
gfp_t
unused_gfp_flags
)
{
{
struct
extent_map_tree
*
tree
;
struct
extent_map_tree
*
tree
;
...
@@ -2537,6 +2546,7 @@ static struct address_space_operations btrfs_aops = {
...
@@ -2537,6 +2546,7 @@ static struct address_space_operations btrfs_aops = {
.
readpage
=
btrfs_readpage
,
.
readpage
=
btrfs_readpage
,
.
writepage
=
btrfs_writepage
,
.
writepage
=
btrfs_writepage
,
.
writepages
=
btrfs_writepages
,
.
writepages
=
btrfs_writepages
,
.
readpages
=
btrfs_readpages
,
.
sync_page
=
block_sync_page
,
.
sync_page
=
block_sync_page
,
.
prepare_write
=
btrfs_prepare_write
,
.
prepare_write
=
btrfs_prepare_write
,
.
commit_write
=
btrfs_commit_write
,
.
commit_write
=
btrfs_commit_write
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录