#undef x
};
-/* Ratelimiting/PD controllers */
-
-static void pd_controllers_update(struct work_struct *work)
-{
- struct bch_fs *c = container_of(to_delayed_work(work),
- struct bch_fs,
- pd_controllers_update);
- struct bch_dev *ca;
- s64 free = 0, fragmented = 0;
- unsigned i;
-
- for_each_member_device(ca, c, i) {
- struct bch_dev_usage stats = bch2_dev_usage_read(ca);
-
- free += bucket_to_sector(ca,
- __dev_buckets_available(ca, stats)) << 9;
- /*
- * Bytes of internal fragmentation, which can be
- * reclaimed by copy GC
- */
- fragmented += max_t(s64, 0, (bucket_to_sector(ca,
- stats.d[BCH_DATA_user].buckets +
- stats.d[BCH_DATA_cached].buckets) -
- (stats.d[BCH_DATA_user].sectors +
- stats.d[BCH_DATA_cached].sectors)) << 9);
- }
-
- bch2_pd_controller_update(&c->copygc_pd, free, fragmented, -1);
- schedule_delayed_work(&c->pd_controllers_update,
- c->pd_controllers_update_seconds * HZ);
-}
-
/* Persistent alloc info: */
static inline u64 alloc_field_v1_get(const struct bch_alloc *a,
void bch2_fs_allocator_background_init(struct bch_fs *c)
{
spin_lock_init(&c->freelist_lock);
-
- c->pd_controllers_update_seconds = 5;
- INIT_DELAYED_WORK(&c->pd_controllers_update, pd_controllers_update);
}
struct workqueue_struct *copygc_wq;
/* ALLOCATION */
- struct delayed_work pd_controllers_update;
- unsigned pd_controllers_update_seconds;
-
struct bch_devs_mask rw_devs[BCH_DATA_NR];
u64 capacity; /* sectors */
/* COPYGC */
struct task_struct *copygc_thread;
copygc_heap copygc_heap;
- struct bch_pd_controller copygc_pd;
struct write_point copygc_write_point;
s64 copygc_wait;
ret = bch2_move_data(c,
0, POS_MIN,
BTREE_ID_NR, POS_MAX,
- &c->copygc_pd.rate,
+ NULL,
writepoint_ptr(&c->copygc_write_point),
copygc_pred, NULL,
&move_stats);
void bch2_copygc_stop(struct bch_fs *c)
{
- c->copygc_pd.rate.rate = UINT_MAX;
- bch2_ratelimit_reset(&c->copygc_pd.rate);
-
if (c->copygc_thread) {
kthread_stop(c->copygc_thread);
put_task_struct(c->copygc_thread);
void bch2_fs_copygc_init(struct bch_fs *c)
{
- bch2_pd_controller_init(&c->copygc_pd);
- c->copygc_pd.d_term = 0;
}
percpu_ref_kill(&c->writes);
cancel_work_sync(&c->ec_stripe_delete_work);
- cancel_delayed_work(&c->pd_controllers_update);
/*
* If we're not doing an emergency shutdown, we want to wait on
return ret;
}
- schedule_delayed_work(&c->pd_controllers_update, 5 * HZ);
-
schedule_work(&c->ec_stripe_delete_work);
return 0;
cancel_work_sync(&ca->io_error_work);
cancel_work_sync(&c->btree_write_error_work);
- cancel_delayed_work_sync(&c->pd_controllers_update);
cancel_work_sync(&c->read_only_work);
}
rw_attribute(copy_gc_enabled);
read_attribute(copy_gc_wait);
-sysfs_pd_controller_attribute(copy_gc);
rw_attribute(rebalance_enabled);
sysfs_pd_controller_attribute(rebalance);
read_attribute(new_stripes);
-rw_attribute(pd_controllers_update_seconds);
-
read_attribute(io_timers_read);
read_attribute(io_timers_write);
sysfs_printf(copy_gc_enabled, "%i", c->copy_gc_enabled);
- sysfs_print(pd_controllers_update_seconds,
- c->pd_controllers_update_seconds);
-
sysfs_printf(rebalance_enabled, "%i", c->rebalance.enabled);
sysfs_pd_controller_show(rebalance, &c->rebalance.pd); /* XXX */
- sysfs_pd_controller_show(copy_gc, &c->copygc_pd);
sysfs_hprint(copy_gc_wait,
max(0LL, c->copygc_wait -
atomic64_read(&c->io_clock[WRITE].now)) << 9);
return ret;
}
- sysfs_strtoul(pd_controllers_update_seconds,
- c->pd_controllers_update_seconds);
sysfs_pd_controller_store(rebalance, &c->rebalance.pd);
- sysfs_pd_controller_store(copy_gc, &c->copygc_pd);
sysfs_strtoul(promote_whole_extents, c->promote_whole_extents);
&sysfs_rebalance_enabled,
&sysfs_rebalance_work,
sysfs_pd_controller_files(rebalance),
- sysfs_pd_controller_files(copy_gc),
&sysfs_new_stripes,