Commit b19d307d authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix i_sectors_leak in bch2_truncate_page

When bch2_truncate_page() discards dirty sectors in the page cache, we
need to account for that - we don't need to account for allocated
sectors because that'll be done by the bch2_fpunch() call when it
updates the btree.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 8810386f
...@@ -2241,6 +2241,7 @@ static int __bch2_truncate_page(struct bch_inode_info *inode, ...@@ -2241,6 +2241,7 @@ static int __bch2_truncate_page(struct bch_inode_info *inode,
unsigned end_offset = ((end - 1) & (PAGE_SIZE - 1)) + 1; unsigned end_offset = ((end - 1) & (PAGE_SIZE - 1)) + 1;
unsigned i; unsigned i;
struct page *page; struct page *page;
s64 i_sectors_delta = 0;
int ret = 0; int ret = 0;
/* Page boundary? Nothing to do */ /* Page boundary? Nothing to do */
...@@ -2292,9 +2293,13 @@ static int __bch2_truncate_page(struct bch_inode_info *inode, ...@@ -2292,9 +2293,13 @@ static int __bch2_truncate_page(struct bch_inode_info *inode,
i < round_down(end_offset, block_bytes(c)) >> 9; i < round_down(end_offset, block_bytes(c)) >> 9;
i++) { i++) {
s->s[i].nr_replicas = 0; s->s[i].nr_replicas = 0;
if (s->s[i].state == SECTOR_DIRTY)
i_sectors_delta--;
s->s[i].state = SECTOR_UNALLOCATED; s->s[i].state = SECTOR_UNALLOCATED;
} }
i_sectors_acct(c, inode, NULL, i_sectors_delta);
/* /*
* Caller needs to know whether this page will be written out by * Caller needs to know whether this page will be written out by
* writeback - doing an i_size update if necessary - or whether it will * writeback - doing an i_size update if necessary - or whether it will
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment