From f8f909496435dcb889cd7fe7339b1e393abfbbb0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 4 Apr 2017 11:52:24 -0400 Subject: [PATCH] os/bluestore: do not extend blobs with unused bitmap If we resize the blob we need to adjust the resolution of the unused bitmap, and that is only possible for some bit patterns. For now just ignore blobs with unused blocks. Add an assert in add_tail() so that we don't forget that add_tail is (probably) where we'd would do that adjustment. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 5 +++++ src/os/bluestore/bluestore_types.h | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index a58b589f4d6..50642358ce0 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1784,6 +1784,11 @@ bool BlueStore::Blob::try_reuse_blob(uint32_t min_alloc_size, return false; } + // FIXME: in some cases we could reduce unused resolution + if (get_blob().has_unused()) { + return false; + } + if (overflow > 0) { new_blen -= overflow; length -= overflow; diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index 9d9b1e34eb8..e5b62568318 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -863,6 +863,7 @@ public: } void add_tail(uint32_t new_len) { assert(is_mutable()); + assert(!has_unused()); assert(new_len > logical_length); extents.emplace_back( bluestore_pextent_t( @@ -872,9 +873,10 @@ public: if (has_csum()) { bufferptr t; t.swap(csum_data); - csum_data = buffer::create(get_csum_value_size() * logical_length / get_csum_chunk_size()); + csum_data = buffer::create( + get_csum_value_size() * logical_length / get_csum_chunk_size()); csum_data.copy_in(0, t.length(), t.c_str()); - csum_data.zero( t.length(), csum_data.length() - t.length()); + csum_data.zero(t.length(), csum_data.length() - t.length()); } } uint32_t get_release_size(uint32_t min_alloc_size) const { -- 2.47.3