Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip async abstract backend #10264

Merged
merged 16 commits into from Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Expand Up @@ -424,6 +424,8 @@ set(libcommon_files
msg/async/Event.cc
msg/async/EventEpoll.cc
msg/async/EventSelect.cc
msg/async/Stack.cc
msg/async/PosixStack.cc
msg/async/net_handler.cc
${xio_common_srcs}
msg/msg_types.cc
Expand Down
2 changes: 2 additions & 0 deletions src/common/ceph_context.cc
Expand Up @@ -472,6 +472,7 @@ CephContext::CephContext(uint32_t module_type_, int init_flags_)
{
ceph_spin_init(&_service_thread_lock);
ceph_spin_init(&_associated_objs_lock);
ceph_spin_init(&_fork_watchers_lock);
ceph_spin_init(&_feature_lock);
ceph_spin_init(&_cct_perf_lock);

Expand Down Expand Up @@ -575,6 +576,7 @@ CephContext::~CephContext()

delete _conf;
ceph_spin_destroy(&_service_thread_lock);
ceph_spin_destroy(&_fork_watchers_lock);
ceph_spin_destroy(&_associated_objs_lock);
ceph_spin_destroy(&_feature_lock);
ceph_spin_destroy(&_cct_perf_lock);
Expand Down
30 changes: 30 additions & 0 deletions src/common/ceph_context.h
Expand Up @@ -177,6 +177,33 @@ class CephContext {
return _set_gid_string;
}

class ForkWatcher {
public:
virtual ~ForkWatcher() {}
virtual void handle_pre_fork() = 0;
virtual void handle_post_fork() = 0;
};

void register_fork_watcher(ForkWatcher *w) {
ceph_spin_lock(&_fork_watchers_lock);
_fork_watchers.push_back(w);
ceph_spin_unlock(&_fork_watchers_lock);
}

void notify_pre_fork() {
ceph_spin_lock(&_fork_watchers_lock);
for (auto &&t : _fork_watchers)
t->handle_pre_fork();
ceph_spin_unlock(&_fork_watchers_lock);
}

void notify_post_fork() {
ceph_spin_lock(&_fork_watchers_lock);
for (auto &&t : _fork_watchers)
t->handle_post_fork();
ceph_spin_unlock(&_fork_watchers_lock);
}

private:
struct SingletonWrapper : boost::noncopyable {
virtual ~SingletonWrapper() {}
Expand Down Expand Up @@ -235,6 +262,9 @@ class CephContext {
ceph_spinlock_t _associated_objs_lock;
std::map<std::string, SingletonWrapper*> _associated_objs;

ceph_spinlock_t _fork_watchers_lock;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use Spinlock?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

std::vector<ForkWatcher*> _fork_watchers;

// crypto
CryptoHandler *_crypto_none;
CryptoHandler *_crypto_aes;
Expand Down
5 changes: 3 additions & 2 deletions src/common/config_opts.h
Expand Up @@ -197,8 +197,9 @@ OPTION(ms_inject_delay_probability, OPT_DOUBLE, 0) // range [0, 1]
OPTION(ms_inject_internal_delays, OPT_DOUBLE, 0) // seconds
OPTION(ms_dump_on_send, OPT_BOOL, false) // hexdump msg to log on send
OPTION(ms_dump_corrupt_message_level, OPT_INT, 1) // debug level to hexdump undecodeable messages at
OPTION(ms_async_op_threads, OPT_INT, 3) // number of worker processing threads for async messenger created on init
OPTION(ms_async_max_op_threads, OPT_INT, 5) // max number of worker processing threads for async messenger
OPTION(ms_async_transport_type, OPT_STR, "posix")
OPTION(ms_async_op_threads, OPT_U64, 3) // number of worker processing threads for async messenger created on init
OPTION(ms_async_max_op_threads, OPT_U64, 5) // max number of worker processing threads for async messenger
OPTION(ms_async_set_affinity, OPT_BOOL, true)
// example: ms_async_affinity_cores = 0,1
// The number of coreset is expected to equal to ms_async_op_threads, otherwise
Expand Down
2 changes: 2 additions & 0 deletions src/global/global_init.cc
Expand Up @@ -339,6 +339,7 @@ int global_init_prefork(CephContext *cct)
return -1;
}

cct->notify_pre_fork();
// stop log thread
cct->_log->flush();
cct->_log->stop();
Expand Down Expand Up @@ -370,6 +371,7 @@ void global_init_postfork_start(CephContext *cct)
{
// restart log thread
cct->_log->start();
cct->notify_post_fork();

/* This is the old trick where we make file descriptors 0, 1, and possibly 2
* point to /dev/null.
Expand Down
4 changes: 4 additions & 0 deletions src/msg/Makefile.am
Expand Up @@ -22,6 +22,8 @@ libmsg_la_SOURCES += \
msg/async/AsyncMessenger.cc \
msg/async/Event.cc \
msg/async/net_handler.cc \
msg/async/Stack.cc \
msg/async/PosixStack.cc \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should squash this change with the previous two commits.

msg/async/EventSelect.cc

if LINUX
Expand All @@ -47,6 +49,8 @@ noinst_HEADERS += \
msg/async/Event.h \
msg/async/EventEpoll.h \
msg/async/EventSelect.h \
msg/async/Stack.h \
msg/async/PosixStack.h \
msg/async/net_handler.h

if LINUX
Expand Down