objecter, librados: add COPY_FROM operation

This operation will copy an entire object (data, attrs, omap)
atomically.  If the src_version does not match the source object, or
the source object is updated while the copy is in progress, we will
fail with a suitable error code.  By atomic we mean that it will either
successfully copy the entire object in its entirety or it will fail (and
require no cleanup).

Add to C++ librados API only for now.

Signed-off-by: Sage Weil <sage@inktank.com>

Conflicts:

	src/include/ceph_strings.cc
	src/include/rados.h
	src/osd/osd_types.cc
osd: initial COPY_FROM (not viable for large objects)

Initial pass at COPY_FROM implementation.  This uses COPY_GET to read an
object from another OSD and write it locally.  It chunks the read but
accumulates it all in-memory and commits it at once, so it is only suitable
for smaller objects.

Signed-off-by: Sage Weil <sage@inktank.com>
ceph_test_rados: test COPY_FROM

Signed-off-by: Sage Weil <sage@inktank.com>
rgw: change watch init ordering, don't distribute if can't

Backport: dumpling

Moving back the watch initialization after the zone init,
as the zone info holds the control pool name. Since zone
init might need to create a new system object (that needs
to distribute cache), don't try to distribute cache if
watch is not yet initialized.

Reviewed-by: Sage Weil <sage@inktank.com>
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
v0.68
Correct syntax for generate swift key
ReplicatedPG: do not meaninglessly fill in the reqid on make_writeable() cloning

This reqid is used to fill in a map that is used for giving clients
the correct version on replayed ops, unless the reqid is blank (in
which case it doesn't go into the map). Indirect clones are not ops
that the client wants to observe and the version is incorrect right now,
so don't fill it in.
Note that this should not have actually caused any buggy behavior, because
the map would have simply been overwritten by the real requested event
a short time later (while still protected by locks and things). But it's
very confusing.

Signed-off-by: Greg Farnum <greg@inktank.com>
MOSDOpReply: more const-correctness

get_map_epoch() is a non-reference getter -- mark it as const!

Signed-off-by: Greg Farnum <greg@inktank.com>
osd: add is_not_empty() function to object_locator_t

Signed-off-by: Greg Farnum <greg@inktank.com>
osd: create a new request_redirect_t

We'll use this so that the OSD can tell the Objecter to redirect a
request to a different object somewhere else.

Signed-off-by: Greg Farnum <greg@inktank.com>
Objecter: rename Op::oid -> Op::base_oid

Analagous to the oloc->base_oloc rename we did in
e2fcad09d94d965867147627b73e99da9454436f, we may specify a different
target name for a redirect. Rename the existing oid to base_oid to
avoid any confusion.

Signed-off-by: Greg Farnum <greg@inktank.com>
Objecter: add an Op::target_oid, and use it when submitting Ops

For now it's just a copy of base_oid, but soon we will allow it
to be overwritten for OSD-driven redirects.

Signed-off-by: Greg Farnum <greg@inktank.com>
MOSDOpReply: add a redirect member

When present, clients must send the request to the location specified
by the redirect (by using the combine_with_locator() function on
request_redirect_t).
A separate mechanism must be used to ensure that clients see and respect
the redirect, as we do not bump up the minimum required version to
decode.

Signed-off-by: Greg Farnum <greg@inktank.com>
Objecter: write a helper function to clean up ops that need to be retried

We have a little block to clean them up if we get back EAGAIN, but it's
actually leaking map references; we will also use this for redirects
from the OSDs.

Signed-off-by: Greg Farnum <greg@inktank.com>
Objecter: follow redirect replies from the OSD

If we get back a redirect reply, we clean up the Op's external references
and re-send using the target_oloc and target_oid. To facilitate this,
recalc_op_target() now only fills them in and overrides them with pool
cache semantics if they're empty.

Keep in mind that this is a pretty simple redirect formula -- the
Objecter will keep following redirects forever if that's what the OSDs
send back. The client is not providing any synchronization right now.

Signed-off-by: Greg Farnum <greg@inktank.com>
osd: implement basic caching policies in ReplicatedPG

Right now these are very basic and aren't as sophisticated as we
want them to end up, but we have a skeleton for where to put the
decision-making logic.

Signed-off-by: Greg Farnum <greg@inktank.com>
test: update cache test since OSDs support redirects

Signed-off-by: Greg Farnum <greg@inktank.com>