From 2ecb3b7f4a49c574bc178a106c6bf0d8247f2a5e Mon Sep 17 00:00:00 2001 From: Zhi Zhang Date: Wed, 22 Jul 2015 10:54:53 +0800 Subject: [PATCH] Fh ref count will leak if readahead does not need to do read from osd The 3c8cdeacf46ae4031189d2ef6948aa3b6ab4ae43 backport introduced a leak. http://tracker.ceph.com/issues/12319 Fixes: #12319 Signed-off-by: Zhi Zhang --- src/client/Client.cc | 5 ++++- src/client/Client.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index fc3b52a254273..446f0d1260889 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7054,11 +7054,14 @@ Client::C_Readahead::C_Readahead(Client *c, Fh *f) : f->get(); } +Client::C_Readahead::~C_Readahead() { + client->_put_fh(f); +} + void Client::C_Readahead::finish(int r) { lgeneric_subdout(client->cct, client, 20) << "client." << client->get_nodeid() << " " << "C_Readahead on " << f->inode << dendl; client->put_cap_ref(f->inode, CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE); f->readahead.dec_pending(); - client->_put_fh(f); } int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl) diff --git a/src/client/Client.h b/src/client/Client.h index 14f47accae93b..b476f5eff8597 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -635,6 +635,7 @@ private: Client *client; Fh *f; C_Readahead(Client *c, Fh *f); + ~C_Readahead(); void finish(int r); }; -- 2.39.5