Skip to content

Commit

Permalink
mds: fix null pointer dereference in Locker::handle_client_caps
Browse files Browse the repository at this point in the history
Locker::handle_client_caps delays processing cap message if the
corresponding inode is freezing or frozen. When the message gets
processed, client can have already closed the session.

Fixes: http://tracker.ceph.com/issues/18306
Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit e281a0b)
  • Loading branch information
ukernel authored and smithfarm committed Apr 14, 2017
1 parent eb84959 commit 9533509
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/mds/Locker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2495,6 +2495,18 @@ void Locker::handle_client_caps(MClientCaps *m)
<< " op " << ceph_cap_op_name(m->get_op()) << dendl;

if (!mds->is_clientreplay() && !mds->is_active() && !mds->is_stopping()) {
if (!session) {
dout(5) << " no session, dropping " << *m << dendl;
m->put();
return;
}
if (session->is_closed() ||
session->is_closing() ||
session->is_killing()) {
dout(7) << " session closed|closing|killing, dropping " << *m << dendl;
m->put();
return;
}
if (mds->is_reconnect() &&
m->get_dirty() && m->get_client_tid() > 0 &&
!session->have_completed_flush(m->get_client_tid())) {
Expand All @@ -2504,7 +2516,7 @@ void Locker::handle_client_caps(MClientCaps *m)
return;
}

if (m->get_client_tid() > 0 &&
if (m->get_client_tid() > 0 && session &&
session->have_completed_flush(m->get_client_tid())) {
dout(7) << "handle_client_caps already flushed tid " << m->get_client_tid()
<< " for client." << client << dendl;
Expand All @@ -2531,7 +2543,7 @@ void Locker::handle_client_caps(MClientCaps *m)
}

// "oldest flush tid" > 0 means client uses unique TID for each flush
if (m->get_oldest_flush_tid() > 0) {
if (m->get_oldest_flush_tid() > 0 && session) {
if (session->trim_completed_flushes(m->get_oldest_flush_tid())) {
mds->mdlog->get_current_segment()->touched_sessions.insert(session->info.inst.name);

Expand Down

0 comments on commit 9533509

Please sign in to comment.