|
@@ -1596,6 +1596,13 @@ again:
|
|
|
|
|
|
copied = btrfs_copy_from_user(pos, write_bytes, pages, i);
|
|
copied = btrfs_copy_from_user(pos, write_bytes, pages, i);
|
|
|
|
|
|
|
|
+ num_sectors = BTRFS_BYTES_TO_BLKS(root->fs_info,
|
|
|
|
+ reserve_bytes);
|
|
|
|
+ dirty_sectors = round_up(copied + sector_offset,
|
|
|
|
+ root->sectorsize);
|
|
|
|
+ dirty_sectors = BTRFS_BYTES_TO_BLKS(root->fs_info,
|
|
|
|
+ dirty_sectors);
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* if we have trouble faulting in the pages, fall
|
|
* if we have trouble faulting in the pages, fall
|
|
* back to one page at a time
|
|
* back to one page at a time
|
|
@@ -1605,6 +1612,7 @@ again:
|
|
|
|
|
|
if (copied == 0) {
|
|
if (copied == 0) {
|
|
force_page_uptodate = true;
|
|
force_page_uptodate = true;
|
|
|
|
+ dirty_sectors = 0;
|
|
dirty_pages = 0;
|
|
dirty_pages = 0;
|
|
} else {
|
|
} else {
|
|
force_page_uptodate = false;
|
|
force_page_uptodate = false;
|
|
@@ -1615,20 +1623,19 @@ again:
|
|
/*
|
|
/*
|
|
* If we had a short copy we need to release the excess delaloc
|
|
* If we had a short copy we need to release the excess delaloc
|
|
* bytes we reserved. We need to increment outstanding_extents
|
|
* bytes we reserved. We need to increment outstanding_extents
|
|
- * because btrfs_delalloc_release_space will decrement it, but
|
|
|
|
|
|
+ * because btrfs_delalloc_release_space and
|
|
|
|
+ * btrfs_delalloc_release_metadata will decrement it, but
|
|
* we still have an outstanding extent for the chunk we actually
|
|
* we still have an outstanding extent for the chunk we actually
|
|
* managed to copy.
|
|
* managed to copy.
|
|
*/
|
|
*/
|
|
- num_sectors = BTRFS_BYTES_TO_BLKS(root->fs_info,
|
|
|
|
- reserve_bytes);
|
|
|
|
- dirty_sectors = round_up(copied + sector_offset,
|
|
|
|
- root->sectorsize);
|
|
|
|
- dirty_sectors = BTRFS_BYTES_TO_BLKS(root->fs_info,
|
|
|
|
- dirty_sectors);
|
|
|
|
-
|
|
|
|
if (num_sectors > dirty_sectors) {
|
|
if (num_sectors > dirty_sectors) {
|
|
- release_bytes = (write_bytes - copied)
|
|
|
|
- & ~((u64)root->sectorsize - 1);
|
|
|
|
|
|
+ /*
|
|
|
|
+ * we round down because we don't want to count
|
|
|
|
+ * any partial blocks actually sent through the
|
|
|
|
+ * IO machines
|
|
|
|
+ */
|
|
|
|
+ release_bytes = round_down(release_bytes - copied,
|
|
|
|
+ root->sectorsize);
|
|
if (copied > 0) {
|
|
if (copied > 0) {
|
|
spin_lock(&BTRFS_I(inode)->lock);
|
|
spin_lock(&BTRFS_I(inode)->lock);
|
|
BTRFS_I(inode)->outstanding_extents++;
|
|
BTRFS_I(inode)->outstanding_extents++;
|