From 62fd382fbf10f2b78946426644d445549a7ebed1 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Sat, 1 Mar 2014 14:33:11 -0800 Subject: [PATCH] osd_types,PG: trim mod_desc for log entries to min size In the event that mod_desc.bl contains pointers into a large message buffer, we'd otherwise end up keeping around the entire MOSDECSubOpWrite which created each log entry. Fixes: #7539 Signed-off-by: Samuel Just --- src/osd/PG.cc | 6 ++++++ src/osd/osd_types.h | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index a525b7195299c..3af870fa9d1b1 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2631,6 +2631,12 @@ void PG::add_log_entry(pg_log_entry_t& e, bufferlist& log_bl) if (e.user_version > info.last_user_version) info.last_user_version = e.user_version; + /** + * Make sure we don't keep around more than we need to in the + * in-memory log + */ + e.mod_desc.trim_bl(); + // log mutation pg_log.add(e); dout(10) << "add_log_entry " << e << dendl; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index f74723bbbaac1..4c03fc0a622f9 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1856,6 +1856,16 @@ public: bool empty() const { return can_local_rollback && (bl.length() == 0); } + + /** + * Create fresh copy of bl bytes to avoid keeping large buffers around + * in the case that bl contains ptrs which point into a much larger + * message buffer + */ + void trim_bl() { + if (bl.length() > 0) + bl.rebuild(); + } void encode(bufferlist &bl) const; void decode(bufferlist::iterator &bl); void dump(Formatter *f) const; -- 2.39.5