aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 4ab4b5cdf4b0..03de2466db23 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1533,29 +1533,25 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
1533 reserve_bytes = round_up(write_bytes + sector_offset, 1533 reserve_bytes = round_up(write_bytes + sector_offset,
1534 root->sectorsize); 1534 root->sectorsize);
1535 1535
1536 if (BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | 1536 if ((BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW |
1537 BTRFS_INODE_PREALLOC)) { 1537 BTRFS_INODE_PREALLOC)) &&
1538 ret = check_can_nocow(inode, pos, &write_bytes); 1538 check_can_nocow(inode, pos, &write_bytes) > 0) {
1539 if (ret < 0) 1539 /*
1540 break; 1540 * For nodata cow case, no need to reserve
1541 if (ret > 0) { 1541 * data space.
1542 /* 1542 */
1543 * For nodata cow case, no need to reserve 1543 only_release_metadata = true;
1544 * data space. 1544 /*
1545 */ 1545 * our prealloc extent may be smaller than
1546 only_release_metadata = true; 1546 * write_bytes, so scale down.
1547 /* 1547 */
1548 * our prealloc extent may be smaller than 1548 num_pages = DIV_ROUND_UP(write_bytes + offset,
1549 * write_bytes, so scale down. 1549 PAGE_CACHE_SIZE);
1550 */ 1550 reserve_bytes = round_up(write_bytes + sector_offset,
1551 num_pages = DIV_ROUND_UP(write_bytes + offset, 1551 root->sectorsize);
1552 PAGE_CACHE_SIZE); 1552 goto reserve_metadata;
1553 reserve_bytes = round_up(write_bytes
1554 + sector_offset,
1555 root->sectorsize);
1556 goto reserve_metadata;
1557 }
1558 } 1553 }
1554
1559 ret = btrfs_check_data_free_space(inode, pos, write_bytes); 1555 ret = btrfs_check_data_free_space(inode, pos, write_bytes);
1560 if (ret < 0) 1556 if (ret < 0)
1561 break; 1557 break;