]> git.hungrycats.org Git - linux/commitdiff
Btrfs: account for the correct number of extents for delalloc reservations
authorJosef Bacik <jbacik@fb.com>
Fri, 13 Mar 2015 19:07:45 +0000 (15:07 -0400)
committerJosef Bacik <jbacik@fb.com>
Mon, 16 Mar 2015 20:28:09 +0000 (16:28 -0400)
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>
fs/btrfs/extent-tree.c

index 0e9b3b2b6553657af86ecb114525bbdc6d1b41d5..3ac3fefb16252fb99ae02255fc9a6e1c9762e5f3 100644 (file)
@@ -5136,7 +5136,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)