bcachefs: bch2_copygc_wakeup()
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 15 Apr 2025 14:26:05 +0000 (10:26 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 21 Apr 2025 00:01:48 +0000 (20:01 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/movinggc.h
fs/bcachefs/rebalance.c
fs/bcachefs/rebalance.h
fs/bcachefs/super.c
fs/bcachefs/sysfs.c

index ea181fef5bc93232f42ac18e1033fcca3b7eda71..d1885cf67a457484b4d06fdd47af4ce7b9487341 100644 (file)
@@ -5,6 +5,15 @@
 unsigned long bch2_copygc_wait_amount(struct bch_fs *);
 void bch2_copygc_wait_to_text(struct printbuf *, struct bch_fs *);
 
+static inline void bch2_copygc_wakeup(struct bch_fs *c)
+{
+       rcu_read_lock();
+       struct task_struct *p = rcu_dereference(c->copygc_thread);
+       if (p)
+               wake_up_process(p);
+       rcu_read_unlock();
+}
+
 void bch2_copygc_stop(struct bch_fs *);
 int bch2_copygc_start(struct bch_fs *);
 void bch2_fs_copygc_init(struct bch_fs *);
index c63fa53f30d219b979cef684e3f6d565ba093743..39006e6affe3db50e975fc35c191cae7a621432d 100644 (file)
@@ -262,7 +262,7 @@ int bch2_set_rebalance_needs_scan(struct bch_fs *c, u64 inum)
        int ret = bch2_trans_commit_do(c, NULL, NULL,
                                       BCH_TRANS_COMMIT_no_enospc,
                            bch2_set_rebalance_needs_scan_trans(trans, inum));
-       rebalance_wakeup(c);
+       bch2_rebalance_wakeup(c);
        return ret;
 }
 
@@ -664,7 +664,7 @@ void bch2_rebalance_stop(struct bch_fs *c)
        c->rebalance.thread = NULL;
 
        if (p) {
-               /* for sychronizing with rebalance_wakeup() */
+               /* for sychronizing with bch2_rebalance_wakeup() */
                synchronize_rcu();
 
                kthread_stop(p);
index 62a3859d3823f3e617c843501d27a9b0b5400520..e5e8eb4a2dd150cfab9b700be9a010581ca03a95 100644 (file)
@@ -37,7 +37,7 @@ int bch2_set_rebalance_needs_scan_trans(struct btree_trans *, u64);
 int bch2_set_rebalance_needs_scan(struct bch_fs *, u64 inum);
 int bch2_set_fs_needs_rebalance(struct bch_fs *);
 
-static inline void rebalance_wakeup(struct bch_fs *c)
+static inline void bch2_rebalance_wakeup(struct bch_fs *c)
 {
        struct task_struct *p;
 
index adbf3bbed6bce2121214ffcb26364ab78e7871ac..ee27734f350f8e1d999316da0e044321b7a26dda 100644 (file)
@@ -1500,7 +1500,7 @@ static int bch2_dev_attach_bdev(struct bch_fs *c, struct bch_sb_handle *sb)
 
        printbuf_exit(&name);
 
-       rebalance_wakeup(c);
+       bch2_rebalance_wakeup(c);
        return 0;
 }
 
@@ -1646,7 +1646,7 @@ int __bch2_dev_set_state(struct bch_fs *c, struct bch_dev *ca,
        if (new_state == BCH_MEMBER_STATE_rw)
                __bch2_dev_read_write(c, ca);
 
-       rebalance_wakeup(c);
+       bch2_rebalance_wakeup(c);
 
        return ret;
 }
index e5f003c29369e05dbbb90ba1831fcbeaca9e66b9..82ee333ddd216cadec3eea28f998c4d0f4ab635f 100644 (file)
@@ -654,11 +654,10 @@ static ssize_t sysfs_opt_store(struct bch_fs *c,
                bch2_set_rebalance_needs_scan(c, 0);
 
        if (v && id == Opt_rebalance_enabled)
-               rebalance_wakeup(c);
+               bch2_rebalance_wakeup(c);
 
-       if (v && id == Opt_copygc_enabled &&
-           c->copygc_thread)
-               wake_up_process(c->copygc_thread);
+       if (v && id == Opt_copygc_enabled)
+               bch2_copygc_wakeup(c);
 
        if (id == Opt_discard && !ca) {
                mutex_lock(&c->sb_lock);