Skip to content

Commit

Permalink
Merge pull request #6143: small probability sigabrt when setting rado…
Browse files Browse the repository at this point in the history
…s_osd_op_timeout

Reviewed-by: Loic Dachary <ldachary@redhat.com>
  • Loading branch information
Loic Dachary committed Nov 19, 2015
2 parents 2955c3b + 394fbfc commit 0e9d356
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 39 deletions.
61 changes: 26 additions & 35 deletions src/osdc/Objecter.cc
Expand Up @@ -1328,7 +1328,7 @@ void Objecter::_check_op_pool_dne(Op *op, bool session_locked)
if (!session_locked) {
s->lock.get_write();
}
_finish_op(op);
_finish_op(op, 0);
if (!session_locked) {
s->lock.unlock();
}
Expand Down Expand Up @@ -1993,13 +1993,10 @@ class C_CancelOp : public Context
ceph_tid_t tid;
Objecter *objecter;
public:
C_CancelOp(Objecter *objecter) : objecter(objecter) {}
C_CancelOp(ceph_tid_t tid, Objecter *objecter) : tid(tid), objecter(objecter) {}
void finish(int r) {
objecter->op_cancel(tid, -ETIMEDOUT);
}
void set_tid(ceph_tid_t _tid) {
tid = _tid;
}
};

ceph_tid_t Objecter::op_submit(Op *op, int *ctx_budget)
Expand Down Expand Up @@ -2028,21 +2025,15 @@ ceph_tid_t Objecter::_op_submit_with_budget(Op *op, RWLock::Context& lc, int *ct
}
}

C_CancelOp *cb = NULL;
if (osd_timeout > 0) {
cb = new C_CancelOp(this);
op->ontimeout = cb;
}

ceph_tid_t tid = _op_submit(op, lc);

if (cb) {
cb->set_tid(tid);
if (op->tid == 0)
op->tid = last_tid.inc();
op->ontimeout = new C_CancelOp(op->tid, this);
Mutex::Locker l(timer_lock);
timer.add_event_after(osd_timeout, op->ontimeout);
}

return tid;
return _op_submit(op, lc);
}

void Objecter::_send_op_account(Op *op)
Expand Down Expand Up @@ -2233,7 +2224,7 @@ int Objecter::op_cancel(OSDSession *s, ceph_tid_t tid, int r)
op->oncommit_sync = NULL;
}
_op_cancel_map_check(op);
_finish_op(op);
_finish_op(op, r);
s->lock.unlock();

return 0;
Expand Down Expand Up @@ -2717,10 +2708,10 @@ void Objecter::_cancel_linger_op(Op *op)
num_uncommitted.dec();
}

_finish_op(op);
_finish_op(op, 0);
}

void Objecter::_finish_op(Op *op)
void Objecter::_finish_op(Op *op, int r)
{
ldout(cct, 15) << "finish_op " << op->tid << dendl;

Expand All @@ -2729,7 +2720,7 @@ void Objecter::_finish_op(Op *op)
if (!op->ctx_budgeted && op->budgeted)
put_op_budget(op);

if (op->ontimeout) {
if (op->ontimeout && r != -ETIMEDOUT) {
Mutex::Locker l(timer_lock);
timer.cancel_event(op->ontimeout);
}
Expand Down Expand Up @@ -2758,7 +2749,7 @@ void Objecter::finish_op(OSDSession *session, ceph_tid_t tid)

Op *op = iter->second;

_finish_op(op);
_finish_op(op, 0);
}

MOSDOp *Objecter::_prepare_osd_op(Op *op)
Expand Down Expand Up @@ -3080,7 +3071,7 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m)
// done with this tid?
if (!op->onack && !op->oncommit && !op->oncommit_sync) {
ldout(cct, 15) << "handle_osd_op_reply completed tid " << tid << dendl;
_finish_op(op);
_finish_op(op, 0);
}

ldout(cct, 5) << num_unacked.read() << " unacked, " << num_uncommitted.read() << " uncommitted" << dendl;
Expand Down Expand Up @@ -3677,7 +3668,7 @@ void Objecter::handle_pool_op_reply(MPoolOpReply *m)
}
iter = pool_ops.find(tid);
if (iter != pool_ops.end()) {
_finish_pool_op(op);
_finish_pool_op(op, 0);
}
} else {
ldout(cct, 10) << "unknown request " << tid << dendl;
Expand Down Expand Up @@ -3708,17 +3699,17 @@ int Objecter::pool_op_cancel(ceph_tid_t tid, int r)
if (op->onfinish)
op->onfinish->complete(r);

_finish_pool_op(op);
_finish_pool_op(op, r);
return 0;
}

