Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 485290a7 authored by Qu Wenruo's avatar Qu Wenruo Committed by Chris Mason
Browse files

btrfs: Fix a data space underflow warning



Even with quota disabled, generic/127 will trigger a kernel warning by
underflow data space info.

The bug is caused by buffered write, which in case of short copy, the
start parameter for btrfs_delalloc_release_space() is wrong, and
round_up/down() in btrfs_delalloc_release() extents the range to page
aligned, decreasing one more page than expected.

This patch will fix it by passing correct start.

Signed-off-by: default avatarQu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 90ce321d
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -1604,13 +1604,18 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
				BTRFS_I(inode)->outstanding_extents++;
				spin_unlock(&BTRFS_I(inode)->lock);
			}
			if (only_release_metadata)
			if (only_release_metadata) {
				btrfs_delalloc_release_metadata(inode,
								release_bytes);
			else
				btrfs_delalloc_release_space(inode, pos,
			} else {
				u64 __pos;

				__pos = round_down(pos, root->sectorsize) +
					(dirty_pages << PAGE_CACHE_SHIFT);
				btrfs_delalloc_release_space(inode, __pos,
							     release_bytes);
			}
		}

		release_bytes = dirty_pages << PAGE_CACHE_SHIFT;