summary refs log tree commit diff
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2010-05-25 20:56:50 -0400
committerChris Mason <chris.mason@oracle.com>2010-05-25 21:52:08 -0400
commit4845e44ffdb26be9b25610664228e8ecaf949a0d (patch)
tree8852e175b6b02a36df6b47c54d574f3365ddb34f /fs/btrfs/file.c
parenteaf25d933e64c2bf3c79b83e8820404f36fdfc52 (diff)
downloadlinux-4845e44ffdb26be9b25610664228e8ecaf949a0d.tar.gz
Btrfs: rework O_DIRECT enospc handling
This changes O_DIRECT write code to mark extents as delalloc
while it is processing them.  Yan Zheng has reworked the
enospc accounting based on tracking delalloc extents and
this makes it much easier to track enospc in the O_DIRECT code.

There are a few space cases with the O_DIRECT code though,
it only sets the EXTENT_DELALLOC bits, instead of doing
EXTENT_DELALLOC | EXTENT_DIRTY | EXTENT_UPTODATE, because
we don't want to mess with clearing the dirty and uptodate
bits when things go wrong.  This is important because there
are no pages in the page cache, so any extent state structs
that we put in the tree won't get freed by releasepage.  We have
to clear them ourselves as the DIO ends.

With this commit, we reserve space at in btrfs_file_aio_write,
and then as each btrfs_direct_IO call progresses it sets
EXTENT_DELALLOC on the range.

btrfs_get_blocks_direct is responsible for clearing the delalloc
at the same time it drops the extent lock.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c14
1 files changed, 0 insertions, 14 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 233aea2e5ef2..54556cae4497 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -909,13 +909,6 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
 		}
 
 		if (num_written < 0) {
-			if (num_written != -EIOCBQUEUED) {
-				/*
-				 * aio land will take care of releasing the
-				 * delalloc
-				 */
-				btrfs_delalloc_release_space(inode, count);
-			}
 			ret = num_written;
 			num_written = 0;
 			goto out;
@@ -924,13 +917,6 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
 			pos = *ppos;
 			goto out;
 		}
-
-		/*
-		 * the buffered IO will reserve bytes for the rest of the
-		 * range, don't double count them here
-		 */
-		btrfs_delalloc_release_space(inode, count - num_written);
-
 		/*
 		 * We are going to do buffered for the rest of the range, so we
 		 * need to make sure to invalidate the buffered pages when we're