summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason2008-01-31 17:05:37 +0100
committerChris Mason2008-09-25 17:04:00 +0200
commitb0c68f8bed058d9f2023b067b16ed06a8c439544 (patch)
tree71c9024152a9f25f6b446c7e33bf25191cefff69 /fs/btrfs/inode.c
parentbtrfs_drop_extent fixe for inline items > 8K (diff)
downloadkernel-qcow2-linux-b0c68f8bed058d9f2023b067b16ed06a8c439544.tar.gz
kernel-qcow2-linux-b0c68f8bed058d9f2023b067b16ed06a8c439544.tar.xz
kernel-qcow2-linux-b0c68f8bed058d9f2023b067b16ed06a8c439544.zip
Btrfs: Enable delalloc accounting
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index bcf3b35fb65e..f13b1dbc0619 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -260,9 +260,9 @@ static int run_delalloc_range(struct inode *inode, u64 start, u64 end)
}
int btrfs_set_bit_hook(struct inode *inode, u64 start, u64 end,
- unsigned long bits)
+ unsigned long old, unsigned long bits)
{
- if ((bits & EXTENT_DELALLOC)) {
+ if (!(old & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) {
struct btrfs_root *root = BTRFS_I(inode)->root;
spin_lock(&root->fs_info->delalloc_lock);
root->fs_info->delalloc_bytes += end - start + 1;
@@ -272,12 +272,18 @@ int btrfs_set_bit_hook(struct inode *inode, u64 start, u64 end,
}
int btrfs_clear_bit_hook(struct inode *inode, u64 start, u64 end,
- unsigned long bits)
+ unsigned long old, unsigned long bits)
{
- if ((bits & EXTENT_DELALLOC)) {
+ if ((old & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) {
struct btrfs_root *root = BTRFS_I(inode)->root;
spin_lock(&root->fs_info->delalloc_lock);
- root->fs_info->delalloc_bytes -= end - start + 1;
+ if (end - start + 1 > root->fs_info->delalloc_bytes) {
+ printk("warning: delalloc account %Lu %Lu\n",
+ end - start + 1, root->fs_info->delalloc_bytes);
+ root->fs_info->delalloc_bytes = 0;
+ } else {
+ root->fs_info->delalloc_bytes -= end - start + 1;
+ }
spin_unlock(&root->fs_info->delalloc_lock);
}
return 0;
@@ -3002,6 +3008,8 @@ static struct extent_io_ops btrfs_extent_io_ops = {
.writepage_io_hook = btrfs_writepage_io_hook,
.readpage_io_hook = btrfs_readpage_io_hook,
.readpage_end_io_hook = btrfs_readpage_end_io_hook,
+ .set_bit_hook = btrfs_set_bit_hook,
+ .clear_bit_hook = btrfs_clear_bit_hook,
};
static struct address_space_operations btrfs_aops = {