Objecter: fix error handling for decoding stat

r is just a local variable, changing it has no effect.
Set the per-operation return value if provided when a decoding
error occurs.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Objecter, librados: use only ObjectOperation form of sparse_read internally

This will be used when exposing an ObjectOperation version of sparse_read()
to the librados user, and there's no reason to duplicate code for creating
and handling it. Add a wrapper Context for handling the lifecycle of the
::ObjectOperation.

This cleans up the synchronous version of sparse_read quite a bit by
using the general operate_read() instead of duplicating decoding and
a bunch of sync boilerplate.

Move handling the decoding of a sparse_read into the Objecter, with
the rest of the decoding of rados operations. librados shouldn't be
the only user of the Objecter that can understand sparse_reads.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librados: add sparse_read() to the C++ bindings for an ObjectOperation

This will allow it to be used with general aio_operate() so we don't have
to add new versions of each operation when we want to add new per-op
arguments, like flags, namespaces, or explicit snapshot contexts/ids.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librados: add per-ObjectOperation flags for balanced and localized reads

These need to apply to the entire ObjectOperation, not just a subop,
so use a new enum and a new aio_operate() call that takes them.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
ReplicatedPG: send -EAGAIN for both balanced and localized reads

This logic for localized reads applies to balanced reads too.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librbd: add options to enable balanced or localized reads for snapshots

Since snapshots never change, it's safe to read from replicas for them.
A common use for this would be reading from a parent snapshot shared by
many clones.

Convert LibrbdWriteback and AioRead to use the ObjectOperation api
so we can set flags. Fortunately the external wrapper holds no data,
so its lifecycle doesn't need to be managed.

Include a simple workunit that sets the flags in various combinations
and looks for their presence in the logs from 'rbd export'.

Fixes: #3064
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>