diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-10-09 19:39:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-10-09 19:39:35 -0400 |
commit | 175d58cfed70f132b8d4df39e19267ad6094bd16 (patch) | |
tree | 9eca7048d9d81c0be1f23dfd558a3959ae4d5521 | |
parent | 38aa0a59a6669af702c523e1d525b24ff5fd471b (diff) | |
parent | 7d35199e15b82a4d1a20049153b03e6258ce79f7 (diff) |
Merge branch 'for-linus-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs fixes from Chris Mason:
"These are small and assorted. Neil's is the oldest, I dropped the
ball thinking he was going to send it in"
* 'for-linus-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: support NFSv2 export
Btrfs: open_ctree: Fix possible memory leak
Btrfs: fix deadlock when finalizing block group creation
Btrfs: update fix for read corruption of compressed and shared extents
Btrfs: send, fix corner case for reference overwrite detection
-rw-r--r-- | fs/btrfs/disk-io.c | 4 | ||||
-rw-r--r-- | fs/btrfs/export.c | 10 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 9 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 19 | ||||
-rw-r--r-- | fs/btrfs/send.c | 8 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 1 | ||||
-rw-r--r-- | fs/btrfs/transaction.h | 1 |
7 files changed, 35 insertions, 17 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 295795aebe0b..1e60d00d4ea7 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -2847,6 +2847,8 @@ int open_ctree(struct super_block *sb, | |||
2847 | !extent_buffer_uptodate(chunk_root->node)) { | 2847 | !extent_buffer_uptodate(chunk_root->node)) { |
2848 | printk(KERN_ERR "BTRFS: failed to read chunk root on %s\n", | 2848 | printk(KERN_ERR "BTRFS: failed to read chunk root on %s\n", |
2849 | sb->s_id); | 2849 | sb->s_id); |
2850 | if (!IS_ERR(chunk_root->node)) | ||
2851 | free_extent_buffer(chunk_root->node); | ||
2850 | chunk_root->node = NULL; | 2852 | chunk_root->node = NULL; |
2851 | goto fail_tree_roots; | 2853 | goto fail_tree_roots; |
2852 | } | 2854 | } |
@@ -2885,6 +2887,8 @@ retry_root_backup: | |||
2885 | !extent_buffer_uptodate(tree_root->node)) { | 2887 | !extent_buffer_uptodate(tree_root->node)) { |
2886 | printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n", | 2888 | printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n", |
2887 | sb->s_id); | 2889 | sb->s_id); |
2890 | if (!IS_ERR(tree_root->node)) | ||
2891 | free_extent_buffer(tree_root->node); | ||
2888 | tree_root->node = NULL; | 2892 | tree_root->node = NULL; |
2889 | goto recovery_tree_root; | 2893 | goto recovery_tree_root; |
2890 | } | 2894 | } |
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c index 8d052209f473..2513a7f53334 100644 --- a/fs/btrfs/export.c +++ b/fs/btrfs/export.c | |||
@@ -112,11 +112,11 @@ static struct dentry *btrfs_fh_to_parent(struct super_block *sb, struct fid *fh, | |||
112 | u32 generation; | 112 | u32 generation; |
113 | 113 | ||
114 | if (fh_type == FILEID_BTRFS_WITH_PARENT) { | 114 | if (fh_type == FILEID_BTRFS_WITH_PARENT) { |
115 | if (fh_len != BTRFS_FID_SIZE_CONNECTABLE) | 115 | if (fh_len < BTRFS_FID_SIZE_CONNECTABLE) |
116 | return NULL; | 116 | return NULL; |
117 | root_objectid = fid->root_objectid; | 117 | root_objectid = fid->root_objectid; |
118 | } else if (fh_type == FILEID_BTRFS_WITH_PARENT_ROOT) { | 118 | } else if (fh_type == FILEID_BTRFS_WITH_PARENT_ROOT) { |
119 | if (fh_len != BTRFS_FID_SIZE_CONNECTABLE_ROOT) | 119 | if (fh_len < BTRFS_FID_SIZE_CONNECTABLE_ROOT) |
120 | return NULL; | 120 | return NULL; |
121 | root_objectid = fid->parent_root_objectid; | 121 | root_objectid = fid->parent_root_objectid; |
122 | } else | 122 | } else |
@@ -136,11 +136,11 @@ static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh, | |||
136 | u32 generation; | 136 | u32 generation; |
137 | 137 | ||
138 | if ((fh_type != FILEID_BTRFS_WITH_PARENT || | 138 | if ((fh_type != FILEID_BTRFS_WITH_PARENT || |
139 | fh_len != BTRFS_FID_SIZE_CONNECTABLE) && | 139 | fh_len < BTRFS_FID_SIZE_CONNECTABLE) && |
140 | (fh_type != FILEID_BTRFS_WITH_PARENT_ROOT || | 140 | (fh_type != FILEID_BTRFS_WITH_PARENT_ROOT || |
141 | fh_len != BTRFS_FID_SIZE_CONNECTABLE_ROOT) && | 141 | fh_len < BTRFS_FID_SIZE_CONNECTABLE_ROOT) && |
142 | (fh_type != FILEID_BTRFS_WITHOUT_PARENT || | 142 | (fh_type != FILEID_BTRFS_WITHOUT_PARENT || |
143 | fh_len != BTRFS_FID_SIZE_NON_CONNECTABLE)) | 143 | fh_len < BTRFS_FID_SIZE_NON_CONNECTABLE)) |
144 | return NULL; | 144 | return NULL; |
145 | 145 | ||
146 | objectid = fid->objectid; | 146 | objectid = fid->objectid; |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 9f9604201333..601d7d45d164 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -2828,6 +2828,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, | |||
2828 | struct btrfs_delayed_ref_head *head; | 2828 | struct btrfs_delayed_ref_head *head; |
2829 | int ret; | 2829 | int ret; |
2830 | int run_all = count == (unsigned long)-1; | 2830 | int run_all = count == (unsigned long)-1; |
2831 | bool can_flush_pending_bgs = trans->can_flush_pending_bgs; | ||
2831 | 2832 | ||
2832 | /* We'll clean this up in btrfs_cleanup_transaction */ | 2833 | /* We'll clean this up in btrfs_cleanup_transaction */ |
2833 | if (trans->aborted) | 2834 | if (trans->aborted) |
@@ -2844,6 +2845,7 @@ again: | |||
2844 | #ifdef SCRAMBLE_DELAYED_REFS | 2845 | #ifdef SCRAMBLE_DELAYED_REFS |
2845 | delayed_refs->run_delayed_start = find_middle(&delayed_refs->root); | 2846 | delayed_refs->run_delayed_start = find_middle(&delayed_refs->root); |
2846 | #endif | 2847 | #endif |
2848 | trans->can_flush_pending_bgs = false; | ||
2847 | ret = __btrfs_run_delayed_refs(trans, root, count); | 2849 | ret = __btrfs_run_delayed_refs(trans, root, count); |
2848 | if (ret < 0) { | 2850 | if (ret < 0) { |
2849 | btrfs_abort_transaction(trans, root, ret); | 2851 | btrfs_abort_transaction(trans, root, ret); |
@@ -2893,6 +2895,7 @@ again: | |||
2893 | } | 2895 | } |
2894 | out: | 2896 | out: |
2895 | assert_qgroups_uptodate(trans); | 2897 | assert_qgroups_uptodate(trans); |
2898 | trans->can_flush_pending_bgs = can_flush_pending_bgs; | ||
2896 | return 0; | 2899 | return 0; |
2897 | } | 2900 | } |
2898 | 2901 | ||
@@ -4306,7 +4309,8 @@ out: | |||
4306 | * the block groups that were made dirty during the lifetime of the | 4309 | * the block groups that were made dirty during the lifetime of the |
4307 | * transaction. | 4310 | * transaction. |
4308 | */ | 4311 | */ |
4309 | if (trans->chunk_bytes_reserved >= (2 * 1024 * 1024ull)) { | 4312 | if (trans->can_flush_pending_bgs && |
4313 | trans->chunk_bytes_reserved >= (2 * 1024 * 1024ull)) { | ||
4310 | btrfs_create_pending_block_groups(trans, trans->root); | 4314 | btrfs_create_pending_block_groups(trans, trans->root); |
4311 | btrfs_trans_release_chunk_metadata(trans); | 4315 | btrfs_trans_release_chunk_metadata(trans); |
4312 | } | 4316 | } |
@@ -9560,7 +9564,9 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans, | |||
9560 | struct btrfs_block_group_item item; | 9564 | struct btrfs_block_group_item item; |
9561 | struct btrfs_key key; | 9565 | struct btrfs_key key; |
9562 | int ret = 0; | 9566 | int ret = 0; |
9567 | bool can_flush_pending_bgs = trans->can_flush_pending_bgs; | ||
9563 | 9568 | ||
9569 | trans->can_flush_pending_bgs = false; | ||
9564 | list_for_each_entry_safe(block_group, tmp, &trans->new_bgs, bg_list) { | 9570 | list_for_each_entry_safe(block_group, tmp, &trans->new_bgs, bg_list) { |
9565 | if (ret) | 9571 | if (ret) |
9566 | goto next; | 9572 | goto next; |
@@ -9581,6 +9587,7 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans, | |||
9581 | next: | 9587 | next: |
9582 | list_del_init(&block_group->bg_list); | 9588 | list_del_init(&block_group->bg_list); |
9583 | } | 9589 | } |
9590 | trans->can_flush_pending_bgs = can_flush_pending_bgs; | ||
9584 | } | 9591 | } |
9585 | 9592 | ||
9586 | int btrfs_make_block_group(struct btrfs_trans_handle *trans, | 9593 | int btrfs_make_block_group(struct btrfs_trans_handle *trans, |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index e2357e31609a..3915c9473e94 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -3132,12 +3132,12 @@ static inline void __do_contiguous_readpages(struct extent_io_tree *tree, | |||
3132 | get_extent_t *get_extent, | 3132 | get_extent_t *get_extent, |
3133 | struct extent_map **em_cached, | 3133 | struct extent_map **em_cached, |
3134 | struct bio **bio, int mirror_num, | 3134 | struct bio **bio, int mirror_num, |
3135 | unsigned long *bio_flags, int rw) | 3135 | unsigned long *bio_flags, int rw, |
3136 | u64 *prev_em_start) | ||
3136 | { | 3137 | { |
3137 | struct inode *inode; | 3138 | struct inode *inode; |
3138 | struct btrfs_ordered_extent *ordered; | 3139 | struct btrfs_ordered_extent *ordered; |
3139 | int index; | 3140 | int index; |
3140 | u64 prev_em_start = (u64)-1; | ||
3141 | 3141 | ||
3142 | inode = pages[0]->mapping->host; | 3142 | inode = pages[0]->mapping->host; |
3143 | while (1) { | 3143 | while (1) { |
@@ -3153,7 +3153,7 @@ static inline void __do_contiguous_readpages(struct extent_io_tree *tree, | |||
3153 | 3153 | ||
3154 | for (index = 0; index < nr_pages; index++) { | 3154 | for (index = 0; index < nr_pages; index++) { |
3155 | __do_readpage(tree, pages[index], get_extent, em_cached, bio, | 3155 | __do_readpage(tree, pages[index], get_extent, em_cached, bio, |
3156 | mirror_num, bio_flags, rw, &prev_em_start); | 3156 | mirror_num, bio_flags, rw, prev_em_start); |
3157 | page_cache_release(pages[index]); | 3157 | page_cache_release(pages[index]); |
3158 | } | 3158 | } |
3159 | } | 3159 | } |
@@ -3163,7 +3163,8 @@ static void __extent_readpages(struct extent_io_tree *tree, | |||
3163 | int nr_pages, get_extent_t *get_extent, | 3163 | int nr_pages, get_extent_t *get_extent, |
3164 | struct extent_map **em_cached, | 3164 | struct extent_map **em_cached, |
3165 | struct bio **bio, int mirror_num, | 3165 | struct bio **bio, int mirror_num, |
3166 | unsigned long *bio_flags, int rw) | 3166 | unsigned long *bio_flags, int rw, |
3167 | u64 *prev_em_start) | ||
3167 | { | 3168 | { |
3168 | u64 start = 0; | 3169 | u64 start = 0; |
3169 | u64 end = 0; | 3170 | u64 end = 0; |
@@ -3184,7 +3185,7 @@ static void __extent_readpages(struct extent_io_tree *tree, | |||
3184 | index - first_index, start, | 3185 | index - first_index, start, |
3185 | end, get_extent, em_cached, | 3186 | end, get_extent, em_cached, |
3186 | bio, mirror_num, bio_flags, | 3187 | bio, mirror_num, bio_flags, |
3187 | rw); | 3188 | rw, prev_em_start); |
3188 | start = page_start; | 3189 | start = page_start; |
3189 | end = start + PAGE_CACHE_SIZE - 1; | 3190 | end = start + PAGE_CACHE_SIZE - 1; |
3190 | first_index = index; | 3191 | first_index = index; |
@@ -3195,7 +3196,8 @@ static void __extent_readpages(struct extent_io_tree *tree, | |||
3195 | __do_contiguous_readpages(tree, &pages[first_index], | 3196 | __do_contiguous_readpages(tree, &pages[first_index], |
3196 | index - first_index, start, | 3197 | index - first_index, start, |
3197 | end, get_extent, em_cached, bio, | 3198 | end, get_extent, em_cached, bio, |
3198 | mirror_num, bio_flags, rw); | 3199 | mirror_num, bio_flags, rw, |
3200 | prev_em_start); | ||
3199 | } | 3201 | } |
3200 | 3202 | ||
3201 | static int __extent_read_full_page(struct extent_io_tree *tree, | 3203 | static int __extent_read_full_page(struct extent_io_tree *tree, |
@@ -4207,6 +4209,7 @@ int extent_readpages(struct extent_io_tree *tree, | |||
4207 | struct page *page; | 4209 | struct page *page; |
4208 | struct extent_map *em_cached = NULL; | 4210 | struct extent_map *em_cached = NULL; |
4209 | int nr = 0; | 4211 | int nr = 0; |
4212 | u64 prev_em_start = (u64)-1; | ||
4210 | 4213 | ||
4211 | for (page_idx = 0; page_idx < nr_pages; page_idx++) { | 4214 | for (page_idx = 0; page_idx < nr_pages; page_idx++) { |
4212 | page = list_entry(pages->prev, struct page, lru); | 4215 | page = list_entry(pages->prev, struct page, lru); |
@@ -4223,12 +4226,12 @@ int extent_readpages(struct extent_io_tree *tree, | |||
4223 | if (nr < ARRAY_SIZE(pagepool)) | 4226 | if (nr < ARRAY_SIZE(pagepool)) |
4224 | continue; | 4227 | continue; |
4225 | __extent_readpages(tree, pagepool, nr, get_extent, &em_cached, | 4228 | __extent_readpages(tree, pagepool, nr, get_extent, &em_cached, |
4226 | &bio, 0, &bio_flags, READ); | 4229 | &bio, 0, &bio_flags, READ, &prev_em_start); |
4227 | nr = 0; | 4230 | nr = 0; |
4228 | } | 4231 | } |
4229 | if (nr) | 4232 | if (nr) |
4230 | __extent_readpages(tree, pagepool, nr, get_extent, &em_cached, | 4233 | __extent_readpages(tree, pagepool, nr, get_extent, &em_cached, |
4231 | &bio, 0, &bio_flags, READ); | 4234 | &bio, 0, &bio_flags, READ, &prev_em_start); |
4232 | 4235 | ||
4233 | if (em_cached) | 4236 | if (em_cached) |
4234 | free_extent_map(em_cached); | 4237 | free_extent_map(em_cached); |
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index aa72bfd28f7d..a739b825bdd3 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c | |||
@@ -1920,10 +1920,12 @@ static int did_overwrite_ref(struct send_ctx *sctx, | |||
1920 | /* | 1920 | /* |
1921 | * We know that it is or will be overwritten. Check this now. | 1921 | * We know that it is or will be overwritten. Check this now. |
1922 | * The current inode being processed might have been the one that caused | 1922 | * The current inode being processed might have been the one that caused |
1923 | * inode 'ino' to be orphanized, therefore ow_inode can actually be the | 1923 | * inode 'ino' to be orphanized, therefore check if ow_inode matches |
1924 | * same as sctx->send_progress. | 1924 | * the current inode being processed. |
1925 | */ | 1925 | */ |
1926 | if (ow_inode <= sctx->send_progress) | 1926 | if ((ow_inode < sctx->send_progress) || |
1927 | (ino != sctx->cur_ino && ow_inode == sctx->cur_ino && | ||
1928 | gen == sctx->cur_inode_gen)) | ||
1927 | ret = 1; | 1929 | ret = 1; |
1928 | else | 1930 | else |
1929 | ret = 0; | 1931 | ret = 0; |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 74bc3338418b..a5b06442f0bf 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -557,6 +557,7 @@ again: | |||
557 | h->delayed_ref_elem.seq = 0; | 557 | h->delayed_ref_elem.seq = 0; |
558 | h->type = type; | 558 | h->type = type; |
559 | h->allocating_chunk = false; | 559 | h->allocating_chunk = false; |
560 | h->can_flush_pending_bgs = true; | ||
560 | h->reloc_reserved = false; | 561 | h->reloc_reserved = false; |
561 | h->sync = false; | 562 | h->sync = false; |
562 | INIT_LIST_HEAD(&h->qgroup_ref_list); | 563 | INIT_LIST_HEAD(&h->qgroup_ref_list); |
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 87964bf8892d..a994bb097ee5 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h | |||
@@ -118,6 +118,7 @@ struct btrfs_trans_handle { | |||
118 | short aborted; | 118 | short aborted; |
119 | short adding_csums; | 119 | short adding_csums; |
120 | bool allocating_chunk; | 120 | bool allocating_chunk; |
121 | bool can_flush_pending_bgs; | ||
121 | bool reloc_reserved; | 122 | bool reloc_reserved; |
122 | bool sync; | 123 | bool sync; |
123 | unsigned int type; | 124 | unsigned int type; |