summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/file.c5
-rw-r--r--fs/btrfs/inode.c9
2 files changed, 8 insertions, 6 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 54556ca..79437c5 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -888,14 +888,9 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
BTRFS_I(inode)->sequence++;
if (unlikely(file->f_flags & O_DIRECT)) {
- ret = btrfs_delalloc_reserve_space(inode, count);
- if (ret)
- goto out;
-
num_written = generic_file_direct_write(iocb, iov, &nr_segs,
pos, ppos, count,
ocount);
-
/*
* the generic O_DIRECT will update in-memory i_size after the
* DIOs are done. But our endio handlers that update the on
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 00aefbd..ca9d550 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5602,9 +5602,16 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
ssize_t ret;
int writing = rw & WRITE;
int write_bits = 0;
+ size_t count = iov_length(iov, nr_segs);
lockstart = offset;
- lockend = offset + iov_length(iov, nr_segs) - 1;
+ lockend = offset + count - 1;
+
+ if (writing) {
+ ret = btrfs_delalloc_reserve_space(inode, count);
+ if (ret)
+ goto out;
+ }
while (1) {
lock_extent_bits(&BTRFS_I(inode)->io_tree, lockstart, lockend,
OpenPOWER on IntegriCloud