From ef7fdc0a981cae66494d3d34160e2799946ffbde Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 6 Dec 2016 12:00:36 +0800 Subject: [PATCH] os/bluestore: fix potential csum_order overflow Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 83e15e7126eb2..e0089f28b8e30 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8064,8 +8064,13 @@ int BlueStore::_do_write( 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.csum_order = std::max(min_alloc_size_order, - (size_t)ctzl(o->onode.expected_write_size)); + if (o->onode.expected_write_size) { + wctx.csum_order = std::max(min_alloc_size_order, + (size_t)ctzl(o->onode.expected_write_size)); + } else { + wctx.csum_order = min_alloc_size_order; + } + if (wctx.compress) { wctx.target_blob_size = select_option( "compression_max_blob_size",