aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-01-29 05:10:51 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-02-20 12:59:05 -0500
commit963d678b0f7649300e3a67f2513ca9d830c6e303 (patch)
tree4f7568f541891a7bbe8b279c98d21aec1cabe06f /fs/btrfs/extent-tree.c
parente2d845211eda9cf296e8edf6724b3d541f4fbfd5 (diff)
Btrfs: use percpu counter for fs_info->delalloc_bytes
fs_info->delalloc_bytes is accessed very frequently, so use percpu counter instead of the u64 variant for it to reduce the lock contention. This patch also fixed the problem that we access the variant without the lock protection.At worst, we would not flush the delalloc inodes, and just return ENOSPC error when we still have some free space in the fs. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 174c4d5c692c..115d1646bf50 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3760,7 +3760,8 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
3760 space_info = block_rsv->space_info; 3760 space_info = block_rsv->space_info;
3761 3761
3762 smp_mb(); 3762 smp_mb();
3763 delalloc_bytes = root->fs_info->delalloc_bytes; 3763 delalloc_bytes = percpu_counter_sum_positive(
3764 &root->fs_info->delalloc_bytes);
3764 if (delalloc_bytes == 0) { 3765 if (delalloc_bytes == 0) {
3765 if (trans) 3766 if (trans)
3766 return; 3767 return;
@@ -3799,7 +3800,8 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
3799 break; 3800 break;
3800 } 3801 }
3801 smp_mb(); 3802 smp_mb();
3802 delalloc_bytes = root->fs_info->delalloc_bytes; 3803 delalloc_bytes = percpu_counter_sum_positive(
3804 &root->fs_info->delalloc_bytes);
3803 } 3805 }
3804} 3806}
3805 3807