bcachefs: Always check if we need disk res in extent update path
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 10 Dec 2020 18:38:54 +0000 (13:38 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:49 +0000 (17:08 -0400)
commit5b9bf43c81e6c0fd9d4f16351d53f26e7e6d19b5
treedc4e2e00b27e611905db1727edd2d7d75f04b4cc
parent719fe7fb555ad9a53bb847bfae1cad7170cb2591
bcachefs: Always check if we need disk res in extent update path

With erasure coding, we now have processes in the background that
compact data, causing it to take up less space on disk than when it was
written, or potentially when it was read.

This means that we can't trust the page cache when it says "we have data
on disk taking up x amount of space here" - there's always the potential
to race with background compaction.

To fix this, just check if we need to add to our disk reservation in the
bch2_extent_update() path, in the transaction that will do the btree
update.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/io.c