diff options
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 02369a3c162e..6d19a0a554aa 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -62,7 +62,7 @@ static void btrfs_destroy_ordered_operations(struct btrfs_transaction *t, | |||
62 | static void btrfs_destroy_ordered_extents(struct btrfs_root *root); | 62 | static void btrfs_destroy_ordered_extents(struct btrfs_root *root); |
63 | static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, | 63 | static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, |
64 | struct btrfs_root *root); | 64 | struct btrfs_root *root); |
65 | static void btrfs_destroy_pending_snapshots(struct btrfs_transaction *t); | 65 | static void btrfs_evict_pending_snapshots(struct btrfs_transaction *t); |
66 | static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root); | 66 | static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root); |
67 | static int btrfs_destroy_marked_extents(struct btrfs_root *root, | 67 | static int btrfs_destroy_marked_extents(struct btrfs_root *root, |
68 | struct extent_io_tree *dirty_pages, | 68 | struct extent_io_tree *dirty_pages, |
@@ -1291,6 +1291,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, | |||
1291 | 0, objectid, NULL, 0, 0, 0); | 1291 | 0, objectid, NULL, 0, 0, 0); |
1292 | if (IS_ERR(leaf)) { | 1292 | if (IS_ERR(leaf)) { |
1293 | ret = PTR_ERR(leaf); | 1293 | ret = PTR_ERR(leaf); |
1294 | leaf = NULL; | ||
1294 | goto fail; | 1295 | goto fail; |
1295 | } | 1296 | } |
1296 | 1297 | ||
@@ -1334,11 +1335,16 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, | |||
1334 | 1335 | ||
1335 | btrfs_tree_unlock(leaf); | 1336 | btrfs_tree_unlock(leaf); |
1336 | 1337 | ||
1338 | return root; | ||
1339 | |||
1337 | fail: | 1340 | fail: |
1338 | if (ret) | 1341 | if (leaf) { |
1339 | return ERR_PTR(ret); | 1342 | btrfs_tree_unlock(leaf); |
1343 | free_extent_buffer(leaf); | ||
1344 | } | ||
1345 | kfree(root); | ||
1340 | 1346 | ||
1341 | return root; | 1347 | return ERR_PTR(ret); |
1342 | } | 1348 | } |
1343 | 1349 | ||
1344 | static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, | 1350 | static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, |
@@ -3253,7 +3259,7 @@ void btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root) | |||
3253 | if (btrfs_root_refs(&root->root_item) == 0) | 3259 | if (btrfs_root_refs(&root->root_item) == 0) |
3254 | synchronize_srcu(&fs_info->subvol_srcu); | 3260 | synchronize_srcu(&fs_info->subvol_srcu); |
3255 | 3261 | ||
3256 | if (fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) { | 3262 | if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) { |
3257 | btrfs_free_log(NULL, root); | 3263 | btrfs_free_log(NULL, root); |
3258 | btrfs_free_log_root_tree(NULL, fs_info); | 3264 | btrfs_free_log_root_tree(NULL, fs_info); |
3259 | } | 3265 | } |
@@ -3687,7 +3693,7 @@ int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, | |||
3687 | return ret; | 3693 | return ret; |
3688 | } | 3694 | } |
3689 | 3695 | ||
3690 | static void btrfs_destroy_pending_snapshots(struct btrfs_transaction *t) | 3696 | static void btrfs_evict_pending_snapshots(struct btrfs_transaction *t) |
3691 | { | 3697 | { |
3692 | struct btrfs_pending_snapshot *snapshot; | 3698 | struct btrfs_pending_snapshot *snapshot; |
3693 | struct list_head splice; | 3699 | struct list_head splice; |
@@ -3700,10 +3706,8 @@ static void btrfs_destroy_pending_snapshots(struct btrfs_transaction *t) | |||
3700 | snapshot = list_entry(splice.next, | 3706 | snapshot = list_entry(splice.next, |
3701 | struct btrfs_pending_snapshot, | 3707 | struct btrfs_pending_snapshot, |
3702 | list); | 3708 | list); |
3703 | 3709 | snapshot->error = -ECANCELED; | |
3704 | list_del_init(&snapshot->list); | 3710 | list_del_init(&snapshot->list); |
3705 | |||
3706 | kfree(snapshot); | ||
3707 | } | 3711 | } |
3708 | } | 3712 | } |
3709 | 3713 | ||
@@ -3840,6 +3844,8 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans, | |||
3840 | cur_trans->blocked = 1; | 3844 | cur_trans->blocked = 1; |
3841 | wake_up(&root->fs_info->transaction_blocked_wait); | 3845 | wake_up(&root->fs_info->transaction_blocked_wait); |
3842 | 3846 | ||
3847 | btrfs_evict_pending_snapshots(cur_trans); | ||
3848 | |||
3843 | cur_trans->blocked = 0; | 3849 | cur_trans->blocked = 0; |
3844 | wake_up(&root->fs_info->transaction_wait); | 3850 | wake_up(&root->fs_info->transaction_wait); |
3845 | 3851 | ||
@@ -3849,8 +3855,6 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans, | |||
3849 | btrfs_destroy_delayed_inodes(root); | 3855 | btrfs_destroy_delayed_inodes(root); |
3850 | btrfs_assert_delayed_root_empty(root); | 3856 | btrfs_assert_delayed_root_empty(root); |
3851 | 3857 | ||
3852 | btrfs_destroy_pending_snapshots(cur_trans); | ||
3853 | |||
3854 | btrfs_destroy_marked_extents(root, &cur_trans->dirty_pages, | 3858 | btrfs_destroy_marked_extents(root, &cur_trans->dirty_pages, |
3855 | EXTENT_DIRTY); | 3859 | EXTENT_DIRTY); |
3856 | btrfs_destroy_pinned_extent(root, | 3860 | btrfs_destroy_pinned_extent(root, |
@@ -3894,6 +3898,8 @@ int btrfs_cleanup_transaction(struct btrfs_root *root) | |||
3894 | if (waitqueue_active(&root->fs_info->transaction_blocked_wait)) | 3898 | if (waitqueue_active(&root->fs_info->transaction_blocked_wait)) |
3895 | wake_up(&root->fs_info->transaction_blocked_wait); | 3899 | wake_up(&root->fs_info->transaction_blocked_wait); |
3896 | 3900 | ||
3901 | btrfs_evict_pending_snapshots(t); | ||
3902 | |||
3897 | t->blocked = 0; | 3903 | t->blocked = 0; |
3898 | smp_mb(); | 3904 | smp_mb(); |
3899 | if (waitqueue_active(&root->fs_info->transaction_wait)) | 3905 | if (waitqueue_active(&root->fs_info->transaction_wait)) |
@@ -3907,8 +3913,6 @@ int btrfs_cleanup_transaction(struct btrfs_root *root) | |||
3907 | btrfs_destroy_delayed_inodes(root); | 3913 | btrfs_destroy_delayed_inodes(root); |
3908 | btrfs_assert_delayed_root_empty(root); | 3914 | btrfs_assert_delayed_root_empty(root); |
3909 | 3915 | ||
3910 | btrfs_destroy_pending_snapshots(t); | ||
3911 | |||
3912 | btrfs_destroy_delalloc_inodes(root); | 3916 | btrfs_destroy_delalloc_inodes(root); |
3913 | 3917 | ||
3914 | spin_lock(&root->fs_info->trans_lock); | 3918 | spin_lock(&root->fs_info->trans_lock); |