diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-05-04 17:28:58 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2018-05-22 00:44:18 -0400 |
commit | 7ec334adee4819633d9703392b46c721fbb610f8 (patch) | |
tree | 1b7970f85433d31094cf97eac9e6f721478a407c | |
parent | 3cf626e56326c36a3de4147230db4d4b4f174ebf (diff) |
bcachefs: Bunch of rebalance fixes
-rw-r--r-- | fs/bcachefs/Makefile | 2 | ||||
-rw-r--r-- | fs/bcachefs/bcachefs.h | 14 | ||||
-rw-r--r-- | fs/bcachefs/bcachefs_format.h | 3 | ||||
-rw-r--r-- | fs/bcachefs/bkey.h | 2 | ||||
-rw-r--r-- | fs/bcachefs/clock.c | 47 | ||||
-rw-r--r-- | fs/bcachefs/clock.h | 3 | ||||
-rw-r--r-- | fs/bcachefs/io.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/movinggc.c | 6 | ||||
-rw-r--r-- | fs/bcachefs/rebalance.c (renamed from fs/bcachefs/tier.c) | 184 | ||||
-rw-r--r-- | fs/bcachefs/rebalance.h (renamed from fs/bcachefs/tier.h) | 12 | ||||
-rw-r--r-- | fs/bcachefs/rebalance_types.h | 23 | ||||
-rw-r--r-- | fs/bcachefs/super.c | 5 | ||||
-rw-r--r-- | fs/bcachefs/sysfs.c | 22 | ||||
-rw-r--r-- | fs/bcachefs/xattr.c | 2 |
14 files changed, 225 insertions, 102 deletions
diff --git a/fs/bcachefs/Makefile b/fs/bcachefs/Makefile index f62c59f1a891..1dd2f3c7c4f1 100644 --- a/fs/bcachefs/Makefile +++ b/fs/bcachefs/Makefile @@ -40,13 +40,13 @@ bcachefs-y := \ movinggc.o \ opts.o \ quota.o \ + rebalance.o \ replicas.o \ siphash.o \ six.o \ super.o \ super-io.o \ sysfs.o \ - tier.o \ trace.o \ util.o \ xattr.o diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index d13f3b708e53..5b6faca1d330 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -197,7 +197,6 @@ #include <linux/zstd.h> #include "bcachefs_format.h" -#include "bset.h" #include "fifo.h" #include "opts.h" #include "util.h" @@ -296,11 +295,13 @@ enum bch_time_stats { }; #include "alloc_types.h" +#include "btree_types.h" #include "buckets_types.h" #include "clock_types.h" #include "journal_types.h" #include "keylist_types.h" #include "quota_types.h" +#include "rebalance_types.h" #include "super_types.h" /* @@ -580,12 +581,6 @@ struct bch_fs { struct delayed_work pd_controllers_update; unsigned pd_controllers_update_seconds; - /* REBALANCE */ - struct task_struct *rebalance_thread; - struct bch_pd_controller rebalance_pd; - - atomic64_t rebalance_work_unknown_dev; - struct bch_devs_mask rw_devs[BCH_DATA_NR]; u64 capacity; /* sectors */ @@ -674,6 +669,9 @@ struct bch_fs { atomic64_t key_version; + /* REBALANCE */ + struct bch_fs_rebalance rebalance; + /* VFS IO PATH - fs-io.c */ struct bio_set writepage_bioset; struct bio_set dio_write_bioset; @@ -724,8 +722,6 @@ struct bch_fs { unsigned btree_gc_periodic:1; unsigned copy_gc_enabled:1; - unsigned rebalance_enabled:1; - unsigned rebalance_percent; bool promote_whole_extents; #define BCH_DEBUG_PARAM(name, description) bool name; diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 48d14a30e03e..b473d666b7db 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -551,10 +551,11 @@ BKEY_VAL_TYPE(reservation, BCH_RESERVATION); sizeof(struct bch_extent_ptr)) / sizeof(u64)) /* Maximum possible size of an entire extent value: */ -/* There's a hack in the keylist code that needs to be fixed.. */ #define BKEY_EXTENT_VAL_U64s_MAX \ (BKEY_EXTENT_PTR_U64s_MAX * (BCH_REPLICAS_MAX + 1)) +#define BKEY_PADDED(key) __BKEY_PADDED(key, BKEY_EXTENT_VAL_U64s_MAX) + /* * Maximum possible size of an entire extent, key + value: */ #define BKEY_EXTENT_U64s_MAX (BKEY_U64s + BKEY_EXTENT_VAL_U64s_MAX) diff --git a/fs/bcachefs/bkey.h b/fs/bcachefs/bkey.h index f665e2e138bf..0a7b9327a288 100644 --- a/fs/bcachefs/bkey.h +++ b/fs/bcachefs/bkey.h @@ -13,8 +13,6 @@ void bch2_to_binary(char *, const u64 *, unsigned); -#define BKEY_PADDED(key) __BKEY_PADDED(key, BKEY_EXTENT_VAL_U64s_MAX) - /* bkey with split value, const */ struct bkey_s_c { const struct bkey *k; diff --git a/fs/bcachefs/clock.c b/fs/bcachefs/clock.c index 650be8cebe8f..c67376f96f5a 100644 --- a/fs/bcachefs/clock.c +++ b/fs/bcachefs/clock.c @@ -42,7 +42,8 @@ void bch2_io_timer_del(struct io_clock *clock, struct io_timer *timer) } struct io_clock_wait { - struct io_timer timer; + struct io_timer io_timer; + struct timer_list cpu_timer; struct task_struct *task; int expired; }; @@ -50,7 +51,16 @@ struct io_clock_wait { static void io_clock_wait_fn(struct io_timer *timer) { struct io_clock_wait *wait = container_of(timer, - struct io_clock_wait, timer); + struct io_clock_wait, io_timer); + + wait->expired = 1; + wake_up_process(wait->task); +} + +static void io_clock_cpu_timeout(struct timer_list *timer) +{ + struct io_clock_wait *wait = container_of(timer, + struct io_clock_wait, cpu_timer); wait->expired = 1; wake_up_process(wait->task); @@ -61,35 +71,38 @@ void bch2_io_clock_schedule_timeout(struct io_clock *clock, unsigned long until) struct io_clock_wait wait; /* XXX: calculate sleep time rigorously */ - wait.timer.expire = until; - wait.timer.fn = io_clock_wait_fn; + wait.io_timer.expire = until; + wait.io_timer.fn = io_clock_wait_fn; wait.task = current; wait.expired = 0; - bch2_io_timer_add(clock, &wait.timer); + bch2_io_timer_add(clock, &wait.io_timer); schedule(); - bch2_io_timer_del(clock, &wait.timer); + bch2_io_timer_del(clock, &wait.io_timer); } -/* - * _only_ to be used from a kthread - */ void bch2_kthread_io_clock_wait(struct io_clock *clock, - unsigned long until) + unsigned long io_until, + unsigned long cpu_timeout) { + bool kthread = (current->flags & PF_KTHREAD) != 0; struct io_clock_wait wait; - /* XXX: calculate sleep time rigorously */ - wait.timer.expire = until; - wait.timer.fn = io_clock_wait_fn; + wait.io_timer.expire = io_until; + wait.io_timer.fn = io_clock_wait_fn; wait.task = current; wait.expired = 0; - bch2_io_timer_add(clock, &wait.timer); + bch2_io_timer_add(clock, &wait.io_timer); + + timer_setup_on_stack(&wait.cpu_timer, io_clock_cpu_timeout, 0); + + if (cpu_timeout != MAX_SCHEDULE_TIMEOUT) + mod_timer(&wait.cpu_timer, cpu_timeout + jiffies); while (1) { set_current_state(TASK_INTERRUPTIBLE); - if (kthread_should_stop()) + if (kthread && kthread_should_stop()) break; if (wait.expired) @@ -100,7 +113,9 @@ void bch2_kthread_io_clock_wait(struct io_clock *clock, } __set_current_state(TASK_RUNNING); - bch2_io_timer_del(clock, &wait.timer); + del_singleshot_timer_sync(&wait.cpu_timer); + destroy_timer_on_stack(&wait.cpu_timer); + bch2_io_timer_del(clock, &wait.io_timer); } static struct io_timer *get_expired_timer(struct io_clock *clock, diff --git a/fs/bcachefs/clock.h b/fs/bcachefs/clock.h index af6b2b392cac..1e2a7dea4ddd 100644 --- a/fs/bcachefs/clock.h +++ b/fs/bcachefs/clock.h @@ -3,7 +3,8 @@ void bch2_io_timer_add(struct io_clock *, struct io_timer *); void bch2_io_timer_del(struct io_clock *, struct io_timer *); -void bch2_kthread_io_clock_wait(struct io_clock *, unsigned long); +void bch2_kthread_io_clock_wait(struct io_clock *, unsigned long, + unsigned long); void bch2_increment_clock(struct bch_fs *, unsigned, int); void bch2_io_clock_schedule_timeout(struct io_clock *, unsigned long); diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index f57afb164f0c..d2a2a6e2dd82 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -21,10 +21,10 @@ #include "journal.h" #include "keylist.h" #include "move.h" +#include "rebalance.h" #include "replicas.h" #include "super.h" #include "super-io.h" -#include "tier.h" #include <linux/blkdev.h> #include <linux/random.h> diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c index 28dabca74565..7bef456110f1 100644 --- a/fs/bcachefs/movinggc.c +++ b/fs/bcachefs/movinggc.c @@ -241,7 +241,8 @@ static int bch2_copygc_thread(void *arg) ca->mi.bucket_size; if (available > reserve) { next = last + available - reserve; - bch2_kthread_io_clock_wait(clock, next); + bch2_kthread_io_clock_wait(clock, next, + MAX_SCHEDULE_TIMEOUT); continue; } @@ -252,7 +253,8 @@ static int bch2_copygc_thread(void *arg) fragmented = usage.sectors_fragmented; if (fragmented < reserve) { next = last + reserve - fragmented; - bch2_kthread_io_clock_wait(clock, next); + bch2_kthread_io_clock_wait(clock, next, + MAX_SCHEDULE_TIMEOUT); continue; } diff --git a/fs/bcachefs/tier.c b/fs/bcachefs/rebalance.c index a15a0fa9dff9..afff826846d0 100644 --- a/fs/bcachefs/tier.c +++ b/fs/bcachefs/rebalance.c @@ -8,8 +8,8 @@ #include "extents.h" #include "io.h" #include "move.h" +#include "rebalance.h" #include "super-io.h" -#include "tier.h" #include <linux/freezer.h> #include <linux/kthread.h> @@ -57,15 +57,17 @@ void bch2_rebalance_add_key(struct bch_fs *c, if (rebalance_ptr_pred(c, ptr, crc, io_opts)) { struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev); - if (!atomic64_add_return(crc.compressed_size, - &ca->rebalance_work)) + if (atomic64_add_return(crc.compressed_size, + &ca->rebalance_work) == + crc.compressed_size) rebalance_wakeup(c); } } void bch2_rebalance_add_work(struct bch_fs *c, u64 sectors) { - if (!atomic64_add_return(sectors, &c->rebalance_work_unknown_dev)) + if (atomic64_add_return(sectors, &c->rebalance.work_unknown_dev) == + sectors) rebalance_wakeup(c); } @@ -95,35 +97,54 @@ found: } struct rebalance_work { + int dev_most_full_idx; unsigned dev_most_full_percent; u64 dev_most_full_work; u64 dev_most_full_capacity; u64 total_work; }; +static void rebalance_work_accumulate(struct rebalance_work *w, + u64 dev_work, u64 unknown_dev, u64 capacity, int idx) +{ + unsigned percent_full; + u64 work = dev_work + unknown_dev; + + if (work < dev_work || work < unknown_dev) + work = U64_MAX; + work = min(work, capacity); + + percent_full = div_u64(work * 100, capacity); + + if (percent_full >= w->dev_most_full_percent) { + w->dev_most_full_idx = idx; + w->dev_most_full_percent = percent_full; + w->dev_most_full_work = work; + w->dev_most_full_capacity = capacity; + } + + if (w->total_work + dev_work >= w->total_work && + w->total_work + dev_work >= dev_work) + w->total_work += dev_work; +} + static struct rebalance_work rebalance_work(struct bch_fs *c) { struct bch_dev *ca; - struct rebalance_work ret = { 0 }; + struct rebalance_work ret = { .dev_most_full_idx = -1 }; + u64 unknown_dev = atomic64_read(&c->rebalance.work_unknown_dev); unsigned i; - for_each_online_member(ca, c, i) { - u64 capacity = bucket_to_sector(ca, ca->mi.nbuckets - - ca->mi.first_bucket); - u64 work = atomic64_read(&ca->rebalance_work) + - atomic64_read(&c->rebalance_work_unknown_dev); - unsigned percent_full = div_u64(work * 100, capacity); - - if (percent_full > ret.dev_most_full_percent) { - ret.dev_most_full_percent = percent_full; - ret.dev_most_full_work = work; - ret.dev_most_full_capacity = capacity; - } - - ret.total_work += atomic64_read(&ca->rebalance_work); - } + for_each_online_member(ca, c, i) + rebalance_work_accumulate(&ret, + atomic64_read(&ca->rebalance_work), + unknown_dev, + bucket_to_sector(ca, ca->mi.nbuckets - + ca->mi.first_bucket), + i); - ret.total_work += atomic64_read(&c->rebalance_work_unknown_dev); + rebalance_work_accumulate(&ret, + unknown_dev, 0, c->capacity, -1); return ret; } @@ -136,7 +157,7 @@ static void rebalance_work_reset(struct bch_fs *c) for_each_online_member(ca, c, i) atomic64_set(&ca->rebalance_work, 0); - atomic64_set(&c->rebalance_work_unknown_dev, 0); + atomic64_set(&c->rebalance.work_unknown_dev, 0); } static unsigned long curr_cputime(void) @@ -150,61 +171,78 @@ static unsigned long curr_cputime(void) static int bch2_rebalance_thread(void *arg) { struct bch_fs *c = arg; + struct bch_fs_rebalance *r = &c->rebalance; struct io_clock *clock = &c->io_clock[WRITE]; struct rebalance_work w, p; unsigned long start, prev_start; unsigned long prev_run_time, prev_run_cputime; unsigned long cputime, prev_cputime; + unsigned long io_start; + long throttle; set_freezable(); + io_start = atomic_long_read(&clock->now); p = rebalance_work(c); prev_start = jiffies; prev_cputime = curr_cputime(); - while (!kthread_wait_freezable(c->rebalance_enabled)) { + while (!kthread_wait_freezable(r->enabled)) { struct bch_move_stats move_stats = { 0 }; - w = rebalance_work(c); start = jiffies; cputime = curr_cputime(); prev_run_time = start - prev_start; prev_run_cputime = cputime - prev_cputime; + w = rebalance_work(c); + BUG_ON(!w.dev_most_full_capacity); + if (!w.total_work) { + r->state = REBALANCE_WAITING; kthread_wait_freezable(rebalance_work(c).total_work); continue; } - if (w.dev_most_full_percent < 20 && - prev_run_cputime * 5 > prev_run_time) { - if (w.dev_most_full_capacity) { - bch2_kthread_io_clock_wait(clock, - atomic_long_read(&clock->now) + - div_u64(w.dev_most_full_capacity, 5)); - } else { - - set_current_state(TASK_INTERRUPTIBLE); - if (kthread_should_stop()) - break; - - schedule_timeout(prev_run_cputime * 5 - - prev_run_time); - continue; - } + /* + * If there isn't much work to do, throttle cpu usage: + */ + throttle = prev_run_cputime * 100 / + max(1U, w.dev_most_full_percent) - + prev_run_time; + + if (w.dev_most_full_percent < 20 && throttle > 0) { + r->state = REBALANCE_THROTTLED; + r->throttled_until_iotime = io_start + + div_u64(w.dev_most_full_capacity * + (20 - w.dev_most_full_percent), + 50); + r->throttled_until_cputime = start + throttle; + + bch2_kthread_io_clock_wait(clock, + r->throttled_until_iotime, + throttle); + continue; } + r->state = REBALANCE_RUNNING; + /* minimum 1 mb/sec: */ - c->rebalance_pd.rate.rate = + r->pd.rate.rate = max_t(u64, 1 << 11, - c->rebalance_pd.rate.rate * + r->pd.rate.rate * max(p.dev_most_full_percent, 1U) / max(w.dev_most_full_percent, 1U)); + io_start = atomic_long_read(&clock->now); + p = w; + prev_start = start; + prev_cputime = cputime; + rebalance_work_reset(c); - bch2_move_data(c, &c->rebalance_pd.rate, + bch2_move_data(c, &r->pd.rate, writepoint_ptr(&c->rebalance_write_point), POS_MIN, POS_MAX, rebalance_pred, NULL, @@ -214,15 +252,59 @@ static int bch2_rebalance_thread(void *arg) return 0; } +ssize_t bch2_rebalance_work_show(struct bch_fs *c, char *buf) +{ + char *out = buf, *end = out + PAGE_SIZE; + struct bch_fs_rebalance *r = &c->rebalance; + struct rebalance_work w = rebalance_work(c); + char h1[21], h2[21]; + + bch2_hprint(h1, w.dev_most_full_work << 9); + bch2_hprint(h2, w.dev_most_full_capacity << 9); + out += scnprintf(out, end - out, + "fullest_dev (%i):\t%s/%s\n", + w.dev_most_full_idx, h1, h2); + + bch2_hprint(h1, w.total_work << 9); + bch2_hprint(h2, c->capacity << 9); + out += scnprintf(out, end - out, + "total work:\t\t%s/%s\n", + h1, h2); + + out += scnprintf(out, end - out, + "rate:\t\t\t%u\n", + r->pd.rate.rate); + + switch (r->state) { + case REBALANCE_WAITING: + out += scnprintf(out, end - out, "waiting\n"); + break; + case REBALANCE_THROTTLED: + bch2_hprint(h1, + (r->throttled_until_iotime - + atomic_long_read(&c->io_clock[WRITE].now)) << 9); + out += scnprintf(out, end - out, + "throttled for %lu sec or %s io\n", + (r->throttled_until_cputime - jiffies) / HZ, + h1); + break; + case REBALANCE_RUNNING: + out += scnprintf(out, end - out, "running\n"); + break; + } + + return out - buf; +} + void bch2_rebalance_stop(struct bch_fs *c) { struct task_struct *p; - c->rebalance_pd.rate.rate = UINT_MAX; - bch2_ratelimit_reset(&c->rebalance_pd.rate); + c->rebalance.pd.rate.rate = UINT_MAX; + bch2_ratelimit_reset(&c->rebalance.pd.rate); - p = c->rebalance_thread; - c->rebalance_thread = NULL; + p = c->rebalance.thread; + c->rebalance.thread = NULL; if (p) { /* for sychronizing with rebalance_wakeup() */ @@ -246,14 +328,14 @@ int bch2_rebalance_start(struct bch_fs *c) get_task_struct(p); - rcu_assign_pointer(c->rebalance_thread, p); - wake_up_process(c->rebalance_thread); + rcu_assign_pointer(c->rebalance.thread, p); + wake_up_process(c->rebalance.thread); return 0; } void bch2_fs_rebalance_init(struct bch_fs *c) { - bch2_pd_controller_init(&c->rebalance_pd); + bch2_pd_controller_init(&c->rebalance.pd); - atomic64_set(&c->rebalance_work_unknown_dev, S64_MAX); + atomic64_set(&c->rebalance.work_unknown_dev, S64_MAX); } diff --git a/fs/bcachefs/tier.h b/fs/bcachefs/rebalance.h index 0c66dfea7c0d..2e6aa6772471 100644 --- a/fs/bcachefs/tier.h +++ b/fs/bcachefs/rebalance.h @@ -1,12 +1,14 @@ -#ifndef _BCACHEFS_TIER_H -#define _BCACHEFS_TIER_H +#ifndef _BCACHEFS_REBALANCE_H +#define _BCACHEFS_REBALANCE_H + +#include "rebalance_types.h" static inline void rebalance_wakeup(struct bch_fs *c) { struct task_struct *p; rcu_read_lock(); - p = rcu_dereference(c->rebalance_thread); + p = rcu_dereference(c->rebalance.thread); if (p) wake_up_process(p); rcu_read_unlock(); @@ -16,8 +18,10 @@ void bch2_rebalance_add_key(struct bch_fs *, struct bkey_s_c, struct bch_io_opts *); void bch2_rebalance_add_work(struct bch_fs *, u64); +ssize_t bch2_rebalance_work_show(struct bch_fs *, char *); + void bch2_rebalance_stop(struct bch_fs *); int bch2_rebalance_start(struct bch_fs *); void bch2_fs_rebalance_init(struct bch_fs *); -#endif /* _BCACHEFS_TIER_H */ +#endif /* _BCACHEFS_REBALANCE_H */ diff --git a/fs/bcachefs/rebalance_types.h b/fs/bcachefs/rebalance_types.h new file mode 100644 index 000000000000..52374d5d53cb --- /dev/null +++ b/fs/bcachefs/rebalance_types.h @@ -0,0 +1,23 @@ +#ifndef _BCACHEFS_REBALANCE_TYPES_H +#define _BCACHEFS_REBALANCE_TYPES_H + +enum rebalance_state { + REBALANCE_WAITING, + REBALANCE_THROTTLED, + REBALANCE_RUNNING, +}; + +struct bch_fs_rebalance { + struct task_struct *thread; + struct bch_pd_controller pd; + + atomic64_t work_unknown_dev; + + enum rebalance_state state; + unsigned long throttled_until_iotime; + unsigned long throttled_until_cputime; + + unsigned enabled:1; +}; + +#endif /* _BCACHEFS_REBALANCE_TYPES_H */ diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index ee72c8294cee..13f19c2dae5b 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -33,11 +33,11 @@ #include "migrate.h" #include "movinggc.h" #include "quota.h" +#include "rebalance.h" #include "replicas.h" #include "super.h" #include "super-io.h" #include "sysfs.h" -#include "tier.h" #include <linux/backing-dev.h> #include <linux/blkdev.h> @@ -590,8 +590,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts) seqcount_init(&c->gc_pos_lock); c->copy_gc_enabled = 1; - c->rebalance_enabled = 1; - c->rebalance_percent = 10; + c->rebalance.enabled = 1; c->promote_whole_extents = true; c->journal.write_time = &c->times[BCH_TIME_journal_write]; diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c index 1a4c6259245d..5e341a712cdf 100644 --- a/fs/bcachefs/sysfs.c +++ b/fs/bcachefs/sysfs.c @@ -24,9 +24,9 @@ #include "keylist.h" #include "move.h" #include "opts.h" +#include "rebalance.h" #include "replicas.h" #include "super-io.h" -#include "tier.h" #include <linux/blkdev.h> #include <linux/sort.h> @@ -183,8 +183,8 @@ rw_attribute(copy_gc_enabled); sysfs_pd_controller_attribute(copy_gc); rw_attribute(rebalance_enabled); -rw_attribute(rebalance_percent); sysfs_pd_controller_attribute(rebalance); +read_attribute(rebalance_work); rw_attribute(promote_whole_extents); rw_attribute(pd_controllers_update_seconds); @@ -340,9 +340,11 @@ SHOW(bch2_fs) sysfs_print(pd_controllers_update_seconds, c->pd_controllers_update_seconds); - sysfs_printf(rebalance_enabled, "%i", c->rebalance_enabled); - sysfs_print(rebalance_percent, c->rebalance_percent); - sysfs_pd_controller_show(rebalance, &c->rebalance_pd); /* XXX */ + sysfs_printf(rebalance_enabled, "%i", c->rebalance.enabled); + sysfs_pd_controller_show(rebalance, &c->rebalance.pd); /* XXX */ + + if (attr == &sysfs_rebalance_work) + return bch2_rebalance_work_show(c, buf); sysfs_print(promote_whole_extents, c->promote_whole_extents); @@ -404,7 +406,7 @@ STORE(__bch2_fs) } if (attr == &sysfs_rebalance_enabled) { - ssize_t ret = strtoul_safe(buf, c->rebalance_enabled) + ssize_t ret = strtoul_safe(buf, c->rebalance.enabled) ?: (ssize_t) size; rebalance_wakeup(c); @@ -413,9 +415,7 @@ STORE(__bch2_fs) sysfs_strtoul(pd_controllers_update_seconds, c->pd_controllers_update_seconds); - - sysfs_strtoul(rebalance_percent, c->rebalance_percent); - sysfs_pd_controller_store(rebalance, &c->rebalance_pd); + sysfs_pd_controller_store(rebalance, &c->rebalance.pd); sysfs_strtoul(promote_whole_extents, c->promote_whole_extents); @@ -474,7 +474,6 @@ struct attribute *bch2_fs_files[] = { &sysfs_journal_write_delay_ms, &sysfs_journal_reclaim_delay_ms, - &sysfs_rebalance_percent, &sysfs_promote_whole_extents, &sysfs_compression_stats, @@ -513,8 +512,11 @@ struct attribute *bch2_fs_internal_files[] = { &sysfs_prune_cache, &sysfs_copy_gc_enabled, + &sysfs_rebalance_enabled, + &sysfs_rebalance_work, sysfs_pd_controller_files(rebalance), + &sysfs_internal_uuid, #define BCH_DEBUG_PARAM(name, description) &sysfs_##name, diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c index 79a98f757cc9..c89c7200a1b4 100644 --- a/fs/bcachefs/xattr.c +++ b/fs/bcachefs/xattr.c @@ -5,8 +5,8 @@ #include "compress.h" #include "extents.h" #include "fs.h" +#include "rebalance.h" #include "str_hash.h" -#include "tier.h" #include "xattr.h" #include <linux/dcache.h> |