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 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 |
