Skip to content

Commit

Permalink
Merge PR ceph#38858 into master
Browse files Browse the repository at this point in the history
* refs/pull/38858/head:
	client/libcephfs: Don't let one unmount screw up another mount

Reviewed-by: Patrick Donnelly <[email protected]>
  • Loading branch information
batrick committed Jan 14, 2021
2 parents 72cc819 + d7dfe68 commit 855c134
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/libcephfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,33 @@
#define DEFAULT_UMASK 002

static mode_t umask_cb(void *);
ceph::async::io_context_pool icp;
namespace {
// Set things up this way so we don't start up threads until mount and
// kill them off when the last mount goes away, but are tolerant to
// multiple mounts of overlapping duration.
std::shared_ptr<ceph::async::io_context_pool> get_icp(CephContext* cct)
{
static std::mutex m;
static std::weak_ptr<ceph::async::io_context_pool> icwp;


std::unique_lock l(m);

auto icp = icwp.lock();
if (icp)
return icp;

icp = std::make_shared<ceph::async::io_context_pool>();
icwp = icp;
icp->start(cct->_conf.get_val<std::uint64_t>("client_asio_thread_count"));
return icp;
}
}

struct ceph_mount_info
{
mode_t umask = DEFAULT_UMASK;
std::shared_ptr<ceph::async::io_context_pool> icp;
public:
explicit ceph_mount_info(CephContext *cct_)
: default_perms(),
Expand Down Expand Up @@ -83,10 +105,10 @@ struct ceph_mount_info
if (!cct->_log->is_started()) {
cct->_log->start();
}
icp = get_icp(cct);

icp.start(cct->_conf.get_val<std::uint64_t>("client_asio_thread_count"));
{
MonClient mc_bootstrap(cct, icp);
MonClient mc_bootstrap(cct, icp->get_io_context());
ret = mc_bootstrap.get_monmap_and_config();
if (ret < 0)
return ret;
Expand All @@ -95,7 +117,7 @@ struct ceph_mount_info
common_init_finish(cct);

//monmap
monclient = new MonClient(cct, icp);
monclient = new MonClient(cct, icp->get_io_context());
ret = -CEPHFS_ERROR_MON_MAP_BUILD; //defined in libcephfs.h;
if (monclient->build_initial_monmap() < 0)
goto fail;
Expand All @@ -105,7 +127,7 @@ struct ceph_mount_info

//at last the client
ret = -CEPHFS_ERROR_NEW_CLIENT; //defined in libcephfs.h;
client = new StandaloneClient(messenger, monclient, icp);
client = new StandaloneClient(messenger, monclient, icp->get_io_context());
if (!client)
goto fail;

Expand Down Expand Up @@ -204,7 +226,7 @@ struct ceph_mount_info
delete messenger;
messenger = nullptr;
}
icp.stop();
icp.reset();
if (monclient) {
delete monclient;
monclient = nullptr;
Expand Down

0 comments on commit 855c134

Please sign in to comment.