aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2015-03-13 15:12:23 -0400
committerChris Mason <clm@fb.com>2015-03-13 13:46:59 -0700
commit6a41dd0922e3c63e677c2d8f7906ce6a3e097af1 (patch)
tree80d324d61437f08db1e4c67d3255c6eb96965792 /fs/btrfs
parentBtrfs: fix merge delalloc logic (diff)
downloadlinux-dev-6a41dd0922e3c63e677c2d8f7906ce6a3e097af1.tar.xz
linux-dev-6a41dd0922e3c63e677c2d8f7906ce6a3e097af1.zip
Btrfs: account for the correct number of extents for delalloc reservations
Direct IO can easily pass in an buffer that is greater than BTRFS_MAX_EXTENT_SIZE, so take this into account when reserving extents in the delalloc reservation code. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 92146a5afdc1..96c613bfe157 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5110,7 +5110,11 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
num_bytes = ALIGN(num_bytes, root->sectorsize);
spin_lock(&BTRFS_I(inode)->lock);
- BTRFS_I(inode)->outstanding_extents++;
+ nr_extents = (unsigned)div64_u64(num_bytes +
+ BTRFS_MAX_EXTENT_SIZE - 1,
+ BTRFS_MAX_EXTENT_SIZE);
+ BTRFS_I(inode)->outstanding_extents += nr_extents;
+ nr_extents = 0;
if (BTRFS_I(inode)->outstanding_extents >
BTRFS_I(inode)->reserved_extents)