diff options
-rw-r--r-- | fs/btrfs/disk-io.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8935eec31ee2..6c8533fba7c9 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -43,6 +43,8 @@ static int check_tree_block(struct btrfs_root *root, struct extent_buffer *buf) | |||
43 | } | 43 | } |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | static struct extent_map_ops btree_extent_map_ops; | ||
47 | |||
46 | struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, | 48 | struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, |
47 | u64 bytenr, u32 blocksize) | 49 | u64 bytenr, u32 blocksize) |
48 | { | 50 | { |
@@ -188,15 +190,29 @@ out: | |||
188 | return 0; | 190 | return 0; |
189 | } | 191 | } |
190 | 192 | ||
191 | static int btree_writepage(struct page *page, struct writeback_control *wbc) | 193 | static int btree_writepage_io_hook(struct page *page, u64 start, u64 end) |
192 | { | 194 | { |
193 | struct extent_map_tree *tree; | ||
194 | struct btrfs_root *root = BTRFS_I(page->mapping->host)->root; | 195 | struct btrfs_root *root = BTRFS_I(page->mapping->host)->root; |
195 | tree = &BTRFS_I(page->mapping->host)->extent_tree; | ||
196 | 196 | ||
197 | csum_dirty_buffer(root, page); | 197 | csum_dirty_buffer(root, page); |
198 | return 0; | ||
199 | } | ||
200 | |||
201 | static int btree_writepage(struct page *page, struct writeback_control *wbc) | ||
202 | { | ||
203 | struct extent_map_tree *tree; | ||
204 | tree = &BTRFS_I(page->mapping->host)->extent_tree; | ||
198 | return extent_write_full_page(tree, page, btree_get_extent, wbc); | 205 | return extent_write_full_page(tree, page, btree_get_extent, wbc); |
199 | } | 206 | } |
207 | |||
208 | static int btree_writepages(struct address_space *mapping, | ||
209 | struct writeback_control *wbc) | ||
210 | { | ||
211 | struct extent_map_tree *tree; | ||
212 | tree = &BTRFS_I(mapping->host)->extent_tree; | ||
213 | return extent_writepages(tree, mapping, btree_get_extent, wbc); | ||
214 | } | ||
215 | |||
200 | int btree_readpage(struct file *file, struct page *page) | 216 | int btree_readpage(struct file *file, struct page *page) |
201 | { | 217 | { |
202 | struct extent_map_tree *tree; | 218 | struct extent_map_tree *tree; |
@@ -251,6 +267,7 @@ static int btree_writepage(struct page *page, struct writeback_control *wbc) | |||
251 | static struct address_space_operations btree_aops = { | 267 | static struct address_space_operations btree_aops = { |
252 | .readpage = btree_readpage, | 268 | .readpage = btree_readpage, |
253 | .writepage = btree_writepage, | 269 | .writepage = btree_writepage, |
270 | .writepages = btree_writepages, | ||
254 | .releasepage = btree_releasepage, | 271 | .releasepage = btree_releasepage, |
255 | .invalidatepage = btree_invalidatepage, | 272 | .invalidatepage = btree_invalidatepage, |
256 | .sync_page = block_sync_page, | 273 | .sync_page = block_sync_page, |
@@ -538,6 +555,8 @@ struct btrfs_root *open_ctree(struct super_block *sb) | |||
538 | extent_map_tree_init(&BTRFS_I(fs_info->btree_inode)->extent_tree, | 555 | extent_map_tree_init(&BTRFS_I(fs_info->btree_inode)->extent_tree, |
539 | fs_info->btree_inode->i_mapping, | 556 | fs_info->btree_inode->i_mapping, |
540 | GFP_NOFS); | 557 | GFP_NOFS); |
558 | BTRFS_I(fs_info->btree_inode)->extent_tree.ops = &btree_extent_map_ops; | ||
559 | |||
541 | extent_map_tree_init(&fs_info->free_space_cache, | 560 | extent_map_tree_init(&fs_info->free_space_cache, |
542 | fs_info->btree_inode->i_mapping, GFP_NOFS); | 561 | fs_info->btree_inode->i_mapping, GFP_NOFS); |
543 | extent_map_tree_init(&fs_info->block_group_cache, | 562 | extent_map_tree_init(&fs_info->block_group_cache, |
@@ -832,3 +851,7 @@ int btrfs_read_buffer(struct extent_buffer *buf) | |||
832 | return read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree, | 851 | return read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree, |
833 | buf, 0, 1); | 852 | buf, 0, 1); |
834 | } | 853 | } |
854 | |||
855 | static struct extent_map_ops btree_extent_map_ops = { | ||
856 | .writepage_io_hook = btree_writepage_io_hook, | ||
857 | }; | ||