summaryrefslogtreecommitdiff
path: root/fs/bcachefs/io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-03-17 17:56:44 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:57 +0300
commitabab7609de92c973bfa3ad069a622c0a107b6386 (patch)
tree699235cb3fa6e053a3b7fe6d47a833c228a9ce03 /fs/bcachefs/io.c
parent711bf946d55d28336dcc4f87209c8b74e6279481 (diff)
downloadlinux-abab7609de92c973bfa3ad069a622c0a107b6386.tar.xz
bcachefs: Fix bch2_extent_fallocate() in nocow mode
When we allocate disk space, we need to be incrementing the WRITE io clock, which perhaps should be renamed to sectors allocated - copygc uses this io clock to know when to run. Also, we should be incrementing the same clock when allocating btree nodes. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/io.c')
-rw-r--r--fs/bcachefs/io.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index e82da496b3f8..0c2d42eaba56 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -384,6 +384,7 @@ int bch2_extent_fallocate(struct btree_trans *trans,
struct open_buckets open_buckets;
struct bkey_s_c k;
struct bkey_buf old, new;
+ unsigned sectors_allocated;
bool have_reservation = false;
bool unwritten = opts.nocow &&
c->sb.version >= bcachefs_metadata_version_unwritten_extents;
@@ -394,6 +395,8 @@ int bch2_extent_fallocate(struct btree_trans *trans,
closure_init_stack(&cl);
open_buckets.nr = 0;
retry:
+ sectors_allocated = 0;
+
k = bch2_btree_iter_peek_slot(iter);
ret = bkey_err(k);
if (ret)
@@ -459,6 +462,7 @@ retry:
return ret;
sectors = min(sectors, wp->sectors_free);
+ sectors_allocated = sectors;
bch2_key_resize(&e->k, sectors);
@@ -485,6 +489,9 @@ out:
goto retry;
}
+ if (!ret && sectors_allocated)
+ bch2_increment_clock(c, sectors_allocated, WRITE);
+
bch2_open_buckets_put(c, &open_buckets);
bch2_disk_reservation_put(c, &disk_res);
bch2_bkey_buf_exit(&new, c);