Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: remove move_ranges_destroy_src #11791

Merged
merged 1 commit into from
Nov 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 0 additions & 26 deletions src/os/ObjectStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ class ObjectStore {
OP_COLL_HINT = 40, // cid, type, bl

OP_TRY_RENAME = 41, // oldcid, oldoid, newoid
OP_MERGE_DELETE = 42, //move tempobj to base object. cid, oid, newoid, vector of tuple <src offset, dest offset, len>
};

// Transaction hint type
Expand Down Expand Up @@ -646,7 +645,6 @@ class ObjectStore {

case OP_CLONERANGE2:
case OP_CLONE:
case OP_MERGE_DELETE:
assert(op->cid < cm.size());
assert(op->oid < om.size());
assert(op->dest_oid < om.size());
Expand Down Expand Up @@ -934,9 +932,6 @@ class ObjectStore {
void decode_attrset(map<string,bufferlist>& aset) {
::decode(aset, data_bl_p);
}
void decode_move_info(vector<std::pair<uint64_t, uint64_t >>& move_info) {
::decode(move_info, data_bl_p);
}
void decode_attrset_bl(bufferlist *pbl) {
decode_str_str_map_to_bl(data_bl_p, pbl);
}
Expand Down Expand Up @@ -1193,27 +1188,6 @@ class ObjectStore {
data.ops++;
}

/*
* Move source object to base object.
* Data portion is only copied from source object to base object.
* The copy is done according to the move_info vector of tuple, which
* has information of offset and length.
* Finally, the source object is deleted.
*/
void move_ranges_destroy_src(
const coll_t& cid,
const ghobject_t& src_oid,
ghobject_t oid,
const vector<std::pair<uint64_t, uint64_t>>& move_info) {
Op* _op = _get_next_op();
_op->op = OP_MERGE_DELETE;
_op->cid = _get_coll_id(cid);
_op->oid = _get_object_id(src_oid);
_op->dest_oid = _get_object_id(oid);
::encode(move_info, data_bl);
data.ops++;
}

/// Create the collection
void create_collection(const coll_t& cid, int bits) {
Op* _op = _get_next_op();
Expand Down
51 changes: 0 additions & 51 deletions src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7225,19 +7225,6 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
}
break;

case Transaction::OP_MERGE_DELETE:
{
const ghobject_t& noid = i.get_oid(op->dest_oid);
OnodeRef& no = ovec[op->dest_oid];
if (!no) {
no = c->get_onode(noid, true);
}
vector<std::pair<uint64_t, uint64_t>> move_info;
i.decode_move_info(move_info);
r = _move_ranges_destroy_src(txc, c, o, no, move_info);
}
break;

case Transaction::OP_COLL_ADD:
assert(0 == "not implemented");
break;
Expand Down Expand Up @@ -8853,44 +8840,6 @@ int BlueStore::_clone_range(TransContext *txc,
return r;
}

/* Move contents of src object according to move_info to base object.
* Once the move_info is traversed completely, delete the src object.
*/
int BlueStore::_move_ranges_destroy_src(
TransContext *txc,
CollectionRef& c,
OnodeRef& srco,
OnodeRef& baseo,
const vector<std::pair<uint64_t, uint64_t>> move_info)
{
dout(15) << __func__ << " " << c->cid << " "
<< srco->oid << " -> " << baseo->oid
<< dendl;

int r = 0;

// Traverse move_info completely, move contents from src object
// to base object.
for (unsigned i = 0; i < move_info.size(); ++i) {
uint64_t off = move_info[i].first;
uint64_t len = move_info[i].second;

dout(15) << __func__ << " " << c->cid << " " << srco->oid << " -> "
<< baseo->oid << " 0x" << std::hex << off << "~" << len
<< dendl;

r = _clone_range(txc, c, srco, baseo, off, len, off);
if (r < 0)
goto out;
}

// delete the src object
r = _do_remove(txc, c, srco);

out:
return r;
}

int BlueStore::_rename(TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,
Expand Down
6 changes: 0 additions & 6 deletions src/os/bluestore/BlueStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -2096,12 +2096,6 @@ class BlueStore : public ObjectStore,
OnodeRef& oldo,
OnodeRef& newo,
uint64_t srcoff, uint64_t length, uint64_t dstoff);
int _move_ranges_destroy_src(
TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,
OnodeRef& newo,
const vector<std::pair<uint64_t,uint64_t>> move_info);
int _rename(TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,
Expand Down
98 changes: 0 additions & 98 deletions src/os/filestore/FileStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2707,22 +2707,6 @@ void FileStore::_do_transaction(
}
break;

case Transaction::OP_MERGE_DELETE:
{
ghobject_t src_oid = i.get_oid(op->oid);
coll_t cid = i.get_cid(op->cid);
ghobject_t oid = i.get_oid(op->dest_oid);
coll_t src_cid = i.get_cid(op->cid);
_kludge_temp_object_collection(cid, oid);
_kludge_temp_object_collection(src_cid, src_oid);
vector<std::pair<uint64_t, uint64_t>> move_info;
i.decode_move_info(move_info);
tracepoint(objectstore, move_ranges_destroy_src_enter, osr_name);
r = _move_ranges_destroy_src(src_cid, src_oid, cid, oid, move_info, spos);
tracepoint(objectstore, move_ranges_destroy_src_exit, r);
}
break;

case Transaction::OP_MKCOLL:
{
coll_t cid = i.get_cid(op->cid);
Expand Down Expand Up @@ -3788,88 +3772,6 @@ int FileStore::_clone_range(const coll_t& oldcid, const ghobject_t& oldoid, cons
return r;
}

/*
* Move contents of src object according to move_info to base object. Once the move_info is traversed completely, delete the src object.
*/
int FileStore::_move_ranges_destroy_src(
const coll_t& src_cid, const ghobject_t& src_oid,
const coll_t& cid, const ghobject_t& oid,
const vector<std::pair<uint64_t, uint64_t>> move_info,
const SequencerPosition& spos)
{
int r = 0;

dout(10) << __func__ << src_cid << "/" << src_oid << " -> "
<< cid << "/" << oid << dendl;

// check replay guard for base object. If not possible to replay, return.
int dstcmp = _check_replay_guard(cid, oid, spos);
if (dstcmp < 0)
return 0;

// check the src name too; it might have a newer guard, and we don't
// want to clobber it
int srccmp = _check_replay_guard(src_cid, src_oid, spos);
if (srccmp < 0)
return 0;

FDRef b;
r = lfn_open(cid, oid, true, &b);
if (r < 0) {
return 0;
}

FDRef t;
r = lfn_open(src_cid, src_oid, false, &t);
//If we are replaying, it is possible that we do not find src obj as
//it is deleted before crashing.
if (r < 0) {
lfn_close(b);
dout(10) << __func__ << " replaying -->" << replaying << dendl;
if (replaying) {
_set_replay_guard(**b, spos, &oid);
return 0;
} else {
return -ENOENT;
}
}

for (unsigned i = 0; i < move_info.size(); ++i) {
uint64_t off = move_info[i].first;
uint64_t len = move_info[i].second;
r = _do_clone_range(**t, **b, off, len, off);
if (r < 0)
break;
}

dout(10) << __func__ << cid << "/" << oid << " " << " = " << r << dendl;

lfn_close(t);

//In case crash occurs here, replay will have to do cloning again.
//Only if do_clone_range is successful, go ahead with deleting the source object.
if (r < 0)
goto out;

r = lfn_unlink(src_cid, src_oid, spos, true);
// If crash occurs between unlink and set guard, correct the error.
// as during next time, it might not find the already deleted object.
if (r < 0 && replaying) {
r = 0;
}

if (r < 0)
goto out;

//set replay guard for base obj coll_t, as this api is not idempotent.
_set_replay_guard(**b, spos, &oid);

out:
lfn_close(b);
dout(10) << __func__ << cid << "/" << oid << " " << " = " << r << dendl;
return r;
}

class SyncEntryTimeout : public Context {
public:
explicit SyncEntryTimeout(int commit_timeo)
Expand Down
5 changes: 0 additions & 5 deletions src/os/filestore/FileStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,6 @@ class FileStore : public JournalingObjectStore,
int _clone_range(const coll_t& oldcid, const ghobject_t& oldoid, const coll_t& newcid, const ghobject_t& newoid,
uint64_t srcoff, uint64_t len, uint64_t dstoff,
const SequencerPosition& spos);
int _move_ranges_destroy_src(
const coll_t& temp_cid, const ghobject_t& temp_oid,
const coll_t& cid, const ghobject_t& oid,
const vector<std::pair<uint64_t, uint64_t> > move_info,
const SequencerPosition& spos);
int _do_clone_range(int from, int to, uint64_t srcoff, uint64_t len, uint64_t dstoff);
int _do_sparse_copy_range(int from, int to, uint64_t srcoff, uint64_t len, uint64_t dstoff);
int _do_copy_range(int from, int to, uint64_t srcoff, uint64_t len, uint64_t dstoff, bool skip_sloppycrc=false);
Expand Down
48 changes: 0 additions & 48 deletions src/os/kstore/KStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2397,16 +2397,6 @@ void KStore::_txc_add_transaction(TransContext *txc, Transaction *t)
}
break;

case Transaction::OP_MERGE_DELETE:
{
const ghobject_t& boid = i.get_oid(op->dest_oid);
OnodeRef bo = c->get_onode(boid, true);
vector<std::pair<uint64_t, uint64_t>> move_info;
i.decode_move_info(move_info);
r = _move_ranges_destroy_src(txc, c, o, cvec[op->dest_cid], bo, move_info);
}
break;

case Transaction::OP_COLL_ADD:
assert(0 == "not implemented");
break;
Expand Down Expand Up @@ -3216,44 +3206,6 @@ int KStore::_clone_range(TransContext *txc,
return r;
}

/* Move contents of src object according to move_info to base object.
* Once the move_info is traversed completely, delete the src object.
*/
int KStore::_move_ranges_destroy_src(
TransContext *txc,
CollectionRef& c,
OnodeRef& srco,
CollectionRef& basec,
OnodeRef& baseo,
vector<std::pair<uint64_t, uint64_t>> move_info)
{
int r = 0;
bufferlist bl;
baseo->exists = true;
_assign_nid(txc, baseo);

// Traverse move_info completely, move contents from src to base object.
for (unsigned i = 0; i < move_info.size(); ++i) {
uint64_t off = move_info[i].first;
uint64_t len = move_info[i].second;

r = _do_read(srco, off, len, bl, 0);
if (r < 0)
goto out;

r = _do_write(txc, baseo, off, bl.length(), bl, 0);
txc->write_onode(baseo);
r = 0;
}

// After for loop ends, remove src obj
r = _do_remove(txc, srco);

out:
return r;
}


int KStore::_rename(TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,
Expand Down
7 changes: 0 additions & 7 deletions src/os/kstore/KStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,6 @@ class KStore : public ObjectStore {
OnodeRef& oldo,
OnodeRef& newo,
uint64_t srcoff, uint64_t length, uint64_t dstoff);
int _move_ranges_destroy_src(
TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,
CollectionRef& bc,
OnodeRef& newo,
vector<std::pair<uint64_t, uint64_t>> move_info);
int _rename(TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,
Expand Down
47 changes: 0 additions & 47 deletions src/os/memstore/MemStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,6 @@ void MemStore::_do_transaction(Transaction& t)
}
break;

case Transaction::OP_MERGE_DELETE:
{
coll_t cid = i.get_cid(op->cid);
ghobject_t oid = i.get_oid(op->oid);
ghobject_t noid = i.get_oid(op->dest_oid);
vector<std::pair<uint64_t, uint64_t>> move_info;
i.decode_move_info(move_info);
r = _move_ranges_destroy_src(cid, oid, noid, move_info);
}
break;

case Transaction::OP_MKCOLL:
{
coll_t cid = i.get_cid(op->cid);
Expand Down Expand Up @@ -1255,42 +1244,6 @@ int MemStore::_clone_range(const coll_t& cid, const ghobject_t& oldoid,
return len;
}

/* Move contents of src object according to move_info to base object.
* Once the move_info is traversed completely, delete the src object.
*/
int MemStore::_move_ranges_destroy_src(
const coll_t& cid, const ghobject_t& srcoid,
const ghobject_t& baseoid,
const vector<std::pair<uint64_t, uint64_t> > move_info)
{
dout(10) << __func__ << " " << cid << " " << srcoid << " -> "
<< baseoid << dendl;
CollectionRef c = get_collection(cid);
if (!c)
return -ENOENT;

ObjectRef oo = c->get_object(srcoid);
if (!oo)
return -ENOENT;
ObjectRef no = c->get_or_create_object(baseoid);

for (unsigned i = 0; i < move_info.size(); ++i) {
uint64_t off = move_info[i].first;
uint64_t len = move_info[i].second;
if (off >= oo->get_size())
return 0;
if (off + len >= oo->get_size())
len = oo->get_size() - off;
const ssize_t old_size = no->get_size();
no->clone(oo.get(), off, len, off);
used_bytes += (no->get_size() - old_size);
}

// delete the src object
_remove(cid, srcoid);
return 0;
}

int MemStore::_omap_clear(const coll_t& cid, const ghobject_t &oid)
{
dout(10) << __func__ << " " << cid << " " << oid << dendl;
Expand Down