Skip to content

Commit

Permalink
os/bluestore: make preferred csum order a function of expected_write_…
Browse files Browse the repository at this point in the history
…size

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Jun 15, 2016
1 parent d9648dc commit 0e8294c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6085,7 +6085,7 @@ int BlueStore::_do_write(
dout(20) << __func__ << " will do buffered write" << dendl;
wctx.buffered = true;
}
wctx.csum_order = block_size_order;
wctx.csum_order = MAX(block_size_order, o->onode.get_preferred_csum_order());

// compression parameters
unsigned alloc_hints = o->onode.alloc_hint_flags;
Expand All @@ -6101,6 +6101,7 @@ int BlueStore::_do_write(
(alloc_hints & (CEPH_OSD_ALLOC_HINT_FLAG_IMMUTABLE|
CEPH_OSD_ALLOC_HINT_FLAG_APPEND_ONLY)) &&
(alloc_hints & CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_WRITE) == 0) {
dout(20) << __func__ << " will prefer large blob and csum sizes" << dendl;
wctx.comp_blob_size = comp_max_blob_size;
wctx.csum_order = min_alloc_size_order;
} else {
Expand Down
9 changes: 9 additions & 0 deletions src/os/bluestore/bluestore_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,15 @@ void bluestore_onode_t::generate_test_instances(list<bluestore_onode_t*>& o)
// FIXME
}

size_t bluestore_onode_t::get_preferred_csum_order() const
{
uint32_t t = expected_write_size;
if (!t) {
return 0;
}
return ctz(expected_write_size);
}

int bluestore_onode_t::compress_extent_map()
{
if (extent_map.empty())
Expand Down
3 changes: 3 additions & 0 deletions src/os/bluestore/bluestore_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ struct bluestore_onode_t {
expected_write_size(0),
alloc_hint_flags(0) {}

/// get preferred csum chunk size
size_t get_preferred_csum_order() const;

/// find a lextent that includes offset
map<uint64_t,bluestore_lextent_t>::iterator find_lextent(uint64_t offset) {
map<uint64_t,bluestore_lextent_t>::iterator fp =
Expand Down
16 changes: 16 additions & 0 deletions src/test/objectstore/test_bluestore_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,22 @@ TEST(bluestore_blob_t, csum_bench)
}
}

TEST(bluestore_onode_t, get_preferred_csum_order)
{
bluestore_onode_t on;
ASSERT_EQ(0u, on.get_preferred_csum_order());
on.expected_write_size = 4096;
ASSERT_EQ(12u, on.get_preferred_csum_order());
on.expected_write_size = 4096;
ASSERT_EQ(12u, on.get_preferred_csum_order());
on.expected_write_size = 8192;
ASSERT_EQ(13u, on.get_preferred_csum_order());
on.expected_write_size = 8192 + 4096;
ASSERT_EQ(12u, on.get_preferred_csum_order());
on.expected_write_size = 1048576;
ASSERT_EQ(20u, on.get_preferred_csum_order());
}

TEST(bluestore_onode_t, find_lextent)
{
bluestore_onode_t on;
Expand Down

0 comments on commit 0e8294c

Please sign in to comment.