summaryrefslogtreecommitdiffstats
path: root/kernel/fs/btrfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/fs/btrfs/inode.c')
-rw-r--r--kernel/fs/btrfs/inode.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/fs/btrfs/inode.c b/kernel/fs/btrfs/inode.c
index 4bc9dbf29..3cff6523f 100644
--- a/kernel/fs/btrfs/inode.c
+++ b/kernel/fs/btrfs/inode.c
@@ -8691,9 +8691,14 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,
* So even we call qgroup_free_data(), it won't decrease reserved
* space.
* 2) Not written to disk
- * This means the reserved space should be freed here.
+ * This means the reserved space should be freed here. However,
+ * if a truncate invalidates the page (by clearing PageDirty)
+ * and the page is accounted for while allocating extent
+ * in btrfs_check_data_free_space() we let delayed_ref to
+ * free the entire extent.
*/
- btrfs_qgroup_free_data(inode, page_start, PAGE_CACHE_SIZE);
+ if (PageDirty(page))
+ btrfs_qgroup_free_data(inode, page_start, PAGE_SIZE);
if (!inode_evicting) {
clear_extent_bit(tree, page_start, page_end,
EXTENT_LOCKED | EXTENT_DIRTY |