From 45c388f2209e169da06fb9a946b32d553c77cff6 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 10 Feb 2015 20:04:17 -0800 Subject: [PATCH] objecter: protect linger_op last_error and registered fields These are read and updated in places where using the session lock or objecter->rwlock wouldn't make sense, so protect them with watch_lock instead. last_error was already mostly protected by this lock, it was just missing in tick(). Fixes: #10831 Backport: giant Signed-off-by: Josh Durgin --- src/osdc/Objecter.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 42edeb1c8543..af90732f7271 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -419,6 +419,7 @@ void Objecter::_send_linger(LingerOp *info) vector opv; Context *onack = NULL; Context *oncommit = NULL; + info->watch_lock.get_read(); // just to read registered status if (info->registered && info->is_watch) { ldout(cct, 15) << "send_linger " << info->linger_id << " reconnect" << dendl; opv.push_back(OSDOp()); @@ -434,6 +435,7 @@ void Objecter::_send_linger(LingerOp *info) onack = new C_Linger_Register(this, info); oncommit = new C_Linger_Commit(this, info); } + info->watch_lock.put_read(); Op *o = new Op(info->target.base_oid, info->target.base_oloc, opv, info->target.flags | CEPH_OSD_FLAG_READ, onack, oncommit, @@ -478,6 +480,7 @@ void Objecter::_linger_register(LingerOp *info, int r) void Objecter::_linger_commit(LingerOp *info, int r) { + RWLock::WLocker wl(info->watch_lock); ldout(cct, 10) << "_linger_commit " << info->linger_id << dendl; if (info->on_reg_commit) { info->on_reg_commit->complete(r); @@ -1879,6 +1882,7 @@ void Objecter::tick() p != s->linger_ops.end(); ++p) { LingerOp *op = p->second; + RWLock::WLocker wl(op->watch_lock); assert(op->session); ldout(cct, 10) << " pinging osd that serves lingering tid " << p->first << " (osd." << op->session->osd << ")" << dendl; toping.insert(op->session); -- 2.47.3