diff options
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 89f5be2bfb43..58a18ed11546 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "volumes.h" | 26 | #include "volumes.h" |
27 | #include "qgroup.h" | 27 | #include "qgroup.h" |
28 | #include "compression.h" | 28 | #include "compression.h" |
29 | #include "delalloc-space.h" | ||
29 | 30 | ||
30 | static struct kmem_cache *btrfs_inode_defrag_cachep; | 31 | static struct kmem_cache *btrfs_inode_defrag_cachep; |
31 | /* | 32 | /* |
@@ -1550,30 +1551,20 @@ static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos, | |||
1550 | { | 1551 | { |
1551 | struct btrfs_fs_info *fs_info = inode->root->fs_info; | 1552 | struct btrfs_fs_info *fs_info = inode->root->fs_info; |
1552 | struct btrfs_root *root = inode->root; | 1553 | struct btrfs_root *root = inode->root; |
1553 | struct btrfs_ordered_extent *ordered; | ||
1554 | u64 lockstart, lockend; | 1554 | u64 lockstart, lockend; |
1555 | u64 num_bytes; | 1555 | u64 num_bytes; |
1556 | int ret; | 1556 | int ret; |
1557 | 1557 | ||
1558 | ret = btrfs_start_write_no_snapshotting(root); | 1558 | ret = btrfs_start_write_no_snapshotting(root); |
1559 | if (!ret) | 1559 | if (!ret) |
1560 | return -ENOSPC; | 1560 | return -EAGAIN; |
1561 | 1561 | ||
1562 | lockstart = round_down(pos, fs_info->sectorsize); | 1562 | lockstart = round_down(pos, fs_info->sectorsize); |
1563 | lockend = round_up(pos + *write_bytes, | 1563 | lockend = round_up(pos + *write_bytes, |
1564 | fs_info->sectorsize) - 1; | 1564 | fs_info->sectorsize) - 1; |
1565 | 1565 | ||
1566 | while (1) { | 1566 | btrfs_lock_and_flush_ordered_range(&inode->io_tree, inode, lockstart, |
1567 | lock_extent(&inode->io_tree, lockstart, lockend); | 1567 | lockend, NULL); |
1568 | ordered = btrfs_lookup_ordered_range(inode, lockstart, | ||
1569 | lockend - lockstart + 1); | ||
1570 | if (!ordered) { | ||
1571 | break; | ||
1572 | } | ||
1573 | unlock_extent(&inode->io_tree, lockstart, lockend); | ||
1574 | btrfs_start_ordered_extent(&inode->vfs_inode, ordered, 1); | ||
1575 | btrfs_put_ordered_extent(ordered); | ||
1576 | } | ||
1577 | 1568 | ||
1578 | num_bytes = lockend - lockstart + 1; | 1569 | num_bytes = lockend - lockstart + 1; |
1579 | ret = can_nocow_extent(&inode->vfs_inode, lockstart, &num_bytes, | 1570 | ret = can_nocow_extent(&inode->vfs_inode, lockstart, &num_bytes, |
@@ -2721,6 +2712,11 @@ out_only_mutex: | |||
2721 | * for detecting, at fsync time, if the inode isn't yet in the | 2712 | * for detecting, at fsync time, if the inode isn't yet in the |
2722 | * log tree or it's there but not up to date. | 2713 | * log tree or it's there but not up to date. |
2723 | */ | 2714 | */ |
2715 | struct timespec64 now = current_time(inode); | ||
2716 | |||
2717 | inode_inc_iversion(inode); | ||
2718 | inode->i_mtime = now; | ||
2719 | inode->i_ctime = now; | ||
2724 | trans = btrfs_start_transaction(root, 1); | 2720 | trans = btrfs_start_transaction(root, 1); |
2725 | if (IS_ERR(trans)) { | 2721 | if (IS_ERR(trans)) { |
2726 | err = PTR_ERR(trans); | 2722 | err = PTR_ERR(trans); |
@@ -2801,9 +2797,9 @@ static int btrfs_fallocate_update_isize(struct inode *inode, | |||
2801 | } | 2797 | } |
2802 | 2798 | ||
2803 | enum { | 2799 | enum { |
2804 | RANGE_BOUNDARY_WRITTEN_EXTENT = 0, | 2800 | RANGE_BOUNDARY_WRITTEN_EXTENT, |
2805 | RANGE_BOUNDARY_PREALLOC_EXTENT = 1, | 2801 | RANGE_BOUNDARY_PREALLOC_EXTENT, |
2806 | RANGE_BOUNDARY_HOLE = 2, | 2802 | RANGE_BOUNDARY_HOLE, |
2807 | }; | 2803 | }; |
2808 | 2804 | ||
2809 | static int btrfs_zero_range_check_range_boundary(struct inode *inode, | 2805 | static int btrfs_zero_range_check_range_boundary(struct inode *inode, |