diff options
author | Josef Bacik <josef@redhat.com> | 2010-10-15 15:18:40 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2010-10-22 15:54:58 -0400 |
commit | 0019f10db6f596f3e14a19f9bd7059a1b85b0853 (patch) | |
tree | 9f295bc2e335a6890ea29bc0830bda43903671d9 /fs/btrfs/inode.c | |
parent | 6d48755d02b150de7f47e7b4753202f2fc9f990f (diff) |
Btrfs: re-work delalloc flushing
Currently we try and flush delalloc, but we only do that in a sort of weak way,
which works fine in most cases but if we're under heavy pressure we need to be
able to wait for flushing to happen. Also instead of checking the bytes
reserved in the block_rsv, check the space info since it is more accurate. The
sync option will be used in a future patch.
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 1bff92ad4744..5f9e4fc20a73 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -6603,7 +6603,8 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput) | |||
6603 | return 0; | 6603 | return 0; |
6604 | } | 6604 | } |
6605 | 6605 | ||
6606 | int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput) | 6606 | int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput, |
6607 | int sync) | ||
6607 | { | 6608 | { |
6608 | struct btrfs_inode *binode; | 6609 | struct btrfs_inode *binode; |
6609 | struct inode *inode = NULL; | 6610 | struct inode *inode = NULL; |
@@ -6625,7 +6626,26 @@ int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput) | |||
6625 | spin_unlock(&root->fs_info->delalloc_lock); | 6626 | spin_unlock(&root->fs_info->delalloc_lock); |
6626 | 6627 | ||
6627 | if (inode) { | 6628 | if (inode) { |
6628 | write_inode_now(inode, 0); | 6629 | if (sync) { |
6630 | filemap_write_and_wait(inode->i_mapping); | ||
6631 | /* | ||
6632 | * We have to do this because compression doesn't | ||
6633 | * actually set PG_writeback until it submits the pages | ||
6634 | * for IO, which happens in an async thread, so we could | ||
6635 | * race and not actually wait for any writeback pages | ||
6636 | * because they've not been submitted yet. Technically | ||
6637 | * this could still be the case for the ordered stuff | ||
6638 | * since the async thread may not have started to do its | ||
6639 | * work yet. If this becomes the case then we need to | ||
6640 | * figure out a way to make sure that in writepage we | ||
6641 | * wait for any async pages to be submitted before | ||
6642 | * returning so that fdatawait does what its supposed to | ||
6643 | * do. | ||
6644 | */ | ||
6645 | btrfs_wait_ordered_range(inode, 0, (u64)-1); | ||
6646 | } else { | ||
6647 | filemap_flush(inode->i_mapping); | ||
6648 | } | ||
6629 | if (delay_iput) | 6649 | if (delay_iput) |
6630 | btrfs_add_delayed_iput(inode); | 6650 | btrfs_add_delayed_iput(inode); |
6631 | else | 6651 | else |