Skip to content

Commit d64dab9

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs fixes from Chris Mason: "We've got more bug fixes in my for-linus branch: One of these fixes another corner of the compression oops from last time. Miao nailed down some problems with concurrent snapshot deletion and drive balancing. I kept out one of his patches for more testing, but these are all stable" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: Btrfs: fix oops caused by the space balance and dead roots Btrfs: insert orphan roots into fs radix tree Btrfs: limit delalloc pages outside of find_delalloc_range Btrfs: use right root when checking for hash collision
2 parents d192f0d + c00869f commit d64dab9

File tree

6 files changed

+25
-21
lines changed

6 files changed

+25
-21
lines changed

fs/btrfs/disk-io.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,8 +1561,9 @@ int btrfs_insert_fs_root(struct btrfs_fs_info *fs_info,
15611561
return ret;
15621562
}
15631563

1564-
struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
1565-
struct btrfs_key *location)
1564+
struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info,
1565+
struct btrfs_key *location,
1566+
bool check_ref)
15661567
{
15671568
struct btrfs_root *root;
15681569
int ret;
@@ -1586,7 +1587,7 @@ struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
15861587
again:
15871588
root = btrfs_lookup_fs_root(fs_info, location->objectid);
15881589
if (root) {
1589-
if (btrfs_root_refs(&root->root_item) == 0)
1590+
if (check_ref && btrfs_root_refs(&root->root_item) == 0)
15901591
return ERR_PTR(-ENOENT);
15911592
return root;
15921593
}
@@ -1595,7 +1596,7 @@ struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
15951596
if (IS_ERR(root))
15961597
return root;
15971598

1598-
if (btrfs_root_refs(&root->root_item) == 0) {
1599+
if (check_ref && btrfs_root_refs(&root->root_item) == 0) {
15991600
ret = -ENOENT;
16001601
goto fail;
16011602
}

fs/btrfs/disk-io.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,17 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root,
6868
int btrfs_init_fs_root(struct btrfs_root *root);
6969
int btrfs_insert_fs_root(struct btrfs_fs_info *fs_info,
7070
struct btrfs_root *root);
71-
struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
72-
struct btrfs_key *location);
71+
72+
struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info,
73+
struct btrfs_key *key,
74+
bool check_ref);
75+
static inline struct btrfs_root *
76+
btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
77+
struct btrfs_key *location)
78+
{
79+
return btrfs_get_fs_root(fs_info, location, true);
80+
}
81+
7382
int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info);
7483
void btrfs_btree_balance_dirty(struct btrfs_root *root);
7584
void btrfs_btree_balance_dirty_nodelay(struct btrfs_root *root);

fs/btrfs/extent_io.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,10 +1490,8 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree,
14901490
cur_start = state->end + 1;
14911491
node = rb_next(node);
14921492
total_bytes += state->end - state->start + 1;
1493-
if (total_bytes >= max_bytes) {
1494-
*end = *start + max_bytes - 1;
1493+
if (total_bytes >= max_bytes)
14951494
break;
1496-
}
14971495
if (!node)
14981496
break;
14991497
}
@@ -1635,10 +1633,9 @@ static noinline u64 find_lock_delalloc_range(struct inode *inode,
16351633

16361634
/*
16371635
* make sure to limit the number of pages we try to lock down
1638-
* if we're looping.
16391636
*/
1640-
if (delalloc_end + 1 - delalloc_start > max_bytes && loops)
1641-
delalloc_end = delalloc_start + PAGE_CACHE_SIZE - 1;
1637+
if (delalloc_end + 1 - delalloc_start > max_bytes)
1638+
delalloc_end = delalloc_start + max_bytes - 1;
16421639

16431640
/* step two, lock all the pages after the page that has start */
16441641
ret = lock_delalloc_pages(inode, locked_page,
@@ -1649,8 +1646,7 @@ static noinline u64 find_lock_delalloc_range(struct inode *inode,
16491646
*/
16501647
free_extent_state(cached_state);
16511648
if (!loops) {
1652-
unsigned long offset = (*start) & (PAGE_CACHE_SIZE - 1);
1653-
max_bytes = PAGE_CACHE_SIZE - offset;
1649+
max_bytes = PAGE_CACHE_SIZE;
16541650
loops = 1;
16551651
goto again;
16561652
} else {

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7986,7 +7986,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
79867986

79877987

79887988
/* check for collisions, even if the name isn't there */
7989-
ret = btrfs_check_dir_item_collision(root, new_dir->i_ino,
7989+
ret = btrfs_check_dir_item_collision(dest, new_dir->i_ino,
79907990
new_dentry->d_name.name,
79917991
new_dentry->d_name.len);
79927992

fs/btrfs/relocation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ static struct btrfs_root *read_fs_root(struct btrfs_fs_info *fs_info,
588588
else
589589
key.offset = (u64)-1;
590590

591-
return btrfs_read_fs_root_no_name(fs_info, &key);
591+
return btrfs_get_fs_root(fs_info, &key, false);
592592
}
593593

594594
#ifdef BTRFS_COMPAT_EXTENT_TREE_V0

fs/btrfs/root-tree.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,6 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root)
299299
continue;
300300
}
301301

302-
if (btrfs_root_refs(&root->root_item) == 0) {
303-
btrfs_add_dead_root(root);
304-
continue;
305-
}
306-
307302
err = btrfs_init_fs_root(root);
308303
if (err) {
309304
btrfs_free_fs_root(root);
@@ -318,6 +313,9 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root)
318313
btrfs_free_fs_root(root);
319314
break;
320315
}
316+
317+
if (btrfs_root_refs(&root->root_item) == 0)
318+
btrfs_add_dead_root(root);
321319
}
322320

323321
btrfs_free_path(path);

0 commit comments

Comments
 (0)