: TestObjectStoreState(store),
txn(0)
{
- txn_object = hobject_t(sobject_t("txn", CEPH_NOSNAP));
-
if (!status.empty())
m_status.open(status.c_str());
}
return obj_rng(gen);
}
-void DeterministicOpSequence::note_txn(ObjectStore::Transaction *t)
+void DeterministicOpSequence::note_txn(coll_entry_t *entry,
+ ObjectStore::Transaction *t)
{
bufferlist bl;
encode(txn, bl);
- t->truncate(txn_coll, ghobject_t(txn_object), 0);
- t->write(txn_coll, ghobject_t(txn_object), 0, bl.length(), bl);
+ ghobject_t oid = get_txn_object(entry->m_cid);
+ t->truncate(entry->m_cid, oid, 0);
+ t->write(entry->m_cid, oid, 0, bl.length(), bl);
dout(10) << __func__ << " " << txn << dendl;
}
void DeterministicOpSequence::_do_coll_create(coll_entry_t *entry, uint32_t pg_num, uint64_t num_objs)
{
ObjectStore::Transaction t;
- note_txn(&t);
t.create_collection(entry->m_cid, 32);
+ note_txn(entry, &t);
bufferlist hint;
encode(pg_num, hint);
encode(num_objs, hint);
void DeterministicOpSequence::_do_touch(coll_entry_t *entry, hobject_t& obj)
{
ObjectStore::Transaction t;
- note_txn(&t);
+ note_txn(entry, &t);
t.touch(entry->m_cid, ghobject_t(obj));
m_store->queue_transaction(entry->m_ch, std::move(t));
}
void DeterministicOpSequence::_do_remove(coll_entry_t *entry, hobject_t& obj)
{
ObjectStore::Transaction t;
- note_txn(&t);
+ note_txn(entry, &t);
t.remove(entry->m_cid, ghobject_t(obj));
m_store->queue_transaction(entry->m_ch, std::move(t));
}
const map<string, bufferlist> &attrs)
{
ObjectStore::Transaction t;
- note_txn(&t);
+ note_txn(entry, &t);
t.omap_setkeys(entry->m_cid, ghobject_t(obj), attrs);
m_store->queue_transaction(entry->m_ch, std::move(t));
}
uint64_t off, uint64_t len, const bufferlist& data)
{
ObjectStore::Transaction t;
- note_txn(&t);
+ note_txn(entry, &t);
t.write(entry->m_cid, ghobject_t(obj), off, len, data);
m_store->queue_transaction(entry->m_ch, std::move(t));
}
hobject_t& new_obj)
{
ObjectStore::Transaction t;
- note_txn(&t);
+ note_txn(entry, &t);
t.clone(entry->m_cid, ghobject_t(orig_obj), ghobject_t(new_obj));
m_store->queue_transaction(entry->m_ch, std::move(t));
}
uint64_t srclen, uint64_t dstoff)
{
ObjectStore::Transaction t;
- note_txn(&t);
+ note_txn(entry, &t);
t.clone_range(entry->m_cid, ghobject_t(orig_obj), ghobject_t(new_obj),
srcoff, srclen, dstoff);
m_store->queue_transaction(entry->m_ch, std::move(t));
bufferlist& bl)
{
ObjectStore::Transaction t;
- note_txn(&t);
+ note_txn(entry, &t);
t.write(entry->m_cid, ghobject_t(orig_obj), srcoff, bl.length(), bl);
t.clone_range(entry->m_cid, ghobject_t(orig_obj), ghobject_t(new_obj),
srcoff, srclen, dstoff);
hobject_t& new_obj)
{
ObjectStore::Transaction t;
- note_txn(&t);
+ note_txn(entry, &t);
t.remove(entry->m_cid, ghobject_t(new_obj));
t.collection_move_rename(entry->m_cid, ghobject_t(orig_obj),
entry->m_cid, ghobject_t(new_obj));
class DeterministicOpSequence : public TestObjectStoreState {
public:
- DeterministicOpSequence(ObjectStore *store, std::string status = std::string());
+ DeterministicOpSequence(ObjectStore *store,
+ std::string status = std::string());
virtual ~DeterministicOpSequence();
virtual void generate(int seed, int num_txs);
- protected:
+ static ghobject_t get_txn_object(coll_t cid) {
+ ghobject_t oid(hobject_t(sobject_t("txn", CEPH_NOSNAP)));
+ spg_t pgid;
+ bool r = cid.is_pg(&pgid);
+ if (r) {
+ oid.hobj.set_hash(pgid.ps());
+ }
+ return oid;
+ }
+
+protected:
enum {
DSOP_TOUCH = 0,
DSOP_WRITE = 1,
int32_t txn;
- coll_t txn_coll;
- hobject_t txn_object;
-
ObjectStore::CollectionHandle m_ch;
std::ofstream m_status;
bool run_one_op(int op, rngen_t& gen);
- void note_txn(ObjectStore::Transaction *t);
+ void note_txn(coll_entry_t *entry, ObjectStore::Transaction *t);
bool do_touch(rngen_t& gen);
bool do_remove(rngen_t& gen);
bool do_write(rngen_t& gen);