diff options
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 f2fb974ed8f0..9f08136b10c4 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -6681,7 +6681,8 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput) | |||
| 6681 | return 0; | 6681 | return 0; |
| 6682 | } | 6682 | } |
| 6683 | 6683 | ||
| 6684 | int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput) | 6684 | int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput, |
| 6685 | int sync) | ||
| 6685 | { | 6686 | { |
| 6686 | struct btrfs_inode *binode; | 6687 | struct btrfs_inode *binode; |
| 6687 | struct inode *inode = NULL; | 6688 | struct inode *inode = NULL; |
| @@ -6703,7 +6704,26 @@ int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput) | |||
| 6703 | spin_unlock(&root->fs_info->delalloc_lock); | 6704 | spin_unlock(&root->fs_info->delalloc_lock); |
| 6704 | 6705 | ||
| 6705 | if (inode) { | 6706 | if (inode) { |
| 6706 | write_inode_now(inode, 0); | 6707 | if (sync) { |
| 6708 | filemap_write_and_wait(inode->i_mapping); | ||
| 6709 | /* | ||
| 6710 | * We have to do this because compression doesn't | ||
| 6711 | * actually set PG_writeback until it submits the pages | ||
| 6712 | * for IO, which happens in an async thread, so we could | ||
| 6713 | * race and not actually wait for any writeback pages | ||
| 6714 | * because they've not been submitted yet. Technically | ||
| 6715 | * this could still be the case for the ordered stuff | ||
| 6716 | * since the async thread may not have started to do its | ||
| 6717 | * work yet. If this becomes the case then we need to | ||
| 6718 | * figure out a way to make sure that in writepage we | ||
| 6719 | * wait for any async pages to be submitted before | ||
| 6720 | * returning so that fdatawait does what its supposed to | ||
| 6721 | * do. | ||
| 6722 | */ | ||
| 6723 | btrfs_wait_ordered_range(inode, 0, (u64)-1); | ||
| 6724 | } else { | ||
| 6725 | filemap_flush(inode->i_mapping); | ||
| 6726 | } | ||
| 6707 | if (delay_iput) | 6727 | if (delay_iput) |
| 6708 | btrfs_add_delayed_iput(inode); | 6728 | btrfs_add_delayed_iput(inode); |
| 6709 | else | 6729 | else |
