Skip to content

Commit

Permalink
osd: add two fileds src/dest_obj_fadvise_flags in struct CopyOp.
Browse files Browse the repository at this point in the history
For src_obj_fadvise_flags, it used in copy data from the source object.
For dest_obj_fadvise_flags, it used in handle data which from the source
object.

Signed-off-by: Jianpeng Ma <[email protected]>
  • Loading branch information
majianpeng committed Mar 23, 2015
1 parent 23b59f3 commit 5982bbe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
19 changes: 13 additions & 6 deletions src/osd/ReplicatedPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,8 @@ void ReplicatedPG::promote_object(ObjectContextRef obc,
CEPH_OSD_COPY_FROM_FLAG_IGNORE_OVERLAY |
CEPH_OSD_COPY_FROM_FLAG_IGNORE_CACHE |
CEPH_OSD_COPY_FROM_FLAG_MAP_SNAP_CLONE,
obc->obs.oi.soid.snap == CEPH_NOSNAP);
obc->obs.oi.soid.snap == CEPH_NOSNAP,
0, 0);

assert(obc->is_blocked());

Expand Down Expand Up @@ -5243,7 +5244,9 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
ctx->copy_cb = cb;
start_copy(cb, ctx->obc, src, src_oloc, src_version,
op.copy_from.flags,
false);
false,
op.copy_from.src_fadvise_flags,
op.flags);
result = -EINPROGRESS;
} else {
// finish
Expand Down Expand Up @@ -6227,7 +6230,7 @@ int ReplicatedPG::fill_in_copy_get(
async_read_started = true;
ctx->pending_async_reads.push_back(
make_pair(
boost::make_tuple(cursor.data_offset, left, 0),
boost::make_tuple(cursor.data_offset, left, osd_op.op.flags),
make_pair(&bl, cb)));
result = MIN(oi.size - cursor.data_offset, (uint64_t)left);
cb->len = result;
Expand Down Expand Up @@ -6317,7 +6320,9 @@ int ReplicatedPG::fill_in_copy_get(
void ReplicatedPG::start_copy(CopyCallback *cb, ObjectContextRef obc,
hobject_t src, object_locator_t oloc,
version_t version, unsigned flags,
bool mirror_snapset)
bool mirror_snapset,
unsigned src_obj_fadvise_flags,
unsigned dest_obj_fadvise_flags)
{
const hobject_t& dest = obc->obs.oi.soid;
dout(10) << __func__ << " " << dest
Expand All @@ -6338,7 +6343,8 @@ void ReplicatedPG::start_copy(CopyCallback *cb, ObjectContextRef obc,
}

CopyOpRef cop(new CopyOp(cb, obc, src, oloc, version, flags,
mirror_snapset));
mirror_snapset, src_obj_fadvise_flags,
dest_obj_fadvise_flags));
copy_ops[dest] = cop;
obc->start_block();

Expand Down Expand Up @@ -6389,6 +6395,7 @@ void ReplicatedPG::_copy_some(ObjectContextRef obc, CopyOpRef cop)
&cop->results.source_omap_digest,
&cop->results.reqids,
&cop->rval);
op.set_last_op_flags(cop->src_obj_fadvise_flags);

C_Copyfrom *fin = new C_Copyfrom(this, obc->obs.oi.soid,
get_last_peering_reset(), cop);
Expand Down Expand Up @@ -6597,7 +6604,7 @@ void ReplicatedPG::_write_copy_chunk(CopyOpRef cop, PGBackend::PGTransaction *t)
cop->temp_cursor.data_offset,
cop->data.length(),
cop->data,
0);
cop->dest_obj_fadvise_flags);
cop->data.clear();
}
if (!pool.info.require_rollback()) {
Expand Down
21 changes: 18 additions & 3 deletions src/osd/ReplicatedPG.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,30 @@ class ReplicatedPG : public PG, public PGBackend::Listener {

object_copy_cursor_t temp_cursor;

/*
* For CopyOp the process is:
* step1: read the data(attr/omap/data) from the source object
* step2: handle those data(w/ those data create a new object)
* src_obj_fadvise_flags used in step1;
* dest_obj_fadvise_flags used in step2
*/
unsigned src_obj_fadvise_flags;
unsigned dest_obj_fadvise_flags;

CopyOp(CopyCallback *cb_, ObjectContextRef _obc, hobject_t s,
object_locator_t l,
version_t v,
unsigned f,
bool ms)
bool ms,
unsigned src_obj_fadvise_flags,
unsigned dest_obj_fadvise_flags)
: cb(cb_), obc(_obc), src(s), oloc(l), flags(f),
mirror_snapset(ms),
objecter_tid(0),
objecter_tid2(0),
rval(-1)
rval(-1),
src_obj_fadvise_flags(src_obj_fadvise_flags),
dest_obj_fadvise_flags(dest_obj_fadvise_flags)
{
results.user_version = v;
results.mirror_snapset = mirror_snapset;
Expand Down Expand Up @@ -1313,7 +1327,8 @@ class ReplicatedPG : public PG, public PGBackend::Listener {
*/
void start_copy(CopyCallback *cb, ObjectContextRef obc, hobject_t src,
object_locator_t oloc, version_t version, unsigned flags,
bool mirror_snapset);
bool mirror_snapset, unsigned src_obj_fadvise_flags,
unsigned dest_obj_fadvise_flags);
void process_copy_chunk(hobject_t oid, ceph_tid_t tid, int r);
void _write_copy_chunk(CopyOpRef cop, PGBackend::PGTransaction *t);
uint64_t get_copy_chunk_size() const {
Expand Down

0 comments on commit 5982bbe

Please sign in to comment.