void Objecter::_finish_pool_op(PoolOp *op)
void Objecter::_finish_pool_op(PoolOp *op, int r)
{
assert(rwlock.is_wlocked());
pool_ops.erase(op->tid);
logger->set(l_osdc_poolop_active, pool_ops.size());

if (op->ontimeout) {
if (op->ontimeout && r != -ETIMEDOUT) {
Mutex::Locker l(timer_lock);
timer.cancel_event(op->ontimeout);
}
Expand Down Expand Up @@ -3796,7 +3787,7 @@ void Objecter::handle_get_pool_stats_reply(MGetPoolStatsReply *m)
last_seen_pgmap_version = m->version;
}
op->onfinish->complete(0);
_finish_pool_stat_op(op);
_finish_pool_stat_op(op, 0);
} else {
ldout(cct, 10) << "unknown request " << tid << dendl;
}
Expand All @@ -3821,18 +3812,18 @@ int Objecter::pool_stat_op_cancel(ceph_tid_t tid, int r)
PoolStatOp *op = it->second;
if (op->onfinish)
op->onfinish->complete(r);
_finish_pool_stat_op(op);
_finish_pool_stat_op(op, r);
return 0;
}

void Objecter::_finish_pool_stat_op(PoolStatOp *op)
void Objecter::_finish_pool_stat_op(PoolStatOp *op, int r)
{
assert(rwlock.is_wlocked());

poolstat_ops.erase(op->tid);
logger->set(l_osdc_poolstat_active, poolstat_ops.size());

if (op->ontimeout) {
if (op->ontimeout && r != -ETIMEDOUT) {
Mutex::Locker l(timer_lock);
timer.cancel_event(op->ontimeout);
}
Expand Down Expand Up @@ -3903,7 +3894,7 @@ void Objecter::handle_fs_stats_reply(MStatfsReply *m)
if (m->h.version > last_seen_pgmap_version)
last_seen_pgmap_version = m->h.version;
op->onfinish->complete(0);
_finish_statfs_op(op);
_finish_statfs_op(op, 0);
} else {
ldout(cct, 10) << "unknown request " << tid << dendl;
}
Expand All @@ -3928,18 +3919,18 @@ int Objecter::statfs_op_cancel(ceph_tid_t tid, int r)
StatfsOp *op = it->second;
if (op->onfinish)
op->onfinish->complete(r);
_finish_statfs_op(op);
_finish_statfs_op(op, r);
return 0;
}

void Objecter::_finish_statfs_op(StatfsOp *op)
void Objecter::_finish_statfs_op(StatfsOp *op, int r)
{
assert(rwlock.is_wlocked());

statfs_ops.erase(op->tid);
logger->set(l_osdc_statfs_active, statfs_ops.size());

if (op->ontimeout) {
if (op->ontimeout && r != -ETIMEDOUT) {
Mutex::Locker l(timer_lock);
timer.cancel_event(op->ontimeout);
}
Expand Down Expand Up @@ -4505,7 +4496,7 @@ int Objecter::command_op_cancel(OSDSession *s, ceph_tid_t tid, int r)

CommandOp *op = it->second;
_command_cancel_map_check(op);
_finish_command(op, -ETIMEDOUT, "");
_finish_command(op, r, "");
return 0;
}

Expand All @@ -4519,7 +4510,7 @@ void Objecter::_finish_command(CommandOp *c, int r, string rs)
if (c->onfinish)
c->onfinish->complete(r);

if (c->ontimeout) {
if (c->ontimeout && r != -ETIMEDOUT) {
Mutex::Locker l(timer_lock);
timer.cancel_event(c->ontimeout);
}
Expand Down
8 changes: 4 additions & 4 deletions src/osdc/Objecter.h
Expand Up @@ -1741,7 +1741,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
void _send_op_account(Op *op);
void _cancel_linger_op(Op *op);
void finish_op(OSDSession *session, ceph_tid_t tid);
void _finish_op(Op *op);
void _finish_op(Op *op, int r);
static bool is_pg_changed(
int oldprimary,
const vector<int>& oldacting,
Expand Down Expand Up @@ -2469,7 +2469,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
private:
void pool_op_submit(PoolOp *op);
void _pool_op_submit(PoolOp *op);
void _finish_pool_op(PoolOp *op);
void _finish_pool_op(PoolOp *op, int r);
void _do_delete_pool(int64_t pool, Context *onfinish);
public:
int create_pool_snap(int64_t pool, string& snapName, Context *onfinish);
Expand All @@ -2495,7 +2495,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
void get_pool_stats(list<string>& pools, map<string,pool_stat_t> *result,
Context *onfinish);
int pool_stat_op_cancel(ceph_tid_t tid, int r);
void _finish_pool_stat_op(PoolStatOp *op);
void _finish_pool_stat_op(PoolStatOp *op, int r);

// ---------------------------
// df stats
Expand All @@ -2505,7 +2505,7 @@ class Objecter : public md_config_obs_t, public Dispatcher {
void handle_fs_stats_reply(MStatfsReply *m);
void get_fs_stats(struct ceph_statfs& result, Context *onfinish);
int statfs_op_cancel(ceph_tid_t tid, int r);
void _finish_statfs_op(StatfsOp *op);
void _finish_statfs_op(StatfsOp *op, int r);

// ---------------------------
// some scatter/gather hackery
Expand Down

0 comments on commit 0e9d356

Please sign in to comment.