From ab30ff20d6c55a69e6298362c15190def1567da7 Mon Sep 17 00:00:00 2001 From: Varada Kari Date: Fri, 15 May 2015 18:39:10 +0530 Subject: [PATCH] KeyValueStore: optimize the object header writes Don't write the object header when any strip is overwritten. write header when new strip is added or any header fields are modified. Signed-off-by: Varada Kari --- src/os/KeyValueStore.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index 589227f987f..f93be78f9bc 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -98,6 +98,7 @@ int StripObjectMap::save_strip_header(StripObjectHeaderRef strip_header, ::encode(*strip_header, strip_header->header->data); set_header(strip_header->cid, strip_header->oid, *(strip_header->header), t); + strip_header->updated = false; } return 0; } @@ -462,11 +463,13 @@ int KeyValueStore::BufferTransaction::submit_transaction() if (header->deleted) continue; - r = store->backend->save_strip_header(header, t); + if (header->updated) { + r = store->backend->save_strip_header(header, t); - if (r < 0) { - dout(10) << __func__ << " save strip header failed " << dendl; - goto out; + if (r < 0) { + dout(10) << __func__ << " save strip header failed " << dendl; + goto out; + } } } @@ -1871,6 +1874,7 @@ int KeyValueStore::_generic_write(StripObjectMap::StripObjectHeaderRef header, if (len + offset > header->max_size) { header->max_size = len + offset; header->bits.resize(header->max_size/header->strip_size+1); + header->updated = true; } vector extents; @@ -1931,13 +1935,13 @@ int KeyValueStore::_generic_write(StripObjectMap::StripObjectHeaderRef header, value.append_zero(header->strip_size-value.length()); header->bits[iter->no] = 1; + header->updated = true; } assert(value.length() == header->strip_size); values[key].swap(value); } assert(bl_offset == len); - header->updated = true; t.set_buffer_keys(header, OBJECT_STRIP_PREFIX, values); dout(10) << __func__ << " " << header->cid << "/" << header->oid << " " << offset << "~" << len << " = " << r << dendl;