aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2015-02-11 15:08:57 -0500
committerChris Mason <clm@fb.com>2015-02-14 11:19:14 -0500
commit3e05bde8c3c2dd761da4d52944a087907955a53c (patch)
tree42d22d2d53c7764f14ccb0f70c25171b06209fe5 /fs/btrfs
parent13212b54d18d5235fb97fbdcba8ae453fd2a3a51 (diff)
Btrfs: only adjust outstanding_extents when we do a short write
We have this weird dance where we always inc outstanding_extents when we do a O_DIRECT write, even if we allocate the entire range. To get around this we also drop the metadata space if we successfully write. This is an unnecessary dance, we only need to jack up outstanding_extents if we don't satisfy the entire range request in get_blocks_direct, otherwise we are good using our original reservation. So drop the unconditional inc and the drop of the metadata space that we have for the unconditional inc. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/inode.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b0292333fd84..5a5b902e647f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7155,6 +7155,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
7155 u64 start = iblock << inode->i_blkbits; 7155 u64 start = iblock << inode->i_blkbits;
7156 u64 lockstart, lockend; 7156 u64 lockstart, lockend;
7157 u64 len = bh_result->b_size; 7157 u64 len = bh_result->b_size;
7158 u64 orig_len = len;
7158 int unlock_bits = EXTENT_LOCKED; 7159 int unlock_bits = EXTENT_LOCKED;
7159 int ret = 0; 7160 int ret = 0;
7160 7161
@@ -7290,9 +7291,11 @@ unlock:
7290 if (start + len > i_size_read(inode)) 7291 if (start + len > i_size_read(inode))
7291 i_size_write(inode, start + len); 7292 i_size_write(inode, start + len);
7292 7293
7293 spin_lock(&BTRFS_I(inode)->lock); 7294 if (len < orig_len) {
7294 BTRFS_I(inode)->outstanding_extents++; 7295 spin_lock(&BTRFS_I(inode)->lock);
7295 spin_unlock(&BTRFS_I(inode)->lock); 7296 BTRFS_I(inode)->outstanding_extents++;
7297 spin_unlock(&BTRFS_I(inode)->lock);
7298 }
7296 7299
7297 ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, 7300 ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
7298 lockstart + len - 1, EXTENT_DELALLOC, NULL, 7301 lockstart + len - 1, EXTENT_DELALLOC, NULL,
@@ -8073,8 +8076,6 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
8073 else if (ret >= 0 && (size_t)ret < count) 8076 else if (ret >= 0 && (size_t)ret < count)
8074 btrfs_delalloc_release_space(inode, 8077 btrfs_delalloc_release_space(inode,
8075 count - (size_t)ret); 8078 count - (size_t)ret);
8076 else
8077 btrfs_delalloc_release_metadata(inode, 0);
8078 } 8079 }
8079out: 8080out:
8080 if (wakeup) 8081 if (wakeup)