summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason2008-01-30 20:33:02 +0100
committerChris Mason2008-09-25 17:04:00 +0200
commit1b0f7c29e2f4f41e1367e7581d3a9c8c70f0394a (patch)
treecc9b9b7282496d521b8ed43cc45848b31ed9d717
parentProperly align the hole size in btrfs_setattr (diff)
downloadkernel-qcow2-linux-1b0f7c29e2f4f41e1367e7581d3a9c8c70f0394a.tar.gz
kernel-qcow2-linux-1b0f7c29e2f4f41e1367e7581d3a9c8c70f0394a.tar.xz
kernel-qcow2-linux-1b0f7c29e2f4f41e1367e7581d3a9c8c70f0394a.zip
Fix hole start calculation in btrfs_settar
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/inode.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 515f8b01ab04..bcf3b35fb65e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1000,20 +1000,14 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
u64 mask = root->sectorsize - 1;
- u64 pos = (inode->i_size + mask) & ~mask;
+ u64 hole_start = (inode->i_size + mask) & ~mask;
u64 block_end = (attr->ia_size + mask) & ~mask;
- u64 hole_start;
u64 hole_size;
u64 alloc_hint = 0;
- if (attr->ia_size <= pos)
+ if (attr->ia_size <= hole_start)
goto out;
- if (pos != inode->i_size)
- hole_start = pos + root->sectorsize;
- else
- hole_start = pos;
-
mutex_lock(&root->fs_info->fs_mutex);
err = btrfs_check_free_space(root, 1, 0);
mutex_unlock(&root->fs_info->fs_mutex);
@@ -1022,14 +1016,14 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
btrfs_truncate_page(inode->i_mapping, inode->i_size);
- lock_extent(io_tree, pos, block_end - 1, GFP_NOFS);
+ lock_extent(io_tree, hole_start, block_end - 1, GFP_NOFS);
hole_size = block_end - hole_start;
mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
btrfs_set_trans_block_group(trans, inode);
err = btrfs_drop_extents(trans, root, inode,
- pos, block_end, pos,
+ hole_start, block_end, hole_start,
&alloc_hint);
if (alloc_hint != EXTENT_MAP_INLINE) {
@@ -1043,7 +1037,7 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
}
btrfs_end_transaction(trans, root);
mutex_unlock(&root->fs_info->fs_mutex);
- unlock_extent(io_tree, pos, block_end - 1, GFP_NOFS);
+ unlock_extent(io_tree, hole_start, block_end - 1, GFP_NOFS);
if (err)
return err;
}