Skip to content

Commit 485290a

Browse files
Qu Wenruomasoncl
authored andcommitted
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: Qu Wenruo <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 90ce321 commit 485290a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fs/btrfs/file.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,12 +1604,17 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
16041604
BTRFS_I(inode)->outstanding_extents++;
16051605
spin_unlock(&BTRFS_I(inode)->lock);
16061606
}
1607-
if (only_release_metadata)
1607+
if (only_release_metadata) {
16081608
btrfs_delalloc_release_metadata(inode,
16091609
release_bytes);
1610-
else
1611-
btrfs_delalloc_release_space(inode, pos,
1610+
} else {
1611+
u64 __pos;
1612+
1613+
__pos = round_down(pos, root->sectorsize) +
1614+
(dirty_pages << PAGE_CACHE_SHIFT);
1615+
btrfs_delalloc_release_space(inode, __pos,
16121616
release_bytes);
1617+
}
16131618
}
16141619

16151620
release_bytes = dirty_pages << PAGE_CACHE_SHIFT;

0 commit comments

Comments
 (0)