diff options
Diffstat (limited to 'fs/bcachefs/opts.c')
-rw-r--r-- | fs/bcachefs/opts.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c index 9f5684ec056a..bd5faafc9aa7 100644 --- a/fs/bcachefs/opts.c +++ b/fs/bcachefs/opts.c @@ -518,7 +518,8 @@ void bch2_opts_to_text(struct printbuf *out, } } -int bch2_opt_hook_pre_set(struct bch_fs *c, struct bch_dev *ca, enum bch_opt_id id, u64 v) +int bch2_opt_hook_pre_set(struct bch_fs *c, struct bch_dev *ca, u64 inum, enum bch_opt_id id, u64 v, + bool change) { int ret = 0; @@ -531,6 +532,8 @@ int bch2_opt_hook_pre_set(struct bch_fs *c, struct bch_dev *ca, enum bch_opt_id case Opt_compression: case Opt_background_compression: ret = bch2_check_set_has_compressed_data(c, v); + if (ret) + return ret; break; case Opt_erasure_code: if (v) @@ -540,13 +543,26 @@ int bch2_opt_hook_pre_set(struct bch_fs *c, struct bch_dev *ca, enum bch_opt_id break; } + if (change && + (id == Opt_foreground_target || + id == Opt_background_target || + id == Opt_promote_target || + id == Opt_compression || + id == Opt_background_compression || + id == Opt_data_checksum || + id == Opt_data_replicas)) { + ret = bch2_set_rebalance_needs_scan(c, inum); + if (ret) + return ret; + } + return ret; } int bch2_opts_hooks_pre_set(struct bch_fs *c) { for (unsigned i = 0; i < bch2_opts_nr; i++) { - int ret = bch2_opt_hook_pre_set(c, NULL, i, bch2_opt_get_by_id(&c->opts, i)); + int ret = bch2_opt_hook_pre_set(c, NULL, 0, i, bch2_opt_get_by_id(&c->opts, i), false); if (ret) return ret; } @@ -555,27 +571,20 @@ int bch2_opts_hooks_pre_set(struct bch_fs *c) } void bch2_opt_hook_post_set(struct bch_fs *c, struct bch_dev *ca, u64 inum, - struct bch_opts *new_opts, enum bch_opt_id id) + enum bch_opt_id id, u64 v) { + if (id == Opt_foreground_target || + id == Opt_background_target || + id == Opt_promote_target || + id == Opt_compression || + id == Opt_background_compression || + id == Opt_data_checksum || + id == Opt_data_replicas) { + bch2_set_rebalance_needs_scan(c, inum); + bch2_rebalance_wakeup(c); + } + switch (id) { - case Opt_foreground_target: - if (new_opts->foreground_target && - !new_opts->background_target) - bch2_set_rebalance_needs_scan(c, inum); - break; - case Opt_compression: - if (new_opts->compression && - !new_opts->background_compression) - bch2_set_rebalance_needs_scan(c, inum); - break; - case Opt_background_target: - if (new_opts->background_target) - bch2_set_rebalance_needs_scan(c, inum); - break; - case Opt_background_compression: - if (new_opts->background_compression) - bch2_set_rebalance_needs_scan(c, inum); - break; case Opt_rebalance_enabled: bch2_rebalance_wakeup(c); break; @@ -600,7 +609,7 @@ void bch2_opt_hook_post_set(struct bch_fs *c, struct bch_dev *ca, u64 inum, * upgrades at runtime as well, but right now there's nothing * that does that: */ - if (new_opts->version_upgrade == BCH_VERSION_UPGRADE_incompatible) + if (v == BCH_VERSION_UPGRADE_incompatible) bch2_sb_upgrade_incompat(c); break; default: |