bcachefs: Start/stop io clock hands in read/write paths
authorKent Overstreet <kent.overstreet@gmail.com>
Sat, 17 Oct 2020 20:44:27 +0000 (16:44 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:44 +0000 (17:08 -0400)
This fixes a bug where the clock hands in the journal and superblock
didn't match, because we were still incrementing the read clock hand
while read-only.

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

index 459da00457efc9e83002d5dcfa8876508d8d29a9..b0448d2f1916548f19427d8132770f5abebd999f 100644 (file)
@@ -1267,18 +1267,6 @@ void bch2_recalc_capacity(struct bch_fs *c)
 
        c->bucket_size_max = bucket_size_max;
 
-       if (c->capacity) {
-               bch2_io_timer_add(&c->io_clock[READ],
-                                &c->bucket_clock[READ].rescale);
-               bch2_io_timer_add(&c->io_clock[WRITE],
-                                &c->bucket_clock[WRITE].rescale);
-       } else {
-               bch2_io_timer_del(&c->io_clock[READ],
-                                &c->bucket_clock[READ].rescale);
-               bch2_io_timer_del(&c->io_clock[WRITE],
-                                &c->bucket_clock[WRITE].rescale);
-       }
-
        /* Wake up case someone was waiting for buckets */
        closure_wake_up(&c->freelist_wait);
 }
index 7656bf632d798fb0135bcb12c34e59febe480ae5..15e760d8dd4de2997206efdd70200b570dfdf50d 100644 (file)
@@ -182,6 +182,9 @@ static void __bch2_fs_read_only(struct bch_fs *c)
        bch2_copygc_stop(c);
        bch2_gc_thread_stop(c);
 
+       bch2_io_timer_del(&c->io_clock[READ], &c->bucket_clock[READ].rescale);
+       bch2_io_timer_del(&c->io_clock[WRITE], &c->bucket_clock[WRITE].rescale);
+
        /*
         * Flush journal before stopping allocators, because flushing journal
         * blacklist entries involves allocating new btree nodes:
@@ -407,6 +410,9 @@ static int __bch2_fs_read_write(struct bch_fs *c, bool early)
                bch2_dev_allocator_add(c, ca);
        bch2_recalc_capacity(c);
 
+       bch2_io_timer_add(&c->io_clock[READ], &c->bucket_clock[READ].rescale);
+       bch2_io_timer_add(&c->io_clock[WRITE], &c->bucket_clock[WRITE].rescale);
+
        for_each_rw_member(ca, c, i) {
                ret = bch2_dev_allocator_start(ca);
                if (ret) {