aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-11-04 10:13:23 -0500
committerChris Mason <chris.mason@fusionio.com>2013-11-11 22:13:30 -0500
commitc61a16a701a12659e2933c5965afe8d45284146a (patch)
treeaf5c567b539c9d368e270bd85bd3e8159fecfeea /fs/btrfs
parent18cd8ea6df32e72548a4b055cba54d1a898c81e5 (diff)
Btrfs: fix the confusion between delalloc bytes and metadata bytes
In shrink_delalloc(), what we need reclaim is the metadata space, so flushing pages by to_reclaim is not reasonable, it is very likely that the pages we flush are not enough. And then we had to invoke the flush function for several times, at the worst, we need call flush_space for several times. It wasted time. We improve this problem by converting the metadata space size we need reserve to the delalloc bytes, By this way, we can flush the pages by a reasonable number. (Now we use a fixed number to do conversion, it is not flexible, maybe we can find a good way to improve it in the future.) Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9183f9cbc121..d8da538d01fb 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4034,6 +4034,8 @@ static inline int calc_reclaim_items_nr(struct btrfs_root *root, u64 to_reclaim)
4034 return nr; 4034 return nr;
4035} 4035}
4036 4036
4037#define EXTENT_SIZE_PER_ITEM (256 * 1024)
4038
4037/* 4039/*
4038 * shrink metadata reservation for delalloc 4040 * shrink metadata reservation for delalloc
4039 */ 4041 */
@@ -4050,6 +4052,10 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
4050 int loops; 4052 int loops;
4051 enum btrfs_reserve_flush_enum flush; 4053 enum btrfs_reserve_flush_enum flush;
4052 4054
4055 /* Calc the number of the pages we need flush for space reservation */
4056 to_reclaim = calc_reclaim_items_nr(root, to_reclaim);
4057 to_reclaim *= EXTENT_SIZE_PER_ITEM;
4058
4053 trans = (struct btrfs_trans_handle *)current->journal_info; 4059 trans = (struct btrfs_trans_handle *)current->journal_info;
4054 block_rsv = &root->fs_info->delalloc_block_rsv; 4060 block_rsv = &root->fs_info->delalloc_block_rsv;
4055 space_info = block_rsv->space_info; 4061 space_info = block_rsv->space_info;