aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/extent-tree.c16
-rw-r--r--fs/btrfs/inode.c39
2 files changed, 11 insertions, 44 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d6243c2afc73..91c2b27d9689 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -688,7 +688,7 @@ u32 btrfs_count_snapshots_in_path(struct btrfs_root *root,
688 struct btrfs_path *path; 688 struct btrfs_path *path;
689 u64 bytenr; 689 u64 bytenr;
690 u64 found_objectid; 690 u64 found_objectid;
691 u64 root_objectid = 0; 691 u64 root_objectid = root->root_key.objectid;
692 u32 total_count = 0; 692 u32 total_count = 0;
693 u32 cur_count; 693 u32 cur_count;
694 u32 refs; 694 u32 refs;
@@ -749,15 +749,11 @@ again:
749 struct btrfs_extent_ref); 749 struct btrfs_extent_ref);
750 found_objectid = btrfs_ref_root(l, ref_item); 750 found_objectid = btrfs_ref_root(l, ref_item);
751 751
752 if (found_objectid != root_objectid) 752 if (found_objectid != root_objectid) {
753 total_count++; 753 total_count = 2;
754 754 break;
755 if (total_count > 1) 755 }
756 goto out; 756 total_count = 1;
757
758 if (root_objectid == 0)
759 root_objectid = found_objectid;
760
761 path->slots[0]++; 757 path->slots[0]++;
762 } 758 }
763 if (cur_count == 0) { 759 if (cur_count == 0) {
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d6de46961887..5003a86510a1 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1770,6 +1770,11 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
1770again: 1770again:
1771 em = lookup_extent_mapping(em_tree, start, end); 1771 em = lookup_extent_mapping(em_tree, start, end);
1772 if (em) { 1772 if (em) {
1773 if (em->start > start) {
1774 printk("get_extent start %Lu em start %Lu\n",
1775 start, em->start);
1776 WARN_ON(1);
1777 }
1773 goto out; 1778 goto out;
1774 } 1779 }
1775 if (!em) { 1780 if (!em) {
@@ -1952,23 +1957,6 @@ static sector_t btrfs_bmap(struct address_space *mapping, sector_t iblock)
1952 return extent_bmap(mapping, iblock, btrfs_get_extent); 1957 return extent_bmap(mapping, iblock, btrfs_get_extent);
1953} 1958}
1954 1959
1955static int btrfs_prepare_write(struct file *file, struct page *page,
1956 unsigned from, unsigned to)
1957{
1958 struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
1959 int err;
1960
1961 mutex_lock(&root->fs_info->fs_mutex);
1962 err = btrfs_check_free_space(root, PAGE_CACHE_SIZE, 0);
1963 mutex_unlock(&root->fs_info->fs_mutex);
1964 if (err)
1965 return -ENOSPC;
1966
1967 return extent_prepare_write(&BTRFS_I(page->mapping->host)->extent_tree,
1968 page->mapping->host, page, from, to,
1969 btrfs_get_extent);
1970}
1971
1972int btrfs_readpage(struct file *file, struct page *page) 1960int btrfs_readpage(struct file *file, struct page *page)
1973{ 1961{
1974 struct extent_map_tree *tree; 1962 struct extent_map_tree *tree;
@@ -2120,21 +2108,6 @@ static void btrfs_truncate(struct inode *inode)
2120 btrfs_btree_balance_dirty(root, nr); 2108 btrfs_btree_balance_dirty(root, nr);
2121} 2109}
2122 2110
2123int btrfs_commit_write(struct file *file, struct page *page,
2124 unsigned from, unsigned to)
2125{
2126 loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
2127 struct inode *inode = page->mapping->host;
2128
2129 btrfs_cow_one_page(inode, page, PAGE_CACHE_SIZE);
2130
2131 if (pos > inode->i_size) {
2132 i_size_write(inode, pos);
2133 mark_inode_dirty(inode);
2134 }
2135 return 0;
2136}
2137
2138static int create_subvol(struct btrfs_root *root, char *name, int namelen) 2111static int create_subvol(struct btrfs_root *root, char *name, int namelen)
2139{ 2112{
2140 struct btrfs_trans_handle *trans; 2113 struct btrfs_trans_handle *trans;
@@ -2930,8 +2903,6 @@ static struct address_space_operations btrfs_aops = {
2930 .writepages = btrfs_writepages, 2903 .writepages = btrfs_writepages,
2931 .readpages = btrfs_readpages, 2904 .readpages = btrfs_readpages,
2932 .sync_page = block_sync_page, 2905 .sync_page = block_sync_page,
2933 .prepare_write = btrfs_prepare_write,
2934 .commit_write = btrfs_commit_write,
2935 .bmap = btrfs_bmap, 2906 .bmap = btrfs_bmap,
2936 .invalidatepage = btrfs_invalidatepage, 2907 .invalidatepage = btrfs_invalidatepage,
2937 .releasepage = btrfs_releasepage, 2908 .releasepage = btrfs_releasepage,