Btrfs: Metadata ENOSPC handling for tree log
PATCH v2 10/12 Btrfs: Metadata ENOSPC handling for tree log
Previous patches make the allocater return -ENOSPC if there is no unreserved free metadata space. This patch updates tree log code and various other places to propagate/handle the ENOSPC error.
Signed-off-by Yan Zheng <[email protected]>
---
fs/btrfs/disk-io.c +0 -36
@@ -973,42 +973,6 @@ static int find_and_setup_root(struct btreturn 0 ; } -int btrfs_free_log_root_tree (struct btrfs_trans_handle *trans, -struct btrfs_fs_info *fs_info) -{ -struct extent_buffer *eb; -struct btrfs_root *log_root_tree = fs_info->log_root_tree; -u64 start =0 ; -u64 end =0 ; -int ret; - -if (!log_root_tree) -return 0 ; - -while (1 ) { - ret =find_first_extent_bit (&log_root_tree->dirty_log_pages, -0 , &start, &end,EXTENT_DIRTY |EXTENT_NEW ); -if (ret) -break ; - -clear_extent_bits (&log_root_tree->dirty_log_pages, start, end, -EXTENT_DIRTY |EXTENT_NEW ,GFP_NOFS ); - } - eb = fs_info->log_root_tree->node; - -WARN_ON (btrfs_header_level (eb) !=0 ); -WARN_ON (btrfs_header_nritems (eb) !=0 ); - - ret =btrfs_free_reserved_extent (fs_info->tree_root, - eb->start, eb->len); -BUG_ON (ret); - -free_extent_buffer (eb); -kfree (fs_info->log_root_tree); - fs_info->log_root_tree =NULL ; -return 0 ; -} -static struct btrfs_root *alloc_log_tree (struct btrfs_trans_handle *trans,struct btrfs_fs_info *fs_info) {
fs/btrfs/disk-io.h +0 -2
@@ -95,8 +95,6 @@ int btrfs_congested_async(struct btrfs_funsigned long btrfs_async_submit_limit (struct btrfs_fs_info *info);int btrfs_write_tree_block (struct extent_buffer *buf);int btrfs_wait_tree_block_writeback (struct extent_buffer *buf); -int btrfs_free_log_root_tree (struct btrfs_trans_handle *trans, -struct btrfs_fs_info *fs_info);int btrfs_init_log_root_tree (struct btrfs_trans_handle *trans,struct btrfs_fs_info *fs_info); int btrfs_add_log_tree(struct btrfs_trans_handle *trans,
fs/btrfs/file-item.c +3 -0
@@ -656,6 +656,9 @@ again: goto found; } ret =PTR_ERR (item); +if (ret != -EFBIG && ret != -ENOENT ) + goto fail_unlock; +if (ret == -EFBIG ) {u32 item_size;/* we found one, but it isn't big enough yet */
fs/btrfs/tree-log.c +151 -90
506 lines not on this page · raw message
fs/btrfs/tree-log.h +2 -0
@@ -25,6 +25,8 @@int btrfs_sync_log (struct btrfs_trans_handle *trans,struct btrfs_root *root);int btrfs_free_log (struct btrfs_trans_handle *trans,struct btrfs_root *root); +int btrfs_free_log_root_tree (struct btrfs_trans_handle *trans, +struct btrfs_fs_info *fs_info);int btrfs_recover_log_trees (struct btrfs_root *tree_root);int btrfs_log_dentry_safe (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct dentry *dentry);