Skip to content

Commit a2648eb

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: "This is an assortment of crash fixes" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: Btrfs: stop all workers before cleaning up roots Btrfs: fix use-after-free bug during umount Btrfs: init relocate extent_io_tree with a mapping btrfs: Drop inode if inode root is NULL Btrfs: don't delete fs_roots until after we cleanup the transaction
2 parents 33c929c + 13e6c37 commit a2648eb

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

fs/btrfs/disk-io.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,8 +2859,8 @@ int open_ctree(struct super_block *sb,
28592859
btrfs_free_qgroup_config(fs_info);
28602860
fail_trans_kthread:
28612861
kthread_stop(fs_info->transaction_kthread);
2862-
del_fs_roots(fs_info);
28632862
btrfs_cleanup_transaction(fs_info->tree_root);
2863+
del_fs_roots(fs_info);
28642864
fail_cleaner:
28652865
kthread_stop(fs_info->cleaner_kthread);
28662866

@@ -3512,15 +3512,15 @@ int close_ctree(struct btrfs_root *root)
35123512
percpu_counter_sum(&fs_info->delalloc_bytes));
35133513
}
35143514

3515-
free_root_pointers(fs_info, 1);
3516-
35173515
btrfs_free_block_groups(fs_info);
35183516

3517+
btrfs_stop_all_workers(fs_info);
3518+
35193519
del_fs_roots(fs_info);
35203520

3521-
iput(fs_info->btree_inode);
3521+
free_root_pointers(fs_info, 1);
35223522

3523-
btrfs_stop_all_workers(fs_info);
3523+
iput(fs_info->btree_inode);
35243524

35253525
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
35263526
if (btrfs_test_opt(root, CHECK_INTEGRITY))

fs/btrfs/inode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8012,6 +8012,9 @@ int btrfs_drop_inode(struct inode *inode)
80128012
{
80138013
struct btrfs_root *root = BTRFS_I(inode)->root;
80148014

8015+
if (root == NULL)
8016+
return 1;
8017+
80158018
/* the snap/subvol tree is on deleting */
80168019
if (btrfs_root_refs(&root->root_item) == 0 &&
80178020
root != root->fs_info->tree_root)

fs/btrfs/relocation.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4082,7 +4082,7 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
40824082
return inode;
40834083
}
40844084

4085-
static struct reloc_control *alloc_reloc_control(void)
4085+
static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info)
40864086
{
40874087
struct reloc_control *rc;
40884088

@@ -4093,7 +4093,8 @@ static struct reloc_control *alloc_reloc_control(void)
40934093
INIT_LIST_HEAD(&rc->reloc_roots);
40944094
backref_cache_init(&rc->backref_cache);
40954095
mapping_tree_init(&rc->reloc_root_tree);
4096-
extent_io_tree_init(&rc->processed_blocks, NULL);
4096+
extent_io_tree_init(&rc->processed_blocks,
4097+
fs_info->btree_inode->i_mapping);
40974098
return rc;
40984099
}
40994100

@@ -4110,7 +4111,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
41104111
int rw = 0;
41114112
int err = 0;
41124113

4113-
rc = alloc_reloc_control();
4114+
rc = alloc_reloc_control(fs_info);
41144115
if (!rc)
41154116
return -ENOMEM;
41164117

@@ -4311,7 +4312,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
43114312
if (list_empty(&reloc_roots))
43124313
goto out;
43134314

4314-
rc = alloc_reloc_control();
4315+
rc = alloc_reloc_control(root->fs_info);
43154316
if (!rc) {
43164317
err = -ENOMEM;
43174318
goto out;

0 commit comments

Comments
 (0)