]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common/config: promote lock from md_config_t to ConfigProxy
authorKefu Chai <kchai@redhat.com>
Sun, 15 Jul 2018 08:49:59 +0000 (16:49 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 24 Jul 2018 02:15:26 +0000 (10:15 +0800)
commite406d8eb9e1deb801ecb346169eaaf96adbb4b53
treed0e30c5dc706408f73d4c54c19049b46e673f5d4
parent3ce6a511d1df1f650df97853f65dd51bae0f2c3e
common/config: promote lock from md_config_t to ConfigProxy

seastar's ConfigProxy and alien's ConfigProxy follow different threading
models and expose different methods. the former updates a setting with 3
steps:
1. create a local copy of current setting, and apply the proposed change
   to the copy
2. populate the updated change with a foreign_ptr<> to all shards
   (including itself)
3. on each shards, call apply_changes() to get the interested observers
   updated, please note, apply_changes() should only update the local
   observers on current shard.

while the alien's ConfigProxy do all the job in a single synchronized
call,
but we can split it into a finer-grained steps:
1. apply the proposed change in-place
2. apply_changes() to get the interested observers updated.

so, to reuse the code across these two implementations, for instance,
set_mon_vals() will be implemented in ConfigProxy instead, so we can
have different behavior in different ConfigProxy classes. if we keep
using the existing single-piece md_config_t::set_mon_vals(), we have no
chance to differentiate the apply_changes() for seastar port. but the
alien implementation requires a grand lock protecting set_val() and
apply_changes(), so we have to move the lock from md_config_t up to
ConfigProxy. it's also simpler this way, as we don't need an extra layer
to have a dummy Mutex for seastar's ConfigProxy. as only the alien's
ConfigProxy requires the lock.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/config.cc
src/common/config.h
src/common/config_proxy.h