diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/backref.c | 3 | ||||
-rw-r--r-- | fs/btrfs/ctree.c | 4 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 8 | ||||
-rw-r--r-- | fs/btrfs/delayed-ref.h | 1 | ||||
-rw-r--r-- | fs/btrfs/dev-replace.c | 5 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 50 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 94 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 89 | ||||
-rw-r--r-- | fs/btrfs/free-space-cache.c | 43 | ||||
-rw-r--r-- | fs/btrfs/free-space-cache.h | 2 | ||||
-rw-r--r-- | fs/btrfs/inode-map.c | 8 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 17 | ||||
-rw-r--r-- | fs/btrfs/ioctl.c | 10 | ||||
-rw-r--r-- | fs/btrfs/relocation.c | 7 | ||||
-rw-r--r-- | fs/btrfs/super.c | 1 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 13 |
16 files changed, 181 insertions, 174 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index b4fb41558111..290e347b6db3 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -918,7 +918,8 @@ again: | |||
918 | ref->parent, bsz, 0); | 918 | ref->parent, bsz, 0); |
919 | if (!eb || !extent_buffer_uptodate(eb)) { | 919 | if (!eb || !extent_buffer_uptodate(eb)) { |
920 | free_extent_buffer(eb); | 920 | free_extent_buffer(eb); |
921 | return -EIO; | 921 | ret = -EIO; |
922 | goto out; | ||
922 | } | 923 | } |
923 | ret = find_extent_in_eb(eb, bytenr, | 924 | ret = find_extent_in_eb(eb, bytenr, |
924 | *extent_item_pos, &eie); | 925 | *extent_item_pos, &eie); |
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index de6de8e60b46..02fae7f7e42c 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -951,10 +951,12 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, | |||
951 | BUG_ON(ret); /* -ENOMEM */ | 951 | BUG_ON(ret); /* -ENOMEM */ |
952 | } | 952 | } |
953 | if (new_flags != 0) { | 953 | if (new_flags != 0) { |
954 | int level = btrfs_header_level(buf); | ||
955 | |||
954 | ret = btrfs_set_disk_extent_flags(trans, root, | 956 | ret = btrfs_set_disk_extent_flags(trans, root, |
955 | buf->start, | 957 | buf->start, |
956 | buf->len, | 958 | buf->len, |
957 | new_flags, 0); | 959 | new_flags, level, 0); |
958 | if (ret) | 960 | if (ret) |
959 | return ret; | 961 | return ret; |
960 | } | 962 | } |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 63c328a9ce95..d6dd49b51ba8 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -88,12 +88,12 @@ struct btrfs_ordered_sum; | |||
88 | /* holds checksums of all the data extents */ | 88 | /* holds checksums of all the data extents */ |
89 | #define BTRFS_CSUM_TREE_OBJECTID 7ULL | 89 | #define BTRFS_CSUM_TREE_OBJECTID 7ULL |
90 | 90 | ||
91 | /* for storing balance parameters in the root tree */ | ||
92 | #define BTRFS_BALANCE_OBJECTID -4ULL | ||
93 | |||
94 | /* holds quota configuration and tracking */ | 91 | /* holds quota configuration and tracking */ |
95 | #define BTRFS_QUOTA_TREE_OBJECTID 8ULL | 92 | #define BTRFS_QUOTA_TREE_OBJECTID 8ULL |
96 | 93 | ||
94 | /* for storing balance parameters in the root tree */ | ||
95 | #define BTRFS_BALANCE_OBJECTID -4ULL | ||
96 | |||
97 | /* orhpan objectid for tracking unlinked/truncated files */ | 97 | /* orhpan objectid for tracking unlinked/truncated files */ |
98 | #define BTRFS_ORPHAN_OBJECTID -5ULL | 98 | #define BTRFS_ORPHAN_OBJECTID -5ULL |
99 | 99 | ||
@@ -3075,7 +3075,7 @@ int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
3075 | int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, | 3075 | int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, |
3076 | struct btrfs_root *root, | 3076 | struct btrfs_root *root, |
3077 | u64 bytenr, u64 num_bytes, u64 flags, | 3077 | u64 bytenr, u64 num_bytes, u64 flags, |
3078 | int is_data); | 3078 | int level, int is_data); |
3079 | int btrfs_free_extent(struct btrfs_trans_handle *trans, | 3079 | int btrfs_free_extent(struct btrfs_trans_handle *trans, |
3080 | struct btrfs_root *root, | 3080 | struct btrfs_root *root, |
3081 | u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid, | 3081 | u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid, |
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index f75fcaf79aeb..70b962cc177d 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h | |||
@@ -60,6 +60,7 @@ struct btrfs_delayed_ref_node { | |||
60 | struct btrfs_delayed_extent_op { | 60 | struct btrfs_delayed_extent_op { |
61 | struct btrfs_disk_key key; | 61 | struct btrfs_disk_key key; |
62 | u64 flags_to_set; | 62 | u64 flags_to_set; |
63 | int level; | ||
63 | unsigned int update_key:1; | 64 | unsigned int update_key:1; |
64 | unsigned int update_flags:1; | 65 | unsigned int update_flags:1; |
65 | unsigned int is_data:1; | 66 | unsigned int is_data:1; |
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 7ba7b3900cb8..65241f32d3f8 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -313,6 +313,11 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
313 | struct btrfs_device *tgt_device = NULL; | 313 | struct btrfs_device *tgt_device = NULL; |
314 | struct btrfs_device *src_device = NULL; | 314 | struct btrfs_device *src_device = NULL; |
315 | 315 | ||
316 | if (btrfs_fs_incompat(fs_info, RAID56)) { | ||
317 | pr_warn("btrfs: dev_replace cannot yet handle RAID5/RAID6\n"); | ||
318 | return -EINVAL; | ||
319 | } | ||
320 | |||
316 | switch (args->start.cont_reading_from_srcdev_mode) { | 321 | switch (args->start.cont_reading_from_srcdev_mode) { |
317 | case BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS: | 322 | case BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS: |
318 | case BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID: | 323 | case BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID: |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index ca0ea9928210..e7b3cb5286a5 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -152,7 +152,7 @@ static struct btrfs_lockdep_keyset { | |||
152 | { .id = BTRFS_DEV_TREE_OBJECTID, .name_stem = "dev" }, | 152 | { .id = BTRFS_DEV_TREE_OBJECTID, .name_stem = "dev" }, |
153 | { .id = BTRFS_FS_TREE_OBJECTID, .name_stem = "fs" }, | 153 | { .id = BTRFS_FS_TREE_OBJECTID, .name_stem = "fs" }, |
154 | { .id = BTRFS_CSUM_TREE_OBJECTID, .name_stem = "csum" }, | 154 | { .id = BTRFS_CSUM_TREE_OBJECTID, .name_stem = "csum" }, |
155 | { .id = BTRFS_ORPHAN_OBJECTID, .name_stem = "orphan" }, | 155 | { .id = BTRFS_QUOTA_TREE_OBJECTID, .name_stem = "quota" }, |
156 | { .id = BTRFS_TREE_LOG_OBJECTID, .name_stem = "log" }, | 156 | { .id = BTRFS_TREE_LOG_OBJECTID, .name_stem = "log" }, |
157 | { .id = BTRFS_TREE_RELOC_OBJECTID, .name_stem = "treloc" }, | 157 | { .id = BTRFS_TREE_RELOC_OBJECTID, .name_stem = "treloc" }, |
158 | { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, .name_stem = "dreloc" }, | 158 | { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, .name_stem = "dreloc" }, |
@@ -1513,7 +1513,6 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root, | |||
1513 | } | 1513 | } |
1514 | 1514 | ||
1515 | root->commit_root = btrfs_root_node(root); | 1515 | root->commit_root = btrfs_root_node(root); |
1516 | BUG_ON(!root->node); /* -ENOMEM */ | ||
1517 | out: | 1516 | out: |
1518 | if (location->objectid != BTRFS_TREE_LOG_OBJECTID) { | 1517 | if (location->objectid != BTRFS_TREE_LOG_OBJECTID) { |
1519 | root->ref_cows = 1; | 1518 | root->ref_cows = 1; |
@@ -1988,30 +1987,33 @@ static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root) | |||
1988 | { | 1987 | { |
1989 | free_extent_buffer(info->tree_root->node); | 1988 | free_extent_buffer(info->tree_root->node); |
1990 | free_extent_buffer(info->tree_root->commit_root); | 1989 | free_extent_buffer(info->tree_root->commit_root); |
1991 | free_extent_buffer(info->dev_root->node); | ||
1992 | free_extent_buffer(info->dev_root->commit_root); | ||
1993 | free_extent_buffer(info->extent_root->node); | ||
1994 | free_extent_buffer(info->extent_root->commit_root); | ||
1995 | free_extent_buffer(info->csum_root->node); | ||
1996 | free_extent_buffer(info->csum_root->commit_root); | ||
1997 | if (info->quota_root) { | ||
1998 | free_extent_buffer(info->quota_root->node); | ||
1999 | free_extent_buffer(info->quota_root->commit_root); | ||
2000 | } | ||
2001 | |||
2002 | info->tree_root->node = NULL; | 1990 | info->tree_root->node = NULL; |
2003 | info->tree_root->commit_root = NULL; | 1991 | info->tree_root->commit_root = NULL; |
2004 | info->dev_root->node = NULL; | 1992 | |
2005 | info->dev_root->commit_root = NULL; | 1993 | if (info->dev_root) { |
2006 | info->extent_root->node = NULL; | 1994 | free_extent_buffer(info->dev_root->node); |
2007 | info->extent_root->commit_root = NULL; | 1995 | free_extent_buffer(info->dev_root->commit_root); |
2008 | info->csum_root->node = NULL; | 1996 | info->dev_root->node = NULL; |
2009 | info->csum_root->commit_root = NULL; | 1997 | info->dev_root->commit_root = NULL; |
1998 | } | ||
1999 | if (info->extent_root) { | ||
2000 | free_extent_buffer(info->extent_root->node); | ||
2001 | free_extent_buffer(info->extent_root->commit_root); | ||
2002 | info->extent_root->node = NULL; | ||
2003 | info->extent_root->commit_root = NULL; | ||
2004 | } | ||
2005 | if (info->csum_root) { | ||
2006 | free_extent_buffer(info->csum_root->node); | ||
2007 | free_extent_buffer(info->csum_root->commit_root); | ||
2008 | info->csum_root->node = NULL; | ||
2009 | info->csum_root->commit_root = NULL; | ||
2010 | } | ||
2010 | if (info->quota_root) { | 2011 | if (info->quota_root) { |
2012 | free_extent_buffer(info->quota_root->node); | ||
2013 | free_extent_buffer(info->quota_root->commit_root); | ||
2011 | info->quota_root->node = NULL; | 2014 | info->quota_root->node = NULL; |
2012 | info->quota_root->commit_root = NULL; | 2015 | info->quota_root->commit_root = NULL; |
2013 | } | 2016 | } |
2014 | |||
2015 | if (chunk_root) { | 2017 | if (chunk_root) { |
2016 | free_extent_buffer(info->chunk_root->node); | 2018 | free_extent_buffer(info->chunk_root->node); |
2017 | free_extent_buffer(info->chunk_root->commit_root); | 2019 | free_extent_buffer(info->chunk_root->commit_root); |
@@ -3659,8 +3661,11 @@ static void btrfs_destroy_ordered_operations(struct btrfs_transaction *t, | |||
3659 | ordered_operations); | 3661 | ordered_operations); |
3660 | 3662 | ||
3661 | list_del_init(&btrfs_inode->ordered_operations); | 3663 | list_del_init(&btrfs_inode->ordered_operations); |
3664 | spin_unlock(&root->fs_info->ordered_extent_lock); | ||
3662 | 3665 | ||
3663 | btrfs_invalidate_inodes(btrfs_inode->root); | 3666 | btrfs_invalidate_inodes(btrfs_inode->root); |
3667 | |||
3668 | spin_lock(&root->fs_info->ordered_extent_lock); | ||
3664 | } | 3669 | } |
3665 | 3670 | ||
3666 | spin_unlock(&root->fs_info->ordered_extent_lock); | 3671 | spin_unlock(&root->fs_info->ordered_extent_lock); |
@@ -3782,8 +3787,11 @@ static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root) | |||
3782 | list_del_init(&btrfs_inode->delalloc_inodes); | 3787 | list_del_init(&btrfs_inode->delalloc_inodes); |
3783 | clear_bit(BTRFS_INODE_IN_DELALLOC_LIST, | 3788 | clear_bit(BTRFS_INODE_IN_DELALLOC_LIST, |
3784 | &btrfs_inode->runtime_flags); | 3789 | &btrfs_inode->runtime_flags); |
3790 | spin_unlock(&root->fs_info->delalloc_lock); | ||
3785 | 3791 | ||
3786 | btrfs_invalidate_inodes(btrfs_inode->root); | 3792 | btrfs_invalidate_inodes(btrfs_inode->root); |
3793 | |||
3794 | spin_lock(&root->fs_info->delalloc_lock); | ||
3787 | } | 3795 | } |
3788 | 3796 | ||
3789 | spin_unlock(&root->fs_info->delalloc_lock); | 3797 | spin_unlock(&root->fs_info->delalloc_lock); |
@@ -3808,7 +3816,7 @@ static int btrfs_destroy_marked_extents(struct btrfs_root *root, | |||
3808 | while (start <= end) { | 3816 | while (start <= end) { |
3809 | eb = btrfs_find_tree_block(root, start, | 3817 | eb = btrfs_find_tree_block(root, start, |
3810 | root->leafsize); | 3818 | root->leafsize); |
3811 | start += eb->len; | 3819 | start += root->leafsize; |
3812 | if (!eb) | 3820 | if (!eb) |
3813 | continue; | 3821 | continue; |
3814 | wait_on_extent_buffer_writeback(eb); | 3822 | wait_on_extent_buffer_writeback(eb); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 2305b5c5cf00..df472ab1b5ac 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -2070,8 +2070,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, | |||
2070 | u32 item_size; | 2070 | u32 item_size; |
2071 | int ret; | 2071 | int ret; |
2072 | int err = 0; | 2072 | int err = 0; |
2073 | int metadata = (node->type == BTRFS_TREE_BLOCK_REF_KEY || | 2073 | int metadata = !extent_op->is_data; |
2074 | node->type == BTRFS_SHARED_BLOCK_REF_KEY); | ||
2075 | 2074 | ||
2076 | if (trans->aborted) | 2075 | if (trans->aborted) |
2077 | return 0; | 2076 | return 0; |
@@ -2086,11 +2085,8 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, | |||
2086 | key.objectid = node->bytenr; | 2085 | key.objectid = node->bytenr; |
2087 | 2086 | ||
2088 | if (metadata) { | 2087 | if (metadata) { |
2089 | struct btrfs_delayed_tree_ref *tree_ref; | ||
2090 | |||
2091 | tree_ref = btrfs_delayed_node_to_tree_ref(node); | ||
2092 | key.type = BTRFS_METADATA_ITEM_KEY; | 2088 | key.type = BTRFS_METADATA_ITEM_KEY; |
2093 | key.offset = tree_ref->level; | 2089 | key.offset = extent_op->level; |
2094 | } else { | 2090 | } else { |
2095 | key.type = BTRFS_EXTENT_ITEM_KEY; | 2091 | key.type = BTRFS_EXTENT_ITEM_KEY; |
2096 | key.offset = node->num_bytes; | 2092 | key.offset = node->num_bytes; |
@@ -2719,7 +2715,7 @@ out: | |||
2719 | int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, | 2715 | int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, |
2720 | struct btrfs_root *root, | 2716 | struct btrfs_root *root, |
2721 | u64 bytenr, u64 num_bytes, u64 flags, | 2717 | u64 bytenr, u64 num_bytes, u64 flags, |
2722 | int is_data) | 2718 | int level, int is_data) |
2723 | { | 2719 | { |
2724 | struct btrfs_delayed_extent_op *extent_op; | 2720 | struct btrfs_delayed_extent_op *extent_op; |
2725 | int ret; | 2721 | int ret; |
@@ -2732,6 +2728,7 @@ int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, | |||
2732 | extent_op->update_flags = 1; | 2728 | extent_op->update_flags = 1; |
2733 | extent_op->update_key = 0; | 2729 | extent_op->update_key = 0; |
2734 | extent_op->is_data = is_data ? 1 : 0; | 2730 | extent_op->is_data = is_data ? 1 : 0; |
2731 | extent_op->level = level; | ||
2735 | 2732 | ||
2736 | ret = btrfs_add_delayed_extent_op(root->fs_info, trans, bytenr, | 2733 | ret = btrfs_add_delayed_extent_op(root->fs_info, trans, bytenr, |
2737 | num_bytes, extent_op); | 2734 | num_bytes, extent_op); |
@@ -3109,6 +3106,11 @@ again: | |||
3109 | WARN_ON(ret); | 3106 | WARN_ON(ret); |
3110 | 3107 | ||
3111 | if (i_size_read(inode) > 0) { | 3108 | if (i_size_read(inode) > 0) { |
3109 | ret = btrfs_check_trunc_cache_free_space(root, | ||
3110 | &root->fs_info->global_block_rsv); | ||
3111 | if (ret) | ||
3112 | goto out_put; | ||
3113 | |||
3112 | ret = btrfs_truncate_free_space_cache(root, trans, path, | 3114 | ret = btrfs_truncate_free_space_cache(root, trans, path, |
3113 | inode); | 3115 | inode); |
3114 | if (ret) | 3116 | if (ret) |
@@ -4562,6 +4564,8 @@ static void init_global_block_rsv(struct btrfs_fs_info *fs_info) | |||
4562 | fs_info->csum_root->block_rsv = &fs_info->global_block_rsv; | 4564 | fs_info->csum_root->block_rsv = &fs_info->global_block_rsv; |
4563 | fs_info->dev_root->block_rsv = &fs_info->global_block_rsv; | 4565 | fs_info->dev_root->block_rsv = &fs_info->global_block_rsv; |
4564 | fs_info->tree_root->block_rsv = &fs_info->global_block_rsv; | 4566 | fs_info->tree_root->block_rsv = &fs_info->global_block_rsv; |
4567 | if (fs_info->quota_root) | ||
4568 | fs_info->quota_root->block_rsv = &fs_info->global_block_rsv; | ||
4565 | fs_info->chunk_root->block_rsv = &fs_info->chunk_block_rsv; | 4569 | fs_info->chunk_root->block_rsv = &fs_info->chunk_block_rsv; |
4566 | 4570 | ||
4567 | update_global_block_rsv(fs_info); | 4571 | update_global_block_rsv(fs_info); |
@@ -6651,51 +6655,51 @@ use_block_rsv(struct btrfs_trans_handle *trans, | |||
6651 | struct btrfs_block_rsv *block_rsv; | 6655 | struct btrfs_block_rsv *block_rsv; |
6652 | struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv; | 6656 | struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv; |
6653 | int ret; | 6657 | int ret; |
6658 | bool global_updated = false; | ||
6654 | 6659 | ||
6655 | block_rsv = get_block_rsv(trans, root); | 6660 | block_rsv = get_block_rsv(trans, root); |
6656 | 6661 | ||
6657 | if (block_rsv->size == 0) { | 6662 | if (unlikely(block_rsv->size == 0)) |
6658 | ret = reserve_metadata_bytes(root, block_rsv, blocksize, | 6663 | goto try_reserve; |
6659 | BTRFS_RESERVE_NO_FLUSH); | 6664 | again: |
6660 | /* | 6665 | ret = block_rsv_use_bytes(block_rsv, blocksize); |
6661 | * If we couldn't reserve metadata bytes try and use some from | 6666 | if (!ret) |
6662 | * the global reserve. | ||
6663 | */ | ||
6664 | if (ret && block_rsv != global_rsv) { | ||
6665 | ret = block_rsv_use_bytes(global_rsv, blocksize); | ||
6666 | if (!ret) | ||
6667 | return global_rsv; | ||
6668 | return ERR_PTR(ret); | ||
6669 | } else if (ret) { | ||
6670 | return ERR_PTR(ret); | ||
6671 | } | ||
6672 | return block_rsv; | 6667 | return block_rsv; |
6668 | |||
6669 | if (block_rsv->failfast) | ||
6670 | return ERR_PTR(ret); | ||
6671 | |||
6672 | if (block_rsv->type == BTRFS_BLOCK_RSV_GLOBAL && !global_updated) { | ||
6673 | global_updated = true; | ||
6674 | update_global_block_rsv(root->fs_info); | ||
6675 | goto again; | ||
6673 | } | 6676 | } |
6674 | 6677 | ||
6675 | ret = block_rsv_use_bytes(block_rsv, blocksize); | 6678 | if (btrfs_test_opt(root, ENOSPC_DEBUG)) { |
6679 | static DEFINE_RATELIMIT_STATE(_rs, | ||
6680 | DEFAULT_RATELIMIT_INTERVAL * 10, | ||
6681 | /*DEFAULT_RATELIMIT_BURST*/ 1); | ||
6682 | if (__ratelimit(&_rs)) | ||
6683 | WARN(1, KERN_DEBUG | ||
6684 | "btrfs: block rsv returned %d\n", ret); | ||
6685 | } | ||
6686 | try_reserve: | ||
6687 | ret = reserve_metadata_bytes(root, block_rsv, blocksize, | ||
6688 | BTRFS_RESERVE_NO_FLUSH); | ||
6676 | if (!ret) | 6689 | if (!ret) |
6677 | return block_rsv; | 6690 | return block_rsv; |
6678 | if (ret && !block_rsv->failfast) { | 6691 | /* |
6679 | if (btrfs_test_opt(root, ENOSPC_DEBUG)) { | 6692 | * If we couldn't reserve metadata bytes try and use some from |
6680 | static DEFINE_RATELIMIT_STATE(_rs, | 6693 | * the global reserve if its space type is the same as the global |
6681 | DEFAULT_RATELIMIT_INTERVAL * 10, | 6694 | * reservation. |
6682 | /*DEFAULT_RATELIMIT_BURST*/ 1); | 6695 | */ |
6683 | if (__ratelimit(&_rs)) | 6696 | if (block_rsv->type != BTRFS_BLOCK_RSV_GLOBAL && |
6684 | WARN(1, KERN_DEBUG | 6697 | block_rsv->space_info == global_rsv->space_info) { |
6685 | "btrfs: block rsv returned %d\n", ret); | 6698 | ret = block_rsv_use_bytes(global_rsv, blocksize); |
6686 | } | 6699 | if (!ret) |
6687 | ret = reserve_metadata_bytes(root, block_rsv, blocksize, | 6700 | return global_rsv; |
6688 | BTRFS_RESERVE_NO_FLUSH); | ||
6689 | if (!ret) { | ||
6690 | return block_rsv; | ||
6691 | } else if (ret && block_rsv != global_rsv) { | ||
6692 | ret = block_rsv_use_bytes(global_rsv, blocksize); | ||
6693 | if (!ret) | ||
6694 | return global_rsv; | ||
6695 | } | ||
6696 | } | 6701 | } |
6697 | 6702 | return ERR_PTR(ret); | |
6698 | return ERR_PTR(-ENOSPC); | ||
6699 | } | 6703 | } |
6700 | 6704 | ||
6701 | static void unuse_block_rsv(struct btrfs_fs_info *fs_info, | 6705 | static void unuse_block_rsv(struct btrfs_fs_info *fs_info, |
@@ -6763,6 +6767,7 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | |||
6763 | extent_op->update_key = 1; | 6767 | extent_op->update_key = 1; |
6764 | extent_op->update_flags = 1; | 6768 | extent_op->update_flags = 1; |
6765 | extent_op->is_data = 0; | 6769 | extent_op->is_data = 0; |
6770 | extent_op->level = level; | ||
6766 | 6771 | ||
6767 | ret = btrfs_add_delayed_tree_ref(root->fs_info, trans, | 6772 | ret = btrfs_add_delayed_tree_ref(root->fs_info, trans, |
6768 | ins.objectid, | 6773 | ins.objectid, |
@@ -6934,7 +6939,8 @@ static noinline int walk_down_proc(struct btrfs_trans_handle *trans, | |||
6934 | ret = btrfs_dec_ref(trans, root, eb, 0, wc->for_reloc); | 6939 | ret = btrfs_dec_ref(trans, root, eb, 0, wc->for_reloc); |
6935 | BUG_ON(ret); /* -ENOMEM */ | 6940 | BUG_ON(ret); /* -ENOMEM */ |
6936 | ret = btrfs_set_disk_extent_flags(trans, root, eb->start, | 6941 | ret = btrfs_set_disk_extent_flags(trans, root, eb->start, |
6937 | eb->len, flag, 0); | 6942 | eb->len, flag, |
6943 | btrfs_header_level(eb), 0); | ||
6938 | BUG_ON(ret); /* -ENOMEM */ | 6944 | BUG_ON(ret); /* -ENOMEM */ |
6939 | wc->flags[level] |= flag; | 6945 | wc->flags[level] |= flag; |
6940 | } | 6946 | } |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index fe1d6c3424a5..b306b3a88fc7 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -1961,28 +1961,6 @@ static void check_page_uptodate(struct extent_io_tree *tree, struct page *page) | |||
1961 | } | 1961 | } |
1962 | 1962 | ||
1963 | /* | 1963 | /* |
1964 | * helper function to unlock a page if all the extents in the tree | ||
1965 | * for that page are unlocked | ||
1966 | */ | ||
1967 | static void check_page_locked(struct extent_io_tree *tree, struct page *page) | ||
1968 | { | ||
1969 | u64 start = page_offset(page); | ||
1970 | u64 end = start + PAGE_CACHE_SIZE - 1; | ||
1971 | if (!test_range_bit(tree, start, end, EXTENT_LOCKED, 0, NULL)) | ||
1972 | unlock_page(page); | ||
1973 | } | ||
1974 | |||
1975 | /* | ||
1976 | * helper function to end page writeback if all the extents | ||
1977 | * in the tree for that page are done with writeback | ||
1978 | */ | ||
1979 | static void check_page_writeback(struct extent_io_tree *tree, | ||
1980 | struct page *page) | ||
1981 | { | ||
1982 | end_page_writeback(page); | ||
1983 | } | ||
1984 | |||
1985 | /* | ||
1986 | * When IO fails, either with EIO or csum verification fails, we | 1964 | * When IO fails, either with EIO or csum verification fails, we |
1987 | * try other mirrors that might have a good copy of the data. This | 1965 | * try other mirrors that might have a good copy of the data. This |
1988 | * io_failure_record is used to record state as we go through all the | 1966 | * io_failure_record is used to record state as we go through all the |
@@ -2411,19 +2389,24 @@ static void end_bio_extent_writepage(struct bio *bio, int err) | |||
2411 | struct extent_io_tree *tree; | 2389 | struct extent_io_tree *tree; |
2412 | u64 start; | 2390 | u64 start; |
2413 | u64 end; | 2391 | u64 end; |
2414 | int whole_page; | ||
2415 | 2392 | ||
2416 | do { | 2393 | do { |
2417 | struct page *page = bvec->bv_page; | 2394 | struct page *page = bvec->bv_page; |
2418 | tree = &BTRFS_I(page->mapping->host)->io_tree; | 2395 | tree = &BTRFS_I(page->mapping->host)->io_tree; |
2419 | 2396 | ||
2420 | start = page_offset(page) + bvec->bv_offset; | 2397 | /* We always issue full-page reads, but if some block |
2421 | end = start + bvec->bv_len - 1; | 2398 | * in a page fails to read, blk_update_request() will |
2399 | * advance bv_offset and adjust bv_len to compensate. | ||
2400 | * Print a warning for nonzero offsets, and an error | ||
2401 | * if they don't add up to a full page. */ | ||
2402 | if (bvec->bv_offset || bvec->bv_len != PAGE_CACHE_SIZE) | ||
2403 | printk("%s page write in btrfs with offset %u and length %u\n", | ||
2404 | bvec->bv_offset + bvec->bv_len != PAGE_CACHE_SIZE | ||
2405 | ? KERN_ERR "partial" : KERN_INFO "incomplete", | ||
2406 | bvec->bv_offset, bvec->bv_len); | ||
2422 | 2407 | ||
2423 | if (bvec->bv_offset == 0 && bvec->bv_len == PAGE_CACHE_SIZE) | 2408 | start = page_offset(page); |
2424 | whole_page = 1; | 2409 | end = start + bvec->bv_offset + bvec->bv_len - 1; |
2425 | else | ||
2426 | whole_page = 0; | ||
2427 | 2410 | ||
2428 | if (--bvec >= bio->bi_io_vec) | 2411 | if (--bvec >= bio->bi_io_vec) |
2429 | prefetchw(&bvec->bv_page->flags); | 2412 | prefetchw(&bvec->bv_page->flags); |
@@ -2431,10 +2414,7 @@ static void end_bio_extent_writepage(struct bio *bio, int err) | |||
2431 | if (end_extent_writepage(page, err, start, end)) | 2414 | if (end_extent_writepage(page, err, start, end)) |
2432 | continue; | 2415 | continue; |
2433 | 2416 | ||
2434 | if (whole_page) | 2417 | end_page_writeback(page); |
2435 | end_page_writeback(page); | ||
2436 | else | ||
2437 | check_page_writeback(tree, page); | ||
2438 | } while (bvec >= bio->bi_io_vec); | 2418 | } while (bvec >= bio->bi_io_vec); |
2439 | 2419 | ||
2440 | bio_put(bio); | 2420 | bio_put(bio); |
@@ -2459,7 +2439,6 @@ static void end_bio_extent_readpage(struct bio *bio, int err) | |||
2459 | struct extent_io_tree *tree; | 2439 | struct extent_io_tree *tree; |
2460 | u64 start; | 2440 | u64 start; |
2461 | u64 end; | 2441 | u64 end; |
2462 | int whole_page; | ||
2463 | int mirror; | 2442 | int mirror; |
2464 | int ret; | 2443 | int ret; |
2465 | 2444 | ||
@@ -2477,13 +2456,19 @@ static void end_bio_extent_readpage(struct bio *bio, int err) | |||
2477 | io_bio->mirror_num); | 2456 | io_bio->mirror_num); |
2478 | tree = &BTRFS_I(page->mapping->host)->io_tree; | 2457 | tree = &BTRFS_I(page->mapping->host)->io_tree; |
2479 | 2458 | ||
2480 | start = page_offset(page) + bvec->bv_offset; | 2459 | /* We always issue full-page reads, but if some block |
2481 | end = start + bvec->bv_len - 1; | 2460 | * in a page fails to read, blk_update_request() will |
2461 | * advance bv_offset and adjust bv_len to compensate. | ||
2462 | * Print a warning for nonzero offsets, and an error | ||
2463 | * if they don't add up to a full page. */ | ||
2464 | if (bvec->bv_offset || bvec->bv_len != PAGE_CACHE_SIZE) | ||
2465 | printk("%s page read in btrfs with offset %u and length %u\n", | ||
2466 | bvec->bv_offset + bvec->bv_len != PAGE_CACHE_SIZE | ||
2467 | ? KERN_ERR "partial" : KERN_INFO "incomplete", | ||
2468 | bvec->bv_offset, bvec->bv_len); | ||
2482 | 2469 | ||
2483 | if (bvec->bv_offset == 0 && bvec->bv_len == PAGE_CACHE_SIZE) | 2470 | start = page_offset(page); |
2484 | whole_page = 1; | 2471 | end = start + bvec->bv_offset + bvec->bv_len - 1; |
2485 | else | ||
2486 | whole_page = 0; | ||
2487 | 2472 | ||
2488 | if (++bvec <= bvec_end) | 2473 | if (++bvec <= bvec_end) |
2489 | prefetchw(&bvec->bv_page->flags); | 2474 | prefetchw(&bvec->bv_page->flags); |
@@ -2542,23 +2527,13 @@ static void end_bio_extent_readpage(struct bio *bio, int err) | |||
2542 | } | 2527 | } |
2543 | unlock_extent_cached(tree, start, end, &cached, GFP_ATOMIC); | 2528 | unlock_extent_cached(tree, start, end, &cached, GFP_ATOMIC); |
2544 | 2529 | ||
2545 | if (whole_page) { | 2530 | if (uptodate) { |
2546 | if (uptodate) { | 2531 | SetPageUptodate(page); |
2547 | SetPageUptodate(page); | ||
2548 | } else { | ||
2549 | ClearPageUptodate(page); | ||
2550 | SetPageError(page); | ||
2551 | } | ||
2552 | unlock_page(page); | ||
2553 | } else { | 2532 | } else { |
2554 | if (uptodate) { | 2533 | ClearPageUptodate(page); |
2555 | check_page_uptodate(tree, page); | 2534 | SetPageError(page); |
2556 | } else { | ||
2557 | ClearPageUptodate(page); | ||
2558 | SetPageError(page); | ||
2559 | } | ||
2560 | check_page_locked(tree, page); | ||
2561 | } | 2535 | } |
2536 | unlock_page(page); | ||
2562 | } while (bvec <= bvec_end); | 2537 | } while (bvec <= bvec_end); |
2563 | 2538 | ||
2564 | bio_put(bio); | 2539 | bio_put(bio); |
@@ -4022,7 +3997,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | |||
4022 | last_for_get_extent = isize; | 3997 | last_for_get_extent = isize; |
4023 | } | 3998 | } |
4024 | 3999 | ||
4025 | lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len, 0, | 4000 | lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len - 1, 0, |
4026 | &cached_state); | 4001 | &cached_state); |
4027 | 4002 | ||
4028 | em = get_extent_skip_holes(inode, start, last_for_get_extent, | 4003 | em = get_extent_skip_holes(inode, start, last_for_get_extent, |
@@ -4109,7 +4084,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | |||
4109 | out_free: | 4084 | out_free: |
4110 | free_extent_map(em); | 4085 | free_extent_map(em); |
4111 | out: | 4086 | out: |
4112 | unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, start + len, | 4087 | unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, start + len - 1, |
4113 | &cached_state, GFP_NOFS); | 4088 | &cached_state, GFP_NOFS); |
4114 | return ret; | 4089 | return ret; |
4115 | } | 4090 | } |
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index ecca6c7375a6..e53009657f0e 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -197,30 +197,32 @@ int create_free_space_inode(struct btrfs_root *root, | |||
197 | block_group->key.objectid); | 197 | block_group->key.objectid); |
198 | } | 198 | } |
199 | 199 | ||
200 | int btrfs_truncate_free_space_cache(struct btrfs_root *root, | 200 | int btrfs_check_trunc_cache_free_space(struct btrfs_root *root, |
201 | struct btrfs_trans_handle *trans, | 201 | struct btrfs_block_rsv *rsv) |
202 | struct btrfs_path *path, | ||
203 | struct inode *inode) | ||
204 | { | 202 | { |
205 | struct btrfs_block_rsv *rsv; | ||
206 | u64 needed_bytes; | 203 | u64 needed_bytes; |
207 | loff_t oldsize; | 204 | int ret; |
208 | int ret = 0; | ||
209 | |||
210 | rsv = trans->block_rsv; | ||
211 | trans->block_rsv = &root->fs_info->global_block_rsv; | ||
212 | 205 | ||
213 | /* 1 for slack space, 1 for updating the inode */ | 206 | /* 1 for slack space, 1 for updating the inode */ |
214 | needed_bytes = btrfs_calc_trunc_metadata_size(root, 1) + | 207 | needed_bytes = btrfs_calc_trunc_metadata_size(root, 1) + |
215 | btrfs_calc_trans_metadata_size(root, 1); | 208 | btrfs_calc_trans_metadata_size(root, 1); |
216 | 209 | ||
217 | spin_lock(&trans->block_rsv->lock); | 210 | spin_lock(&rsv->lock); |
218 | if (trans->block_rsv->reserved < needed_bytes) { | 211 | if (rsv->reserved < needed_bytes) |
219 | spin_unlock(&trans->block_rsv->lock); | 212 | ret = -ENOSPC; |
220 | trans->block_rsv = rsv; | 213 | else |
221 | return -ENOSPC; | 214 | ret = 0; |
222 | } | 215 | spin_unlock(&rsv->lock); |
223 | spin_unlock(&trans->block_rsv->lock); | 216 | return 0; |
217 | } | ||
218 | |||
219 | int btrfs_truncate_free_space_cache(struct btrfs_root *root, | ||
220 | struct btrfs_trans_handle *trans, | ||
221 | struct btrfs_path *path, | ||
222 | struct inode *inode) | ||
223 | { | ||
224 | loff_t oldsize; | ||
225 | int ret = 0; | ||
224 | 226 | ||
225 | oldsize = i_size_read(inode); | 227 | oldsize = i_size_read(inode); |
226 | btrfs_i_size_write(inode, 0); | 228 | btrfs_i_size_write(inode, 0); |
@@ -232,9 +234,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, | |||
232 | */ | 234 | */ |
233 | ret = btrfs_truncate_inode_items(trans, root, inode, | 235 | ret = btrfs_truncate_inode_items(trans, root, inode, |
234 | 0, BTRFS_EXTENT_DATA_KEY); | 236 | 0, BTRFS_EXTENT_DATA_KEY); |
235 | |||
236 | if (ret) { | 237 | if (ret) { |
237 | trans->block_rsv = rsv; | ||
238 | btrfs_abort_transaction(trans, root, ret); | 238 | btrfs_abort_transaction(trans, root, ret); |
239 | return ret; | 239 | return ret; |
240 | } | 240 | } |
@@ -242,7 +242,6 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, | |||
242 | ret = btrfs_update_inode(trans, root, inode); | 242 | ret = btrfs_update_inode(trans, root, inode); |
243 | if (ret) | 243 | if (ret) |
244 | btrfs_abort_transaction(trans, root, ret); | 244 | btrfs_abort_transaction(trans, root, ret); |
245 | trans->block_rsv = rsv; | ||
246 | 245 | ||
247 | return ret; | 246 | return ret; |
248 | } | 247 | } |
@@ -920,10 +919,8 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, | |||
920 | 919 | ||
921 | /* Make sure we can fit our crcs into the first page */ | 920 | /* Make sure we can fit our crcs into the first page */ |
922 | if (io_ctl.check_crcs && | 921 | if (io_ctl.check_crcs && |
923 | (io_ctl.num_pages * sizeof(u32)) >= PAGE_CACHE_SIZE) { | 922 | (io_ctl.num_pages * sizeof(u32)) >= PAGE_CACHE_SIZE) |
924 | WARN_ON(1); | ||
925 | goto out_nospc; | 923 | goto out_nospc; |
926 | } | ||
927 | 924 | ||
928 | io_ctl_set_generation(&io_ctl, trans->transid); | 925 | io_ctl_set_generation(&io_ctl, trans->transid); |
929 | 926 | ||
diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h index 4dc17d8809c7..8b7f19f44961 100644 --- a/fs/btrfs/free-space-cache.h +++ b/fs/btrfs/free-space-cache.h | |||
@@ -54,6 +54,8 @@ int create_free_space_inode(struct btrfs_root *root, | |||
54 | struct btrfs_block_group_cache *block_group, | 54 | struct btrfs_block_group_cache *block_group, |
55 | struct btrfs_path *path); | 55 | struct btrfs_path *path); |
56 | 56 | ||
57 | int btrfs_check_trunc_cache_free_space(struct btrfs_root *root, | ||
58 | struct btrfs_block_rsv *rsv); | ||
57 | int btrfs_truncate_free_space_cache(struct btrfs_root *root, | 59 | int btrfs_truncate_free_space_cache(struct btrfs_root *root, |
58 | struct btrfs_trans_handle *trans, | 60 | struct btrfs_trans_handle *trans, |
59 | struct btrfs_path *path, | 61 | struct btrfs_path *path, |
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index d26f67a59e36..2c66ddbbe670 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c | |||
@@ -429,11 +429,12 @@ int btrfs_save_ino_cache(struct btrfs_root *root, | |||
429 | num_bytes = trans->bytes_reserved; | 429 | num_bytes = trans->bytes_reserved; |
430 | /* | 430 | /* |
431 | * 1 item for inode item insertion if need | 431 | * 1 item for inode item insertion if need |
432 | * 3 items for inode item update (in the worst case) | 432 | * 4 items for inode item update (in the worst case) |
433 | * 1 items for slack space if we need do truncation | ||
433 | * 1 item for free space object | 434 | * 1 item for free space object |
434 | * 3 items for pre-allocation | 435 | * 3 items for pre-allocation |
435 | */ | 436 | */ |
436 | trans->bytes_reserved = btrfs_calc_trans_metadata_size(root, 8); | 437 | trans->bytes_reserved = btrfs_calc_trans_metadata_size(root, 10); |
437 | ret = btrfs_block_rsv_add(root, trans->block_rsv, | 438 | ret = btrfs_block_rsv_add(root, trans->block_rsv, |
438 | trans->bytes_reserved, | 439 | trans->bytes_reserved, |
439 | BTRFS_RESERVE_NO_FLUSH); | 440 | BTRFS_RESERVE_NO_FLUSH); |
@@ -468,7 +469,8 @@ again: | |||
468 | if (i_size_read(inode) > 0) { | 469 | if (i_size_read(inode) > 0) { |
469 | ret = btrfs_truncate_free_space_cache(root, trans, path, inode); | 470 | ret = btrfs_truncate_free_space_cache(root, trans, path, inode); |
470 | if (ret) { | 471 | if (ret) { |
471 | btrfs_abort_transaction(trans, root, ret); | 472 | if (ret != -ENOSPC) |
473 | btrfs_abort_transaction(trans, root, ret); | ||
472 | goto out_put; | 474 | goto out_put; |
473 | } | 475 | } |
474 | } | 476 | } |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d59dddfb1f96..23c596cd1b98 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -714,8 +714,10 @@ retry: | |||
714 | async_extent->ram_size - 1, 0); | 714 | async_extent->ram_size - 1, 0); |
715 | 715 | ||
716 | em = alloc_extent_map(); | 716 | em = alloc_extent_map(); |
717 | if (!em) | 717 | if (!em) { |
718 | ret = -ENOMEM; | ||
718 | goto out_free_reserve; | 719 | goto out_free_reserve; |
720 | } | ||
719 | em->start = async_extent->start; | 721 | em->start = async_extent->start; |
720 | em->len = async_extent->ram_size; | 722 | em->len = async_extent->ram_size; |
721 | em->orig_start = em->start; | 723 | em->orig_start = em->start; |
@@ -922,8 +924,10 @@ static noinline int __cow_file_range(struct btrfs_trans_handle *trans, | |||
922 | } | 924 | } |
923 | 925 | ||
924 | em = alloc_extent_map(); | 926 | em = alloc_extent_map(); |
925 | if (!em) | 927 | if (!em) { |
928 | ret = -ENOMEM; | ||
926 | goto out_reserve; | 929 | goto out_reserve; |
930 | } | ||
927 | em->start = start; | 931 | em->start = start; |
928 | em->orig_start = em->start; | 932 | em->orig_start = em->start; |
929 | ram_size = ins.offset; | 933 | ram_size = ins.offset; |
@@ -4723,6 +4727,7 @@ void btrfs_evict_inode(struct inode *inode) | |||
4723 | btrfs_end_transaction(trans, root); | 4727 | btrfs_end_transaction(trans, root); |
4724 | btrfs_btree_balance_dirty(root); | 4728 | btrfs_btree_balance_dirty(root); |
4725 | no_delete: | 4729 | no_delete: |
4730 | btrfs_remove_delayed_node(inode); | ||
4726 | clear_inode(inode); | 4731 | clear_inode(inode); |
4727 | return; | 4732 | return; |
4728 | } | 4733 | } |
@@ -4838,14 +4843,13 @@ static void inode_tree_add(struct inode *inode) | |||
4838 | struct rb_node **p; | 4843 | struct rb_node **p; |
4839 | struct rb_node *parent; | 4844 | struct rb_node *parent; |
4840 | u64 ino = btrfs_ino(inode); | 4845 | u64 ino = btrfs_ino(inode); |
4841 | again: | ||
4842 | p = &root->inode_tree.rb_node; | ||
4843 | parent = NULL; | ||
4844 | 4846 | ||
4845 | if (inode_unhashed(inode)) | 4847 | if (inode_unhashed(inode)) |
4846 | return; | 4848 | return; |
4847 | 4849 | again: | |
4850 | parent = NULL; | ||
4848 | spin_lock(&root->inode_lock); | 4851 | spin_lock(&root->inode_lock); |
4852 | p = &root->inode_tree.rb_node; | ||
4849 | while (*p) { | 4853 | while (*p) { |
4850 | parent = *p; | 4854 | parent = *p; |
4851 | entry = rb_entry(parent, struct btrfs_inode, rb_node); | 4855 | entry = rb_entry(parent, struct btrfs_inode, rb_node); |
@@ -8000,7 +8004,6 @@ void btrfs_destroy_inode(struct inode *inode) | |||
8000 | inode_tree_del(inode); | 8004 | inode_tree_del(inode); |
8001 | btrfs_drop_extent_cache(inode, 0, (u64)-1, 0); | 8005 | btrfs_drop_extent_cache(inode, 0, (u64)-1, 0); |
8002 | free: | 8006 | free: |
8003 | btrfs_remove_delayed_node(inode); | ||
8004 | call_rcu(&inode->i_rcu, btrfs_i_callback); | 8007 | call_rcu(&inode->i_rcu, btrfs_i_callback); |
8005 | } | 8008 | } |
8006 | 8009 | ||
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 0de4a2fcfb24..0f81d67cdc8d 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -1801,7 +1801,11 @@ static noinline int copy_to_sk(struct btrfs_root *root, | |||
1801 | item_off = btrfs_item_ptr_offset(leaf, i); | 1801 | item_off = btrfs_item_ptr_offset(leaf, i); |
1802 | item_len = btrfs_item_size_nr(leaf, i); | 1802 | item_len = btrfs_item_size_nr(leaf, i); |
1803 | 1803 | ||
1804 | if (item_len > BTRFS_SEARCH_ARGS_BUFSIZE) | 1804 | btrfs_item_key_to_cpu(leaf, key, i); |
1805 | if (!key_in_sk(key, sk)) | ||
1806 | continue; | ||
1807 | |||
1808 | if (sizeof(sh) + item_len > BTRFS_SEARCH_ARGS_BUFSIZE) | ||
1805 | item_len = 0; | 1809 | item_len = 0; |
1806 | 1810 | ||
1807 | if (sizeof(sh) + item_len + *sk_offset > | 1811 | if (sizeof(sh) + item_len + *sk_offset > |
@@ -1810,10 +1814,6 @@ static noinline int copy_to_sk(struct btrfs_root *root, | |||
1810 | goto overflow; | 1814 | goto overflow; |
1811 | } | 1815 | } |
1812 | 1816 | ||
1813 | btrfs_item_key_to_cpu(leaf, key, i); | ||
1814 | if (!key_in_sk(key, sk)) | ||
1815 | continue; | ||
1816 | |||
1817 | sh.objectid = key->objectid; | 1817 | sh.objectid = key->objectid; |
1818 | sh.offset = key->offset; | 1818 | sh.offset = key->offset; |
1819 | sh.type = key->type; | 1819 | sh.type = key->type; |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 704a1b8d2a2b..395b82031a42 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -1773,7 +1773,7 @@ again: | |||
1773 | if (!eb || !extent_buffer_uptodate(eb)) { | 1773 | if (!eb || !extent_buffer_uptodate(eb)) { |
1774 | ret = (!eb) ? -ENOMEM : -EIO; | 1774 | ret = (!eb) ? -ENOMEM : -EIO; |
1775 | free_extent_buffer(eb); | 1775 | free_extent_buffer(eb); |
1776 | return ret; | 1776 | break; |
1777 | } | 1777 | } |
1778 | btrfs_tree_lock(eb); | 1778 | btrfs_tree_lock(eb); |
1779 | if (cow) { | 1779 | if (cow) { |
@@ -3350,6 +3350,11 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info, | |||
3350 | } | 3350 | } |
3351 | 3351 | ||
3352 | truncate: | 3352 | truncate: |
3353 | ret = btrfs_check_trunc_cache_free_space(root, | ||
3354 | &fs_info->global_block_rsv); | ||
3355 | if (ret) | ||
3356 | goto out; | ||
3357 | |||
3353 | path = btrfs_alloc_path(); | 3358 | path = btrfs_alloc_path(); |
3354 | if (!path) { | 3359 | if (!path) { |
3355 | ret = -ENOMEM; | 3360 | ret = -ENOMEM; |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index a4807ced23cc..f0857e092a3c 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -1263,6 +1263,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) | |||
1263 | 1263 | ||
1264 | btrfs_dev_replace_suspend_for_unmount(fs_info); | 1264 | btrfs_dev_replace_suspend_for_unmount(fs_info); |
1265 | btrfs_scrub_cancel(fs_info); | 1265 | btrfs_scrub_cancel(fs_info); |
1266 | btrfs_pause_balance(fs_info); | ||
1266 | 1267 | ||
1267 | ret = btrfs_commit_super(root); | 1268 | ret = btrfs_commit_super(root); |
1268 | if (ret) | 1269 | if (ret) |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 317afc7a2af4..24940085cdac 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -3120,14 +3120,13 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
3120 | allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE; | 3120 | allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE; |
3121 | if (num_devices == 1) | 3121 | if (num_devices == 1) |
3122 | allowed |= BTRFS_BLOCK_GROUP_DUP; | 3122 | allowed |= BTRFS_BLOCK_GROUP_DUP; |
3123 | else if (num_devices < 4) | 3123 | else if (num_devices > 1) |
3124 | allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1); | 3124 | allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1); |
3125 | else | 3125 | if (num_devices > 2) |
3126 | allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | | 3126 | allowed |= BTRFS_BLOCK_GROUP_RAID5; |
3127 | BTRFS_BLOCK_GROUP_RAID10 | | 3127 | if (num_devices > 3) |
3128 | BTRFS_BLOCK_GROUP_RAID5 | | 3128 | allowed |= (BTRFS_BLOCK_GROUP_RAID10 | |
3129 | BTRFS_BLOCK_GROUP_RAID6); | 3129 | BTRFS_BLOCK_GROUP_RAID6); |
3130 | |||
3131 | if ((bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) && | 3130 | if ((bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) && |
3132 | (!alloc_profile_is_valid(bctl->data.target, 1) || | 3131 | (!alloc_profile_is_valid(bctl->data.target, 1) || |
3133 | (bctl->data.target & ~allowed))) { | 3132 | (bctl->data.target & ~allowed))) { |