return out;
}
-void BlueStore::Blob::discard_unallocated()
+void BlueStore::Blob::discard_unallocated(Collection *coll)
{
if (blob.is_compressed()) {
bool discard = false;
if (blob.can_prune_tail()) {
dirty_blob();
blob.prune_tail();
+ auto cct = coll->store->cct; //used by dout
dout(20) << __func__ << " pruned tail, now " << blob << dendl;
}
}
}
bool BlueStore::Blob::put_ref(
+ Collection *coll,
uint64_t offset,
uint64_t length,
- uint64_t min_release_size,
vector<bluestore_pextent_t> *r)
{
vector<bluestore_pextent_t> logical;
return false;
}
+ auto min_release_size = coll->store->min_alloc_size;
// we cannot release something smaller than our csum chunk size
if (b.has_csum() && b.get_csum_chunk_size() > min_release_size) {
min_release_size = b.get_csum_chunk_size();
other->ref_map.get(dest_offset, length);
}
-void BlueStore::Blob::split(size_t blob_offset, Blob *r)
+void BlueStore::Blob::split(Collection *coll, size_t blob_offset, Blob *r)
{
+ auto cct = coll->store->cct; //used by dout
dout(10) << __func__ << " 0x" << std::hex << blob_offset << std::dec
<< " start " << *this << dendl;
assert(blob.can_split());
#undef dout_prefix
#define dout_prefix *_dout << "bluestore.extentmap(" << this << ") "
-BlueStore::ExtentMap::ExtentMap(CephContext* cct, Onode *o)
- : cct(cct), onode(o),
- inline_bl(cct->_conf->bluestore_extent_map_inline_shard_prealloc_size) {
+BlueStore::ExtentMap::ExtentMap(Onode *o)
+ : onode(o),
+ inline_bl(
+ o->c->store->cct->_conf->bluestore_extent_map_inline_shard_prealloc_size) {
}
bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
bool force)
{
+ auto cct = onode->c->store->cct; //used by dout
assert(!needs_reshard);
if (onode->onode.extent_map_shards.empty()) {
if (inline_bl.length() == 0) {
return false;
}
-void BlueStore::ExtentMap::reshard(uint64_t min_alloc_size)
+void BlueStore::ExtentMap::reshard()
{
+ auto min_alloc_size = onode->c->store->min_alloc_size;
+ auto cct = onode->c->store->cct; //used by dout
+
needs_reshard = false;
// un-span all blobs
}
}
-bool BlueStore::ExtentMap::encode_some(uint32_t offset, uint32_t length,
- bufferlist& bl, unsigned *pn)
+bool BlueStore::ExtentMap::encode_some(
+ uint32_t offset,
+ uint32_t length,
+ bufferlist& bl,
+ unsigned *pn)
{
+ auto cct = onode->c->store->cct; //used by dout
Extent dummy(offset);
auto start = extent_map.lower_bound(dummy);
uint32_t end = offset + length;
le->assign_blob(blobs[blobid - 1]);
assert(le->blob);
} else {
- Blob *b = new Blob(cct);
+ Blob *b = new Blob();
uint64_t sbid = 0;
b->decode(p, struct_v, &sbid, false);
blobs[n] = b;
}
void BlueStore::ExtentMap::decode_spanning_blobs(
- Collection *c,
bufferptr::iterator& p)
{
__u8 struct_v;
unsigned n;
denc_varint(n, p);
while (n--) {
- BlobRef b(new Blob(c->store->cct));
+ BlobRef b(new Blob());
denc_varint(b->id, p);
spanning_blob_map[b->id] = b;
uint64_t sbid = 0;
b->decode(p, struct_v, &sbid, true);
- c->open_shared_blob(sbid, b);
+ onode->c->open_shared_blob(sbid, b);
}
}
uint32_t offset,
uint32_t length)
{
+ auto cct = onode->c->store->cct; //used by dout
dout(30) << __func__ << " 0x" << std::hex << offset << "~" << length
<< std::dec << dendl;
auto start = seek_shard(offset);
uint32_t offset,
uint32_t length)
{
+ auto cct = onode->c->store->cct; //used by dout
dout(30) << __func__ << " 0x" << std::hex << offset << "~" << length
<< std::dec << dendl;
if (shards.empty()) {
return true;
}
-int BlueStore::ExtentMap::compress_extent_map(uint64_t offset, uint64_t length)
+int BlueStore::ExtentMap::compress_extent_map(
+ uint64_t offset,
+ uint64_t length)
{
+ auto cct = onode->c->store->cct; //used by dout
if (extent_map.empty())
return 0;
int removed = 0;
uint32_t blob_offset,
uint32_t pos)
{
+ auto cct = onode->c->store->cct; //used by dout
+
uint32_t end_pos = pos + lb->get_blob().get_logical_length() - blob_offset;
dout(20) << __func__ << " 0x" << std::hex << pos << " end 0x" << end_pos
<< " blob_offset 0x" << blob_offset << std::dec << " " << *lb
<< dendl;
BlobRef rb = onode->c->new_blob();
- lb->split(blob_offset, rb.get());
+ lb->split(onode->c, blob_offset, rb.get());
for (auto ep = seek_lextent(pos);
ep != extent_map.end() && ep->logical_offset < end_pos;
on->onode.decode(p);
// initialize extent_map
- on->extent_map.decode_spanning_blobs(this, p);
+ on->extent_map.decode_spanning_blobs(p);
if (on->onode.extent_map_shards.empty()) {
denc(on->extent_map.inline_bl, p);
on->extent_map.decode_some(on->extent_map.inline_bl);
}
}
+BlueStore::BlueStore(CephContext *cct,
+ const string& path,
+ uint64_t _min_alloc_size)
+ : ObjectStore(cct, path),
+ bluefs(NULL),
+ bluefs_shared_bdev(0),
+ db(NULL),
+ bdev(NULL),
+ fm(NULL),
+ alloc(NULL),
+ path_fd(-1),
+ fsid_fd(-1),
+ mounted(false),
+ coll_lock("BlueStore::coll_lock"),
+ throttle_ops(cct, "bluestore_max_ops", cct->_conf->bluestore_max_ops),
+ throttle_bytes(cct, "bluestore_max_bytes", cct->_conf->bluestore_max_bytes),
+ throttle_wal_ops(cct, "bluestore_wal_max_ops",
+ cct->_conf->bluestore_max_ops +
+ cct->_conf->bluestore_wal_max_ops),
+ throttle_wal_bytes(cct, "bluestore_wal_max_bytes",
+ cct->_conf->bluestore_max_bytes +
+ cct->_conf->bluestore_wal_max_bytes),
+ wal_tp(cct,
+ "BlueStore::wal_tp",
+ "tp_wal",
+ cct->_conf->bluestore_sync_wal_apply ? 0 : cct->_conf->bluestore_wal_threads,
+ "bluestore_wal_threads"),
+ wal_wq(this,
+ cct->_conf->bluestore_wal_thread_timeout,
+ cct->_conf->bluestore_wal_thread_suicide_timeout,
+ &wal_tp),
+ m_finisher_num(1),
+ kv_sync_thread(this),
+ kv_stop(false),
+ logger(NULL),
+ debug_read_error_lock("BlueStore::debug_read_error_lock"),
+ csum_type(Checksummer::CSUM_CRC32C),
+ min_alloc_size(_min_alloc_size),
+ min_alloc_size_order(ctz(_min_alloc_size)),
+ sync_wal_apply(cct->_conf->bluestore_sync_wal_apply),
+ mempool_thread(this)
+{
+ _init_logger();
+ cct->_conf->add_observer(this);
+ set_cache_shards(1);
+
+ if (cct->_conf->bluestore_shard_finishers) {
+ m_finisher_num = cct->_conf->osd_op_num_shards;
+ }
+
+ for (int i = 0; i < m_finisher_num; ++i) {
+ ostringstream oss;
+ oss << "finisher-" << i;
+ Finisher *f = new Finisher(cct, oss.str(), "finisher");
+ finishers.push_back(f);
+ }
+}
+
BlueStore::~BlueStore()
{
for (auto f : finishers) {
bool BlueStore::exists(CollectionHandle &c_, const ghobject_t& oid)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(10) << __func__ << " " << c->cid << " " << oid << dendl;
if (!c->exists)
return false;
struct stat *st,
bool allow_eio)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
if (!c->exists)
return -ENOENT;
dout(10) << __func__ << " " << c->get_cid() << " " << oid << dendl;
CollectionHandle ch = _get_collection(cid);
if (!ch)
return -ENOENT;
- Collection *c = static_cast<Collection*>(ch.get());
+ Collection *c = static_cast<Collection *>(ch.get());
dout(15) << __func__ << " " << cid << " options " << opts << dendl;
if (!c->exists)
return -ENOENT;
uint32_t op_flags,
bool allow_eio)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
const coll_t &cid = c->get_cid();
dout(15) << __func__ << " " << cid << " " << oid
<< " 0x" << std::hex << offset << "~" << length << std::dec
size_t length,
bufferlist& bl)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
if (!c->exists)
return -ENOENT;
interval_set<uint64_t> m;
const char *name,
bufferptr& value)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->cid << " " << oid << " " << name << dendl;
if (!c->exists)
return -ENOENT;
const ghobject_t& oid,
map<string,bufferptr>& aset)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
if (!c->exists)
return -ENOENT;
bool sort_bitwise, int max,
vector<ghobject_t> *ls, ghobject_t *pnext)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->cid
<< " start " << start << " end " << end << " max " << max << dendl;
int r;
}
int BlueStore::_collection_list(
- Collection* c, const ghobject_t& start, const ghobject_t& end,
+ Collection *c, const ghobject_t& start, const ghobject_t& end,
bool sort_bitwise, int max,
vector<ghobject_t> *ls, ghobject_t *pnext)
{
map<string, bufferlist> *out /// < [out] Key to value map
)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
if (!c->exists)
return -ENOENT;
bool allow_eio ///< [in] don't assert on eio
)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
if (!c->exists)
return -ENOENT;
set<string> *keys ///< [out] Keys defined on oid
)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
if (!c->exists)
return -ENOENT;
map<string, bufferlist> *out ///< [out] Returned keys and values
)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
if (!c->exists)
return -ENOENT;
set<string> *out ///< [out] Subset of keys defined on oid
)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
if (!c->exists)
return -ENOENT;
const ghobject_t &oid ///< [in] object
)
{
- Collection *c = static_cast<Collection*>(c_.get());
+ Collection *c = static_cast<Collection *>(c_.get());
dout(10) << __func__ << " " << c->get_cid() << " " << oid << dendl;
if (!c->exists) {
return ObjectMap::ObjectMapIterator();
t->rmkey(PREFIX_OBJ, key);
}
o->extent_map.fault_range(db, 0, o->onode.size);
- o->extent_map.reshard(min_alloc_size);
+ o->extent_map.reshard();
reshard = o->extent_map.update(t, true);
if (reshard) {
dout(20) << __func__ << " warning: still wants reshard, check options?"
BlobRef b = lo.blob;
const bluestore_blob_t& blob = b->get_blob();
vector<bluestore_pextent_t> r;
- if (b->put_ref(lo.blob_offset, lo.length, min_alloc_size, &r)) {
+ if (b->put_ref(c.get(), lo.blob_offset, lo.length, &r)) {
if (blob.is_compressed()) {
txc->statfs_delta.compressed() -= blob.get_compressed_payload_length();
}
// longer allocated. Note that this will leave behind edge bits
// that are no longer referenced but not deallocated (until they
// age out of the cache naturally).
- b->discard_unallocated();
+ b->discard_unallocated(c.get());
for (auto e : r) {
dout(20) << __func__ << " release " << e << dendl;
txc->released.insert(e.offset, e.length);
{
dout(15) << __func__ << " " << c->cid << " " << o->oid
<< " 0x" << std::hex << offset << std::dec << dendl;
+
_dump_onode(o, 30);
if (offset == o->onode.size)
} else if (!e.blob->shared_blob->loaded) {
c->load_shared_blob(e.blob->shared_blob);
}
- cb = new Blob(cct);
+ cb = new Blob();
e.blob->last_encoded_id = n;
id_to_blob[n] = cb;
e.blob->dup(*cb);
TEST(Blob, put_ref)
{
{
- BlueStore::Blob b(g_ceph_context);
+ BlueStore store(g_ceph_context, "", 4096);
+ BlueStore::Cache *cache = BlueStore::Cache::create(
+ g_ceph_context, "lru", NULL);
+ BlueStore::Collection coll(&store, cache, coll_t());
+ BlueStore::Blob b;
b.shared_blob = new BlueStore::SharedBlob(nullptr);
b.shared_blob->get(); // hack to avoid dtor from running
b.dirty_blob().extents.push_back(bluestore_pextent_t(0x40715000, 0x2000));
cout << b << std::endl;
vector<bluestore_pextent_t> r;
- b.put_ref(0, 0x1200, 0x1000, &r);
+ b.put_ref(&coll, 0, 0x1200, &r);
cout << " r " << r << std::endl;
cout << b << std::endl;
r.clear();
- b.put_ref(0xae00, 0x4200, 0x1000, &r);
+ b.put_ref(&coll, 0xae00, 0x4200, &r);
cout << " r " << r << std::endl;
cout << b << std::endl;
}
unsigned mas = 4096;
- unsigned mrs = 8192;
+ BlueStore store(g_ceph_context, "", 8192);
+ BlueStore::Cache *cache = BlueStore::Cache::create(
+ g_ceph_context, "lru", NULL);
+ BlueStore::Collection coll(&store, cache, coll_t());
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
b.extents.push_back(bluestore_pextent_t(0, mas*2));
B.get_ref(0, mas*2);
ASSERT_TRUE(b.is_allocated(0, mas*2));
- B.put_ref(0, mas*2, mrs, &r);
+ B.put_ref(&coll, 0, mas*2, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0u, r[0].offset);
ASSERT_EQ(mas*2, b.extents[0].length);
}
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
b.extents.push_back(bluestore_pextent_t(123, mas*2));
B.get_ref(0, mas*2);
- B.put_ref(0, mas, mrs, &r);
+ B.put_ref(&coll, 0, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*2));
- B.put_ref(mas, mas, mrs, &r);
+ B.put_ref(&coll, mas, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(123u, r[0].offset);
ASSERT_EQ(mas*2, b.extents[0].length);
}
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
b.extents.push_back(bluestore_pextent_t(3, mas));
b.extents.push_back(bluestore_pextent_t(4, mas));
B.get_ref(0, mas*4);
- B.put_ref(mas, mas, mrs, &r);
+ B.put_ref(&coll, mas, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*4));
ASSERT_TRUE(b.is_allocated(mas, mas));
- B.put_ref(mas*2, mas, mrs, &r);
+ B.put_ref(&coll, mas*2, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(mas*2, mas));
ASSERT_TRUE(b.is_allocated(0, mas*4));
- B.put_ref(mas*3, mas, mrs, &r);
+ B.put_ref(&coll, mas*3, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(2u, r.size());
ASSERT_EQ(3u, r[0].offset);
ASSERT_EQ(3u, b.extents.size());
}
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
b.extents.push_back(bluestore_pextent_t(5, mas));
b.extents.push_back(bluestore_pextent_t(6, mas));
B.get_ref(0, mas*6);
- B.put_ref(mas, mas, mrs, &r);
+ B.put_ref(&coll, mas, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*6));
- B.put_ref(mas*2, mas, mrs, &r);
+ B.put_ref(&coll, mas*2, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*6));
- B.put_ref(mas*3, mas, mrs, &r);
+ B.put_ref(&coll, mas*3, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(2u, r.size());
ASSERT_EQ(3u, r[0].offset);
ASSERT_TRUE(b.extents[4].is_valid());
}
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
b.extents.push_back(bluestore_pextent_t(1, mas * 6));
B.get_ref(0, mas*6);
- B.put_ref(mas, mas, mrs, &r);
+ B.put_ref(&coll, mas, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*6));
- B.put_ref(mas*2, mas, mrs, &r);
+ B.put_ref(&coll, mas*2, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*6));
- B.put_ref(mas*3, mas, mrs, &r);
+ B.put_ref(&coll, mas*3, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_TRUE(b.extents[2].is_valid());
}
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
b.extents.push_back(bluestore_pextent_t(2, mas * 4));
b.extents.push_back(bluestore_pextent_t(3, mas * 4));
B.get_ref(0, mas*12);
- B.put_ref(mas, mas, mrs, &r);
+ B.put_ref(&coll, mas, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*12));
- B.put_ref(mas*9, mas, mrs, &r);
+ B.put_ref(&coll, mas*9, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*12));
- B.put_ref(mas*2, mas*7, mrs, &r);
+ B.put_ref(&coll, mas*2, mas*7, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(3u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_TRUE(b.extents[2].is_valid());
}
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
b.extents.push_back(bluestore_pextent_t(2, mas * 4));
b.extents.push_back(bluestore_pextent_t(3, mas * 4));
B.get_ref(0, mas*12);
- B.put_ref(mas, mas, mrs, &r);
+ B.put_ref(&coll, mas, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*12));
- B.put_ref(mas*9, mas, mrs, &r);
+ B.put_ref(&coll, mas*9, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*12));
- B.put_ref(mas*2, mas*7, mrs, &r);
+ B.put_ref(&coll, mas*2, mas*7, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(3u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_TRUE(b.extents[0].is_valid());
ASSERT_FALSE(b.extents[1].is_valid());
ASSERT_TRUE(b.extents[2].is_valid());
- B.put_ref(0, mas, mrs, &r);
+ B.put_ref(&coll, 0, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x1u, r[0].offset);
ASSERT_EQ(2u, b.extents.size());
ASSERT_FALSE(b.extents[0].is_valid());
ASSERT_TRUE(b.extents[1].is_valid());
- B.put_ref(mas*10, mas*2, mrs, &r);
+ B.put_ref(&coll, mas*10, mas*2, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x2003u, r[0].offset);
ASSERT_FALSE(b.extents[0].is_valid());
}
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
b.extents.push_back(bluestore_pextent_t(2, mas * 4));
b.extents.push_back(bluestore_pextent_t(3, mas * 4));
B.get_ref(0, mas*12);
- B.put_ref(mas, mas, mrs, &r);
+ B.put_ref(&coll, mas, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*12));
- B.put_ref(mas*9, mas, mrs, &r);
+ B.put_ref(&coll, mas*9, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*12));
- B.put_ref(mas*2, mas*7, mrs, &r);
+ B.put_ref(&coll, mas*2, mas*7, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(3u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_TRUE(b.extents[0].is_valid());
ASSERT_FALSE(b.extents[1].is_valid());
ASSERT_TRUE(b.extents[2].is_valid());
- B.put_ref(mas*10, mas*2, mrs, &r);
+ B.put_ref(&coll, mas*10, mas*2, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x2003u, r[0].offset);
ASSERT_EQ(2u, b.extents.size());
ASSERT_TRUE(b.extents[0].is_valid());
ASSERT_FALSE(b.extents[1].is_valid());
- B.put_ref(0, mas, mrs, &r);
+ B.put_ref(&coll, 0, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x1u, r[0].offset);
ASSERT_FALSE(b.extents[0].is_valid());
}
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
vector<bluestore_pextent_t> r;
b.extents.push_back(bluestore_pextent_t(1, mas * 8));
B.get_ref(0, mas*8);
- B.put_ref(0, mas, mrs, &r);
+ B.put_ref(&coll, 0, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*8));
- B.put_ref(mas*7, mas, mrs, &r);
+ B.put_ref(&coll, mas*7, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*8));
- B.put_ref(mas*2, mas, mrs, &r);
+ B.put_ref(&coll, mas*2, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, 8));
- B.put_ref(mas*3, mas*4, mrs, &r);
+ B.put_ref(&coll, mas*3, mas*4, &r);
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_EQ(mas*6, r[0].length);
ASSERT_EQ(2u, b.extents.size());
ASSERT_TRUE(b.extents[0].is_valid());
ASSERT_FALSE(b.extents[1].is_valid());
- B.put_ref(mas, mas, mrs, &r);
+ B.put_ref(&coll, mas, mas, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x1u, r[0].offset);
}
// verify csum chunk size if factored in properly
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
b.init_csum(Checksummer::CSUM_CRC32C, 14, mas * 4);
B.get_ref(0, mas*4);
ASSERT_TRUE(b.is_allocated(0, mas*4));
- B.put_ref(0, mas*3, mrs, &r);
+ B.put_ref(&coll, 0, mas*3, &r);
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas*4));
ASSERT_EQ(mas*4, b.extents[0].length);
}
{
- BlueStore::Blob B(g_ceph_context);
+ BlueStore::Blob B;
B.shared_blob = new BlueStore::SharedBlob(nullptr);
B.shared_blob->get(); // hack to avoid dtor from running
bluestore_blob_t& b = B.dirty_blob();
cout << "before: " << B << std::endl;
vector<bluestore_pextent_t> r;
- B.put_ref(0x1800, 0x2000, 0x1000, &r);
+ B.put_ref(&coll, 0x1800, 0x2000, &r);
cout << "after: " << B << std::endl;
cout << "r " << r << std::endl;
}
TEST(Blob, split)
{
- BlueStore store(g_ceph_context, "");
+ BlueStore store(g_ceph_context, "", 4096);
BlueStore::Cache *cache = BlueStore::Cache::create(
g_ceph_context, "lru", NULL);
BlueStore::Collection coll(&store, cache, coll_t());
{
- BlueStore::Blob L(g_ceph_context), R(g_ceph_context);
+ BlueStore::Blob L, R;
L.shared_blob = new BlueStore::SharedBlob(&coll);
L.shared_blob->get(); // hack to avoid dtor from running
R.shared_blob = new BlueStore::SharedBlob(&coll);
R.shared_blob->get(); // hack to avoid dtor from running
L.dirty_blob().extents.emplace_back(bluestore_pextent_t(0x2000, 0x2000));
L.dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000);
- L.split(0x1000, &R);
+ L.split(&coll, 0x1000, &R);
ASSERT_EQ(0x1000u, L.get_blob().get_logical_length());
ASSERT_EQ(4u, L.get_blob().csum_data.length());
ASSERT_EQ(1u, L.get_blob().extents.size());
ASSERT_EQ(0x1000u, R.get_blob().extents.front().length);
}
{
- BlueStore::Blob L(g_ceph_context), R(g_ceph_context);
+ BlueStore::Blob L, R;
L.shared_blob = new BlueStore::SharedBlob(&coll);
L.shared_blob->get(); // hack to avoid dtor from running
R.shared_blob = new BlueStore::SharedBlob(&coll);
L.dirty_blob().extents.emplace_back(bluestore_pextent_t(0x2000, 0x1000));
L.dirty_blob().extents.emplace_back(bluestore_pextent_t(0x12000, 0x1000));
L.dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000);
- L.split(0x1000, &R);
+ L.split(&coll, 0x1000, &R);
ASSERT_EQ(0x1000u, L.get_blob().get_logical_length());
ASSERT_EQ(4u, L.get_blob().csum_data.length());
ASSERT_EQ(1u, L.get_blob().extents.size());
TEST(ExtentMap, find_lextent)
{
- BlueStore store(g_ceph_context, "");
+ BlueStore store(g_ceph_context, "", 4096);
BlueStore::LRUCache cache(g_ceph_context);
- BlueStore::ExtentMap em(g_ceph_context, nullptr);
- BlueStore::BlobRef br(new BlueStore::Blob(g_ceph_context));
BlueStore::Collection coll(&store, &cache, coll_t());
+ BlueStore::Onode onode(&coll, ghobject_t(), "");
+ BlueStore::ExtentMap em(&onode);
+ BlueStore::BlobRef br(new BlueStore::Blob);
br->shared_blob = new BlueStore::SharedBlob(&coll);
ASSERT_EQ(em.extent_map.end(), em.find_lextent(0));
TEST(ExtentMap, seek_lextent)
{
- BlueStore store(g_ceph_context, "");
+ BlueStore store(g_ceph_context, "", 4096);
BlueStore::LRUCache cache(g_ceph_context);
- BlueStore::ExtentMap em(g_ceph_context, nullptr);
- BlueStore::BlobRef br(new BlueStore::Blob(g_ceph_context));
BlueStore::Collection coll(&store, &cache, coll_t());
+ BlueStore::Onode onode(&coll, ghobject_t(), "");
+ BlueStore::ExtentMap em(&onode);
+ BlueStore::BlobRef br(new BlueStore::Blob);
br->shared_blob = new BlueStore::SharedBlob(&coll);
ASSERT_EQ(em.extent_map.end(), em.seek_lextent(0));
TEST(ExtentMap, has_any_lextents)
{
- BlueStore store(g_ceph_context, "");
+ BlueStore store(g_ceph_context, "", 4096);
BlueStore::LRUCache cache(g_ceph_context);
- BlueStore::ExtentMap em(g_ceph_context, nullptr);
- BlueStore::BlobRef b(new BlueStore::Blob(g_ceph_context));
BlueStore::Collection coll(&store, &cache, coll_t());
+ BlueStore::Onode onode(&coll, ghobject_t(), "");
+ BlueStore::ExtentMap em(&onode);
+ BlueStore::BlobRef b(new BlueStore::Blob);
b->shared_blob = new BlueStore::SharedBlob(&coll);
ASSERT_FALSE(em.has_any_lextents(0, 0));
TEST(ExtentMap, compress_extent_map)
{
- BlueStore store(g_ceph_context, "");
+ BlueStore store(g_ceph_context, "", 4096);
BlueStore::LRUCache cache(g_ceph_context);
- BlueStore::ExtentMap em(g_ceph_context, nullptr);
- BlueStore::BlobRef b1(new BlueStore::Blob(g_ceph_context));
- BlueStore::BlobRef b2(new BlueStore::Blob(g_ceph_context));
- BlueStore::BlobRef b3(new BlueStore::Blob(g_ceph_context));
BlueStore::Collection coll(&store, &cache, coll_t());
+ BlueStore::Onode onode(&coll, ghobject_t(), "");
+ BlueStore::ExtentMap em(&onode);
+ BlueStore::BlobRef b1(new BlueStore::Blob);
+ BlueStore::BlobRef b2(new BlueStore::Blob);
+ BlueStore::BlobRef b3(new BlueStore::Blob);
b1->shared_blob = new BlueStore::SharedBlob(&coll);
b2->shared_blob = new BlueStore::SharedBlob(&coll);
b3->shared_blob = new BlueStore::SharedBlob(&coll);