From: Sage Weil Date: Mon, 23 May 2016 19:04:11 +0000 (-0400) Subject: os/bluestore: _do_write_big: limit size of blobs based on compression mode X-Git-Tag: v11.0.0~359^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=931264ecab1a8a3ef74df298a2e2ef8a2adf3730;p=ceph.git os/bluestore: _do_write_big: limit size of blobs based on compression mode We may want to compress in smaller chunks based on hints/policy. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index b957dd979001..cb8c2c576d43 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -5599,21 +5599,30 @@ void BlueStore::_do_write_big( bufferlist::iterator& blp, WriteContext *wctx) { + uint64_t max_blob_len = length; + if (wctx->compress) { + max_blob_len = MIN(length, wctx->comp_blob_size); + } dout(10) << __func__ << " 0x" << std::hex << offset << "~0x" << length + << " max_blob_len 0x" << max_blob_len << std::dec << dendl; - int64_t blob; - bluestore_blob_t *b = o->onode.add_blob(&blob); - b->length = length; - wctx->blob_new.push_back(b); - bufferlist t; - blp.copy(length, t); - wctx->bl_new.push_back(t); - o->onode.punch_hole(offset, length, &wctx->lex_old); - o->onode.extent_map[offset] = bluestore_lextent_t(blob, 0, length, 0); - b->ref_map.get(0, length); - dout(20) << __func__ << " lex 0x" << std::hex << offset << std::dec << ": " - << o->onode.extent_map[offset] << dendl; - dout(20) << __func__ << " blob " << *b << dendl; + while (length > 0) { + int64_t blob; + bluestore_blob_t *b = o->onode.add_blob(&blob); + wctx->blob_new.push_back(b); + b->length = MIN(max_blob_len, length); + bufferlist t; + blp.copy(b->length, t); + wctx->bl_new.push_back(t); + o->onode.punch_hole(offset, length, &wctx->lex_old); + o->onode.extent_map[offset] = bluestore_lextent_t(blob, 0, length, 0); + b->ref_map.get(0, length); + dout(20) << __func__ << " lex 0x" << std::hex << offset << std::dec << ": " + << o->onode.extent_map[offset] << dendl; + dout(20) << __func__ << " blob " << *b << dendl; + offset += b->length; + length -= b->length; + } } int BlueStore::_do_alloc_write( @@ -5756,6 +5765,24 @@ int BlueStore::_do_write( wctx.buffered = true; } + // compression parameters + unsigned alloc_hints = o->onode.alloc_hint_flags; + wctx.compress = + (comp_mode == COMP_FORCE) || + (comp_mode == COMP_AGGRESSIVE && + (alloc_hints & CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE) == 0) || + (comp_mode == COMP_PASSIVE && + (alloc_hints & CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE)); + + if ((alloc_hints & CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_READ) && + (alloc_hints & CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_READ) == 0 && + (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) + wctx.comp_blob_size = comp_max_blob_size; + else + wctx.comp_blob_size = comp_min_blob_size; + // write in buffer cache o->bc.write(txc->seq, offset, bl);