aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-11-03 22:54:25 -0400
committerChris Mason <chris.mason@oracle.com>2011-11-06 03:04:18 -0500
commit6d668dda0caec537fbf28c4d91e6d18181af3cff (patch)
treebfc4afce43435e0dc354e58150745fcf2c6072f0 /fs
parentaf31f5e5b84b5bf2bcec464153a5130b170b2770 (diff)
Btrfs: make a delayed_block_rsv for the delayed item insertion
I've been hitting warnings in use_block_rsv when running the delayed insertion stuff. It's because we will readjust global block rsv based on what is in use, which means we could end up discarding reservations that are for the delayed insertion stuff. So instead create a seperate block rsv for the delayed insertion stuff. This will also make it easier to debug problems with the delayed insertion reservations since we will know that only the delayed insertion code touches this block_rsv. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/delayed-inode.c14
-rw-r--r--fs/btrfs/disk-io.c1
-rw-r--r--fs/btrfs/extent-tree.c3
4 files changed, 13 insertions, 7 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 78f43d1102a0..3002e5d4da0b 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -957,6 +957,8 @@ struct btrfs_fs_info {
957 struct btrfs_block_rsv trans_block_rsv; 957 struct btrfs_block_rsv trans_block_rsv;
958 /* block reservation for chunk tree */ 958 /* block reservation for chunk tree */
959 struct btrfs_block_rsv chunk_block_rsv; 959 struct btrfs_block_rsv chunk_block_rsv;
960 /* block reservation for delayed operations */
961 struct btrfs_block_rsv delayed_block_rsv;
960 962
961 struct btrfs_block_rsv empty_block_rsv; 963 struct btrfs_block_rsv empty_block_rsv;
962 964
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index b52c672f4c18..fc4026af7290 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -591,7 +591,7 @@ static int btrfs_delayed_item_reserve_metadata(struct btrfs_trans_handle *trans,
591 return 0; 591 return 0;
592 592
593 src_rsv = trans->block_rsv; 593 src_rsv = trans->block_rsv;
594 dst_rsv = &root->fs_info->global_block_rsv; 594 dst_rsv = &root->fs_info->delayed_block_rsv;
595 595
596 num_bytes = btrfs_calc_trans_metadata_size(root, 1); 596 num_bytes = btrfs_calc_trans_metadata_size(root, 1);
597 ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes); 597 ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
@@ -609,7 +609,7 @@ static void btrfs_delayed_item_release_metadata(struct btrfs_root *root,
609 if (!item->bytes_reserved) 609 if (!item->bytes_reserved)
610 return; 610 return;
611 611
612 rsv = &root->fs_info->global_block_rsv; 612 rsv = &root->fs_info->delayed_block_rsv;
613 btrfs_block_rsv_release(root, rsv, 613 btrfs_block_rsv_release(root, rsv,
614 item->bytes_reserved); 614 item->bytes_reserved);
615} 615}
@@ -628,7 +628,7 @@ static int btrfs_delayed_inode_reserve_metadata(
628 return 0; 628 return 0;
629 629
630 src_rsv = trans->block_rsv; 630 src_rsv = trans->block_rsv;
631 dst_rsv = &root->fs_info->global_block_rsv; 631 dst_rsv = &root->fs_info->delayed_block_rsv;
632 632
633 num_bytes = btrfs_calc_trans_metadata_size(root, 1); 633 num_bytes = btrfs_calc_trans_metadata_size(root, 1);
634 ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes); 634 ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
@@ -646,7 +646,7 @@ static void btrfs_delayed_inode_release_metadata(struct btrfs_root *root,
646 if (!node->bytes_reserved) 646 if (!node->bytes_reserved)
647 return; 647 return;
648 648
649 rsv = &root->fs_info->global_block_rsv; 649 rsv = &root->fs_info->delayed_block_rsv;
650 btrfs_block_rsv_release(root, rsv, 650 btrfs_block_rsv_release(root, rsv,
651 node->bytes_reserved); 651 node->bytes_reserved);
652 node->bytes_reserved = 0; 652 node->bytes_reserved = 0;
@@ -1026,7 +1026,7 @@ int btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
1026 path->leave_spinning = 1; 1026 path->leave_spinning = 1;
1027 1027
1028 block_rsv = trans->block_rsv; 1028 block_rsv = trans->block_rsv;
1029 trans->block_rsv = &root->fs_info->global_block_rsv; 1029 trans->block_rsv = &root->fs_info->delayed_block_rsv;
1030 1030
1031 delayed_root = btrfs_get_delayed_root(root); 1031 delayed_root = btrfs_get_delayed_root(root);
1032 1032
@@ -1069,7 +1069,7 @@ static int __btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans,
1069 path->leave_spinning = 1; 1069 path->leave_spinning = 1;
1070 1070
1071 block_rsv = trans->block_rsv; 1071 block_rsv = trans->block_rsv;
1072 trans->block_rsv = &node->root->fs_info->global_block_rsv; 1072 trans->block_rsv = &node->root->fs_info->delayed_block_rsv;
1073 1073
1074 ret = btrfs_insert_delayed_items(trans, path, node->root, node); 1074 ret = btrfs_insert_delayed_items(trans, path, node->root, node);
1075 if (!ret) 1075 if (!ret)
@@ -1149,7 +1149,7 @@ static void btrfs_async_run_delayed_node_done(struct btrfs_work *work)
1149 goto free_path; 1149 goto free_path;
1150 1150
1151 block_rsv = trans->block_rsv; 1151 block_rsv = trans->block_rsv;
1152 trans->block_rsv = &root->fs_info->global_block_rsv; 1152 trans->block_rsv = &root->fs_info->delayed_block_rsv;
1153 1153
1154 ret = btrfs_insert_delayed_items(trans, path, root, delayed_node); 1154 ret = btrfs_insert_delayed_items(trans, path, root, delayed_node);
1155 if (!ret) 1155 if (!ret)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index a61f8a6cf219..23b6776477b7 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1891,6 +1891,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1891 btrfs_init_block_rsv(&fs_info->trans_block_rsv); 1891 btrfs_init_block_rsv(&fs_info->trans_block_rsv);
1892 btrfs_init_block_rsv(&fs_info->chunk_block_rsv); 1892 btrfs_init_block_rsv(&fs_info->chunk_block_rsv);
1893 btrfs_init_block_rsv(&fs_info->empty_block_rsv); 1893 btrfs_init_block_rsv(&fs_info->empty_block_rsv);
1894 btrfs_init_block_rsv(&fs_info->delayed_block_rsv);
1894 atomic_set(&fs_info->nr_async_submits, 0); 1895 atomic_set(&fs_info->nr_async_submits, 0);
1895 atomic_set(&fs_info->async_delalloc_pages, 0); 1896 atomic_set(&fs_info->async_delalloc_pages, 0);
1896 atomic_set(&fs_info->async_submit_draining, 0); 1897 atomic_set(&fs_info->async_submit_draining, 0);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 782eb3ea8edf..01c1f08b976a 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3914,6 +3914,7 @@ static void init_global_block_rsv(struct btrfs_fs_info *fs_info)
3914 fs_info->delalloc_block_rsv.space_info = space_info; 3914 fs_info->delalloc_block_rsv.space_info = space_info;
3915 fs_info->trans_block_rsv.space_info = space_info; 3915 fs_info->trans_block_rsv.space_info = space_info;
3916 fs_info->empty_block_rsv.space_info = space_info; 3916 fs_info->empty_block_rsv.space_info = space_info;
3917 fs_info->delayed_block_rsv.space_info = space_info;
3917 3918
3918 fs_info->extent_root->block_rsv = &fs_info->global_block_rsv; 3919 fs_info->extent_root->block_rsv = &fs_info->global_block_rsv;
3919 fs_info->csum_root->block_rsv = &fs_info->global_block_rsv; 3920 fs_info->csum_root->block_rsv = &fs_info->global_block_rsv;
@@ -3933,6 +3934,8 @@ static void release_global_block_rsv(struct btrfs_fs_info *fs_info)
3933 WARN_ON(fs_info->trans_block_rsv.reserved > 0); 3934 WARN_ON(fs_info->trans_block_rsv.reserved > 0);
3934 WARN_ON(fs_info->chunk_block_rsv.size > 0); 3935 WARN_ON(fs_info->chunk_block_rsv.size > 0);
3935 WARN_ON(fs_info->chunk_block_rsv.reserved > 0); 3936 WARN_ON(fs_info->chunk_block_rsv.reserved > 0);
3937 WARN_ON(fs_info->delayed_block_rsv.size > 0);
3938 WARN_ON(fs_info->delayed_block_rsv.reserved > 0);
3936} 3939}
3937 3940
3938void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans, 3941void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,