summaryrefslogtreecommitdiff
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-01-04 13:42:16 +0300
committerDavid Sterba <dsterba@suse.com>2017-01-04 13:42:16 +0300
commit3dda13a8ad787f3d4c4f18c8c05f8eebc7ea135a (patch)
treee427359939b7ae3c7ef9eda9839ca3ccd0739b98 /fs/btrfs/inode.c
parent2939e1a86f758b55cdba73e29397dd3d94df13bc (diff)
parentc2931667c83ded6504b3857e99cc45b21fa496fb (diff)
downloadlinux-3dda13a8ad787f3d4c4f18c8c05f8eebc7ea135a.tar.xz
Merge branch 'misc-4.10' into for-chris-4.10-20170104
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a713d9d324b0..81b9d9d0450c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7623,11 +7623,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode,
* within our reservation, otherwise we need to adjust our inode
* counter appropriately.
*/
- if (dio_data->outstanding_extents) {
+ if (dio_data->outstanding_extents >= num_extents) {
dio_data->outstanding_extents -= num_extents;
} else {
+ /*
+ * If dio write length has been split due to no large enough
+ * contiguous space, we need to compensate our inode counter
+ * appropriately.
+ */
+ u64 num_needed = num_extents - dio_data->outstanding_extents;
+
spin_lock(&BTRFS_I(inode)->lock);
- BTRFS_I(inode)->outstanding_extents += num_extents;
+ BTRFS_I(inode)->outstanding_extents += num_needed;
spin_unlock(&BTRFS_I(inode)->lock);
}
}