Skip to content

Commit

Permalink
common: add LockPolicy to md_config_t
Browse files Browse the repository at this point in the history
before this change, we guard all read/write access to md_config_t with a
lock. after this change, this policy is optional. and is controled by a
enum named `LockPolicy`. we will use `md_config_impl<LockPolicy::SINGLE>`
to implement the lockless config used by crimson/osd.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Jun 27, 2018
1 parent af13810 commit 2df0a50
Show file tree
Hide file tree
Showing 61 changed files with 330 additions and 195 deletions.
2 changes: 1 addition & 1 deletion src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13940,7 +13940,7 @@ const char** Client::get_tracked_conf_keys() const
return keys;
}

void Client::handle_conf_change(const struct md_config_t *conf,
void Client::handle_conf_change(const md_config_t *conf,
const std::set <std::string> &changed)
{
Mutex::Locker lock(client_lock);
Expand Down
2 changes: 1 addition & 1 deletion src/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ class Client : public Dispatcher, public md_config_obs_t {
int test_dentry_handling(bool can_invalidate);

const char** get_tracked_conf_keys() const override;
void handle_conf_change(const struct md_config_t *conf,
void handle_conf_change(const md_config_t *conf,
const std::set <std::string> &changed) override;
uint32_t get_deleg_timeout() { return deleg_timeout; }
int set_deleg_timeout(uint32_t timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/common/Mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

#include "include/assert.h"
#include "lockdep.h"
#include "common/ceph_context.h"

#include <string>
#include <pthread.h>

using namespace ceph;

class CephContext;
class PerfCounters;

enum {
Expand Down
1 change: 1 addition & 0 deletions src/common/PluginRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef CEPH_COMMON_PLUGINREGISTRY_H
#define CEPH_COMMON_PLUGINREGISTRY_H

#include <map>
#include "common/Mutex.h"

class CephContext;
Expand Down
4 changes: 2 additions & 2 deletions src/common/TracepointProvider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ TracepointProvider::~TracepointProvider() {
}

void TracepointProvider::handle_conf_change(
const struct md_config_t *conf, const std::set<std::string> &changed) {
const md_config_t *conf, const std::set<std::string> &changed) {
if (changed.count(m_config_keys[0])) {
verify_config(conf);
}
}

void TracepointProvider::verify_config(const struct md_config_t *conf) {
void TracepointProvider::verify_config(const md_config_t *conf) {
Mutex::Locker locker(m_lock);
if (m_handle) {
return;
Expand Down
7 changes: 3 additions & 4 deletions src/common/TracepointProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
#ifndef CEPH_TRACEPOINT_PROVIDER_H
#define CEPH_TRACEPOINT_PROVIDER_H

#include "common/ceph_context.h"
#include "common/config_obs.h"
#include "common/Mutex.h"
#include <dlfcn.h>

struct md_config_t;

class TracepointProvider : public md_config_obs_t {
public:
struct Traits {
Expand Down Expand Up @@ -66,7 +65,7 @@ class TracepointProvider : public md_config_obs_t {
const char** get_tracked_conf_keys() const override {
return m_config_keys;
}
void handle_conf_change(const struct md_config_t *conf,
void handle_conf_change(const md_config_t *conf,
const std::set <std::string> &changed) override;

private:
Expand All @@ -77,7 +76,7 @@ class TracepointProvider : public md_config_obs_t {
Mutex m_lock;
void* m_handle = nullptr;

void verify_config(const struct md_config_t *conf);
void verify_config(const md_config_t *conf);
};

#endif // CEPH_TRACEPOINT_PROVIDER_H
2 changes: 1 addition & 1 deletion src/common/WorkQueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ThreadPool::~ThreadPool()
delete[] _conf_keys;
}

void ThreadPool::handle_conf_change(const struct md_config_t *conf,
void ThreadPool::handle_conf_change(const md_config_t *conf,
const std::set <std::string> &changed)
{
if (changed.count(_thread_num_option)) {
Expand Down
3 changes: 2 additions & 1 deletion src/common/WorkQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "Cond.h"
#include "include/unordered_map.h"
#include "common/config_obs.h"
#include "common/HeartbeatMap.h"

#include <atomic>
Expand Down Expand Up @@ -89,7 +90,7 @@ class ThreadPool : public md_config_obs_t {
const char **get_tracked_conf_keys() const override {
return _conf_keys;
}
void handle_conf_change(const struct md_config_t *conf,
void handle_conf_change(const md_config_t *conf,
const std::set <std::string> &changed) override;

public:
Expand Down
2 changes: 2 additions & 0 deletions src/common/ceph_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#include "auth/Crypto.h"
#include "include/str_list.h"
#include "common/config.h"
#include "common/config_obs.h"
#include "common/PluginRegistry.h"
#include "common/valgrind.h"
#include "include/spinlock.h"
Expand Down
3 changes: 1 addition & 2 deletions src/common/ceph_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "common/cmdparse.h"
#include "common/code_environment.h"
#include "common/config_fwd.h"

#include "include/spinlock.h"

Expand All @@ -38,8 +39,6 @@ class AdminSocket;
class CephContextServiceThread;
class PerfCountersCollection;
class PerfCounters;
class md_config_obs_t;
struct md_config_t;
class CephContextHook;
class CephContextObs;
class CryptoHandler;
Expand Down
1 change: 1 addition & 0 deletions src/common/ceph_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*
*/

#include "common/ceph_context.h"
#include "common/config.h"
#include "ceph_crypto.h"

Expand Down
Loading

0 comments on commit 2df0a50

Please sign in to comment.