diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-11-22 20:47:20 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:17 +0300 |
commit | b19d307dc11586df2e2b7430c0ccbfa439bf7a0b (patch) | |
tree | 09dd71b7208b0eac64da5a4c6cd45fe15b419c49 /fs/bcachefs/fs-io.c | |
parent | 8810386f6bd55cf3287a1219901c2993b3bac959 (diff) | |
download | linux-b19d307dc11586df2e2b7430c0ccbfa439bf7a0b.tar.xz |
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: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/fs-io.c')
-rw-r--r-- | fs/bcachefs/fs-io.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index dff6d7547212..68e707fcf9cd 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -2241,6 +2241,7 @@ static int __bch2_truncate_page(struct bch_inode_info *inode, unsigned end_offset = ((end - 1) & (PAGE_SIZE - 1)) + 1; unsigned i; struct page *page; + s64 i_sectors_delta = 0; int ret = 0; /* Page boundary? Nothing to do */ @@ -2292,9 +2293,13 @@ static int __bch2_truncate_page(struct bch_inode_info *inode, i < round_down(end_offset, block_bytes(c)) >> 9; i++) { s->s[i].nr_replicas = 0; + if (s->s[i].state == SECTOR_DIRTY) + i_sectors_delta--; 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 * writeback - doing an i_size update if necessary - or whether it will |