aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 4e9eeb48f76f..56d8ec21a0f4 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -87,7 +87,8 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
87 int force); 87 int force);
88static int find_next_key(struct btrfs_path *path, int level, 88static int find_next_key(struct btrfs_path *path, int level,
89 struct btrfs_key *key); 89 struct btrfs_key *key);
90static void dump_space_info(struct btrfs_space_info *info, u64 bytes, 90static void dump_space_info(struct btrfs_fs_info *fs_info,
91 struct btrfs_space_info *info, u64 bytes,
91 int dump_block_groups); 92 int dump_block_groups);
92static int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache, 93static int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache,
93 u64 ram_bytes, u64 num_bytes, int delalloc); 94 u64 ram_bytes, u64 num_bytes, int delalloc);
@@ -266,9 +267,8 @@ static int exclude_super_stripes(struct btrfs_root *root,
266 267
267 for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { 268 for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
268 bytenr = btrfs_sb_offset(i); 269 bytenr = btrfs_sb_offset(i);
269 ret = btrfs_rmap_block(&root->fs_info->mapping_tree, 270 ret = btrfs_rmap_block(root->fs_info, cache->key.objectid,
270 cache->key.objectid, bytenr, 271 bytenr, 0, &logical, &nr, &stripe_len);
271 0, &logical, &nr, &stripe_len);
272 if (ret) 272 if (ret)
273 return ret; 273 return ret;
274 274
@@ -4432,7 +4432,7 @@ void check_system_chunk(struct btrfs_trans_handle *trans,
4432 if (left < thresh && btrfs_test_opt(root->fs_info, ENOSPC_DEBUG)) { 4432 if (left < thresh && btrfs_test_opt(root->fs_info, ENOSPC_DEBUG)) {
4433 btrfs_info(root->fs_info, "left=%llu, need=%llu, flags=%llu", 4433 btrfs_info(root->fs_info, "left=%llu, need=%llu, flags=%llu",
4434 left, thresh, type); 4434 left, thresh, type);
4435 dump_space_info(info, 0, 0); 4435 dump_space_info(root->fs_info, info, 0, 0);
4436 } 4436 }
4437 4437
4438 if (left < thresh) { 4438 if (left < thresh) {
@@ -7907,22 +7907,24 @@ out:
7907 return ret; 7907 return ret;
7908} 7908}
7909 7909
7910static void dump_space_info(struct btrfs_space_info *info, u64 bytes, 7910static void dump_space_info(struct btrfs_fs_info *fs_info,
7911 struct btrfs_space_info *info, u64 bytes,
7911 int dump_block_groups) 7912 int dump_block_groups)
7912{ 7913{
7913 struct btrfs_block_group_cache *cache; 7914 struct btrfs_block_group_cache *cache;
7914 int index = 0; 7915 int index = 0;
7915 7916
7916 spin_lock(&info->lock); 7917 spin_lock(&info->lock);
7917 pr_info("BTRFS: space_info %llu has %llu free, is %sfull\n", 7918 btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull",
7918 info->flags, 7919 info->flags,
7919 info->total_bytes - info->bytes_used - info->bytes_pinned - 7920 info->total_bytes - info->bytes_used - info->bytes_pinned -
7920 info->bytes_reserved - info->bytes_readonly - 7921 info->bytes_reserved - info->bytes_readonly -
7921 info->bytes_may_use, (info->full) ? "" : "not "); 7922 info->bytes_may_use, (info->full) ? "" : "not ");
7922 pr_info("BTRFS: space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, may_use=%llu, readonly=%llu\n", 7923 btrfs_info(fs_info,
7923 info->total_bytes, info->bytes_used, info->bytes_pinned, 7924 "space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, may_use=%llu, readonly=%llu",
7924 info->bytes_reserved, info->bytes_may_use, 7925 info->total_bytes, info->bytes_used, info->bytes_pinned,
7925 info->bytes_readonly); 7926 info->bytes_reserved, info->bytes_may_use,
7927 info->bytes_readonly);
7926 spin_unlock(&info->lock); 7928 spin_unlock(&info->lock);
7927 7929
7928 if (!dump_block_groups) 7930 if (!dump_block_groups)
@@ -7932,10 +7934,11 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes,
7932again: 7934again:
7933 list_for_each_entry(cache, &info->block_groups[index], list) { 7935 list_for_each_entry(cache, &info->block_groups[index], list) {
7934 spin_lock(&cache->lock); 7936 spin_lock(&cache->lock);
7935 pr_info("BTRFS: block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %s\n", 7937 btrfs_info(fs_info,
7936 cache->key.objectid, cache->key.offset, 7938 "block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %s",
7937 btrfs_block_group_used(&cache->item), cache->pinned, 7939 cache->key.objectid, cache->key.offset,
7938 cache->reserved, cache->ro ? "[readonly]" : ""); 7940 btrfs_block_group_used(&cache->item), cache->pinned,
7941 cache->reserved, cache->ro ? "[readonly]" : "");
7939 btrfs_dump_free_space(cache, bytes); 7942 btrfs_dump_free_space(cache, bytes);
7940 spin_unlock(&cache->lock); 7943 spin_unlock(&cache->lock);
7941 } 7944 }
@@ -7949,6 +7952,7 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes,
7949 u64 empty_size, u64 hint_byte, 7952 u64 empty_size, u64 hint_byte,
7950 struct btrfs_key *ins, int is_data, int delalloc) 7953 struct btrfs_key *ins, int is_data, int delalloc)
7951{ 7954{
7955 struct btrfs_fs_info *fs_info = root->fs_info;
7952 bool final_tried = num_bytes == min_alloc_size; 7956 bool final_tried = num_bytes == min_alloc_size;
7953 u64 flags; 7957 u64 flags;
7954 int ret; 7958 int ret;
@@ -7959,8 +7963,7 @@ again:
7959 ret = find_free_extent(root, ram_bytes, num_bytes, empty_size, 7963 ret = find_free_extent(root, ram_bytes, num_bytes, empty_size,
7960 hint_byte, ins, flags, delalloc); 7964 hint_byte, ins, flags, delalloc);
7961 if (!ret && !is_data) { 7965 if (!ret && !is_data) {
7962 btrfs_dec_block_group_reservations(root->fs_info, 7966 btrfs_dec_block_group_reservations(fs_info, ins->objectid);
7963 ins->objectid);
7964 } else if (ret == -ENOSPC) { 7967 } else if (ret == -ENOSPC) {
7965 if (!final_tried && ins->offset) { 7968 if (!final_tried && ins->offset) {
7966 num_bytes = min(num_bytes >> 1, ins->offset); 7969 num_bytes = min(num_bytes >> 1, ins->offset);
@@ -7970,15 +7973,15 @@ again:
7970 if (num_bytes == min_alloc_size) 7973 if (num_bytes == min_alloc_size)
7971 final_tried = true; 7974 final_tried = true;
7972 goto again; 7975 goto again;
7973 } else if (btrfs_test_opt(root->fs_info, ENOSPC_DEBUG)) { 7976 } else if (btrfs_test_opt(fs_info, ENOSPC_DEBUG)) {
7974 struct btrfs_space_info *sinfo; 7977 struct btrfs_space_info *sinfo;
7975 7978
7976 sinfo = __find_space_info(root->fs_info, flags); 7979 sinfo = __find_space_info(fs_info, flags);
7977 btrfs_err(root->fs_info, 7980 btrfs_err(root->fs_info,
7978 "allocation failed flags %llu, wanted %llu", 7981 "allocation failed flags %llu, wanted %llu",
7979 flags, num_bytes); 7982 flags, num_bytes);
7980 if (sinfo) 7983 if (sinfo)
7981 dump_space_info(sinfo, num_bytes, 1); 7984 dump_space_info(fs_info, sinfo, num_bytes, 1);
7982 } 7985 }
7983 } 7986 }
7984 7987
@@ -9178,9 +9181,10 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
9178 struct btrfs_block_rsv *block_rsv, int update_ref, 9181 struct btrfs_block_rsv *block_rsv, int update_ref,
9179 int for_reloc) 9182 int for_reloc)
9180{ 9183{
9184 struct btrfs_fs_info *fs_info = root->fs_info;
9181 struct btrfs_path *path; 9185 struct btrfs_path *path;
9182 struct btrfs_trans_handle *trans; 9186 struct btrfs_trans_handle *trans;
9183 struct btrfs_root *tree_root = root->fs_info->tree_root; 9187 struct btrfs_root *tree_root = fs_info->tree_root;
9184 struct btrfs_root_item *root_item = &root->root_item; 9188 struct btrfs_root_item *root_item = &root->root_item;
9185 struct walk_control *wc; 9189 struct walk_control *wc;
9186 struct btrfs_key key; 9190 struct btrfs_key key;
@@ -9189,7 +9193,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
9189 int level; 9193 int level;
9190 bool root_dropped = false; 9194 bool root_dropped = false;
9191 9195
9192 btrfs_debug(root->fs_info, "Drop subvolume %llu", root->objectid); 9196 btrfs_debug(fs_info, "Drop subvolume %llu", root->objectid);
9193 9197
9194 path = btrfs_alloc_path(); 9198 path = btrfs_alloc_path();
9195 if (!path) { 9199 if (!path) {
@@ -9318,7 +9322,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
9318 9322
9319 btrfs_end_transaction_throttle(trans, tree_root); 9323 btrfs_end_transaction_throttle(trans, tree_root);
9320 if (!for_reloc && btrfs_need_cleaner_sleep(root)) { 9324 if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
9321 pr_debug("BTRFS: drop snapshot early exit\n"); 9325 btrfs_debug(fs_info,
9326 "drop snapshot early exit");
9322 err = -EAGAIN; 9327 err = -EAGAIN;
9323 goto out_free; 9328 goto out_free;
9324 } 9329 }
@@ -9384,7 +9389,7 @@ out:
9384 if (!for_reloc && root_dropped == false) 9389 if (!for_reloc && root_dropped == false)
9385 btrfs_add_dead_root(root); 9390 btrfs_add_dead_root(root);
9386 if (err && err != -EAGAIN) 9391 if (err && err != -EAGAIN)
9387 btrfs_handle_fs_error(root->fs_info, err, NULL); 9392 btrfs_handle_fs_error(fs_info, err, NULL);
9388 return err; 9393 return err;
9389} 9394}
9390 9395
@@ -10018,7 +10023,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
10018 if (WARN_ON(space_info->bytes_pinned > 0 || 10023 if (WARN_ON(space_info->bytes_pinned > 0 ||
10019 space_info->bytes_reserved > 0 || 10024 space_info->bytes_reserved > 0 ||
10020 space_info->bytes_may_use > 0)) 10025 space_info->bytes_may_use > 0))
10021 dump_space_info(space_info, 0, 0); 10026 dump_space_info(info, space_info, 0, 0);
10022 list_del(&space_info->list); 10027 list_del(&space_info->list);
10023 for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) { 10028 for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) {
10024 struct kobject *kobj; 10029 struct kobject *kobj;
@@ -10067,7 +10072,8 @@ static void __link_block_group(struct btrfs_space_info *space_info,
10067 10072
10068 return; 10073 return;
10069out_err: 10074out_err:
10070 pr_warn("BTRFS: failed to add kobject for block cache. ignoring.\n"); 10075 btrfs_warn(cache->fs_info,
10076 "failed to add kobject for block cache, ignoring");
10071} 10077}
10072 10078
10073static struct btrfs_block_group_cache * 10079static struct btrfs_block_group_cache *