Skip to content

Commit 0e4e026

Browse files
author
Chris Mason
committed
Merge branch 'for-linus' into raid56-experimental
Conflicts: fs/btrfs/volumes.c Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2 parents 1f0905e + 1eafa6c commit 0e4e026

File tree

14 files changed

+300
-98
lines changed

14 files changed

+300
-98
lines changed

fs/btrfs/extent-tree.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4061,7 +4061,7 @@ static int reserve_metadata_bytes(struct btrfs_root *root,
40614061
* We make the other tasks wait for the flush only when we can flush
40624062
* all things.
40634063
*/
4064-
if (ret && flush == BTRFS_RESERVE_FLUSH_ALL) {
4064+
if (ret && flush != BTRFS_RESERVE_NO_FLUSH) {
40654065
flushing = true;
40664066
space_info->flush = 1;
40674067
}
@@ -5631,7 +5631,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
56315631
int empty_cluster = 2 * 1024 * 1024;
56325632
struct btrfs_space_info *space_info;
56335633
int loop = 0;
5634-
int index = 0;
5634+
int index = __get_raid_index(data);
56355635
int alloc_type = (data & BTRFS_BLOCK_GROUP_DATA) ?
56365636
RESERVE_ALLOC_NO_ACCOUNT : RESERVE_ALLOC;
56375637
bool found_uncached_bg = false;
@@ -6867,11 +6867,13 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans,
68676867
&wc->flags[level]);
68686868
if (ret < 0) {
68696869
btrfs_tree_unlock_rw(eb, path->locks[level]);
6870+
path->locks[level] = 0;
68706871
return ret;
68716872
}
68726873
BUG_ON(wc->refs[level] == 0);
68736874
if (wc->refs[level] == 1) {
68746875
btrfs_tree_unlock_rw(eb, path->locks[level]);
6876+
path->locks[level] = 0;
68756877
return 1;
68766878
}
68776879
}

fs/btrfs/extent_map.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ static int mergable_maps(struct extent_map *prev, struct extent_map *next)
171171
if (test_bit(EXTENT_FLAG_COMPRESSED, &prev->flags))
172172
return 0;
173173

174+
if (test_bit(EXTENT_FLAG_LOGGING, &prev->flags) ||
175+
test_bit(EXTENT_FLAG_LOGGING, &next->flags))
176+
return 0;
177+
174178
if (extent_map_end(prev) == next->start &&
175179
prev->flags == next->flags &&
176180
prev->bdev == next->bdev &&
@@ -256,7 +260,8 @@ int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
256260
if (!em)
257261
goto out;
258262

259-
list_move(&em->list, &tree->modified_extents);
263+
if (!test_bit(EXTENT_FLAG_LOGGING, &em->flags))
264+
list_move(&em->list, &tree->modified_extents);
260265
em->generation = gen;
261266
clear_bit(EXTENT_FLAG_PINNED, &em->flags);
262267
em->mod_start = em->start;
@@ -281,6 +286,12 @@ int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
281286

282287
}
283288

289+
void clear_em_logging(struct extent_map_tree *tree, struct extent_map *em)
290+
{
291+
clear_bit(EXTENT_FLAG_LOGGING, &em->flags);
292+
try_merge_map(tree, em);
293+
}
294+
284295
/**
285296
* add_extent_mapping - add new extent map to the extent tree
286297
* @tree: tree to insert new map in

fs/btrfs/extent_map.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ void free_extent_map(struct extent_map *em);
6969
int __init extent_map_init(void);
7070
void extent_map_exit(void);
7171
int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len, u64 gen);
72+
void clear_em_logging(struct extent_map_tree *tree, struct extent_map *em);
7273
struct extent_map *search_extent_mapping(struct extent_map_tree *tree,
7374
u64 start, u64 len);
7475
#endif

fs/btrfs/file-item.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode,
460460
if (!contig)
461461
offset = page_offset(bvec->bv_page) + bvec->bv_offset;
462462

463-
if (!contig && (offset >= ordered->file_offset + ordered->len ||
464-
offset < ordered->file_offset)) {
463+
if (offset >= ordered->file_offset + ordered->len ||
464+
offset < ordered->file_offset) {
465465
unsigned long bytes_left;
466466
sums->len = this_sum_bytes;
467467
this_sum_bytes = 0;

fs/btrfs/file.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
22422242
if (lockend <= lockstart)
22432243
lockend = lockstart + root->sectorsize;
22442244

2245+
lockend--;
22452246
len = lockend - lockstart + 1;
22462247

22472248
len = max_t(u64, len, root->sectorsize);
@@ -2308,9 +2309,12 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
23082309
}
23092310
}
23102311

2311-
*offset = start;
2312-
free_extent_map(em);
2313-
break;
2312+
if (!test_bit(EXTENT_FLAG_PREALLOC,
2313+
&em->flags)) {
2314+
*offset = start;
2315+
free_extent_map(em);
2316+
break;
2317+
}
23142318
}
23152319
}
23162320

fs/btrfs/free-space-cache.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,11 +1885,13 @@ int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,
18851885
{
18861886
struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
18871887
struct btrfs_free_space *info;
1888-
int ret = 0;
1888+
int ret;
1889+
bool re_search = false;
18891890

18901891
spin_lock(&ctl->tree_lock);
18911892

18921893
again:
1894+
ret = 0;
18931895
if (!bytes)
18941896
goto out_lock;
18951897

@@ -1902,17 +1904,17 @@ int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,
19021904
info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset),
19031905
1, 0);
19041906
if (!info) {
1905-
/* the tree logging code might be calling us before we
1906-
* have fully loaded the free space rbtree for this
1907-
* block group. So it is possible the entry won't
1908-
* be in the rbtree yet at all. The caching code
1909-
* will make sure not to put it in the rbtree if
1910-
* the logging code has pinned it.
1907+
/*
1908+
* If we found a partial bit of our free space in a
1909+
* bitmap but then couldn't find the other part this may
1910+
* be a problem, so WARN about it.
19111911
*/
1912+
WARN_ON(re_search);
19121913
goto out_lock;
19131914
}
19141915
}
19151916

1917+
re_search = false;
19161918
if (!info->bitmap) {
19171919
unlink_free_space(ctl, info);
19181920
if (offset == info->offset) {
@@ -1958,8 +1960,10 @@ int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,
19581960
}
19591961

19601962
ret = remove_from_bitmap(ctl, info, &offset, &bytes);
1961-
if (ret == -EAGAIN)
1963+
if (ret == -EAGAIN) {
1964+
re_search = true;
19621965
goto again;
1966+
}
19631967
BUG_ON(ret); /* logic error */
19641968
out_lock:
19651969
spin_unlock(&ctl->tree_lock);

0 commit comments

Comments
 (0)