*dispatch_result = DISPATCH_RESULT_COMPLETE;
auto req = new ObjectReadRequest<I>(m_image_ctx, oid, object_no, object_off,
object_len, snap_id, op_flags,
- false, parent_trace, read_data,
- extent_map, on_dispatched);
+ parent_trace, read_data, extent_map,
+ on_dispatched);
req->send();
return true;
}
ObjectReadRequest<I>::ObjectReadRequest(I *ictx, const std::string &oid,
uint64_t objectno, uint64_t offset,
uint64_t len, librados::snap_t snap_id,
- int op_flags, bool cache_initiated,
+ int op_flags,
const ZTracer::Trace &parent_trace,
bufferlist* read_data,
ExtentMap* extent_map,
Context *completion)
: ObjectRequest<I>(ictx, oid, objectno, offset, len, snap_id, "read",
parent_trace, completion),
- m_op_flags(op_flags), m_cache_initiated(cache_initiated),
- m_read_data(read_data), m_extent_map(extent_map) {
+ m_op_flags(op_flags), m_read_data(read_data), m_extent_map(extent_map) {
}
template <typename I>
I *image_ctx = this->m_ictx;
ldout(image_ctx->cct, 20) << dendl;
- if (!m_cache_initiated && image_ctx->object_cacher != nullptr) {
- read_cache();
- } else {
- read_object();
- }
-}
-
-template <typename I>
-void ObjectReadRequest<I>::read_cache() {
- I *image_ctx = this->m_ictx;
- ldout(image_ctx->cct, 20) << dendl;
-
- // must use async callback to avoid cache_lock cycle
- auto cache_ctx = util::create_async_context_callback(
- *image_ctx, util::create_context_callback<
- ObjectReadRequest<I>, &ObjectReadRequest<I>::handle_read_cache>(this));
- image_ctx->aio_read_from_cache(
- this->m_oid, this->m_object_no, m_read_data, this->m_object_len,
- this->m_object_off, cache_ctx, m_op_flags,
- (this->m_trace.valid() ? &this->m_trace : nullptr));
-}
-
-template <typename I>
-void ObjectReadRequest<I>::handle_read_cache(int r) {
- I *image_ctx = this->m_ictx;
- ldout(image_ctx->cct, 20) << "r=" << r << dendl;
-
- if (r == -ENOENT) {
- read_parent();
- return;
- } else if (r < 0) {
- lderr(image_ctx->cct) << "failed to read from cache: "
- << cpp_strerror(r) << dendl;
- this->finish(r);
- return;
- }
-
- this->finish(0);
+ read_object();
}
template <typename I>
static ObjectReadRequest* create(ImageCtxT *ictx, const std::string &oid,
uint64_t objectno, uint64_t offset,
uint64_t len, librados::snap_t snap_id,
- int op_flags, bool cache_initiated,
+ int op_flags,
const ZTracer::Trace &parent_trace,
ceph::bufferlist* read_data,
ExtentMap* extent_map, Context *completion) {
return new ObjectReadRequest(ictx, oid, objectno, offset, len,
- snap_id, op_flags, cache_initiated,
- parent_trace, read_data, extent_map,
- completion);
+ snap_id, op_flags, parent_trace, read_data,
+ extent_map, completion);
}
ObjectReadRequest(ImageCtxT *ictx, const std::string &oid,
uint64_t objectno, uint64_t offset, uint64_t len,
librados::snap_t snap_id, int op_flags,
- bool cache_initiated, const ZTracer::Trace &parent_trace,
+ const ZTracer::Trace &parent_trace,
ceph::bufferlist* read_data, ExtentMap* extent_map,
Context *completion);
/**
* @verbatim
*
- * <start>
- * |
- * |
- * /--------/ \--------\
- * | |
- * | (cache | (cache
- * v disabled) v enabled)
- * READ_OBJECT READ_CACHE
- * | |
- * |/------------------/
+ * <start>
+ * |
+ * |
+ * v
+ * READ_OBJECT
* |
* v (skip if not needed)
* READ_PARENT
*/
int m_op_flags;
- bool m_cache_initiated;
ceph::bufferlist* m_read_data;
ExtentMap* m_extent_map;
- void read_cache();
- void handle_read_cache(int r);
-
void read_object();
void handle_read_object(int r);
ExtentMap extent_map;
C_SaferCond ctx;
auto req = MockObjectReadRequest::create(
- &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
- false, {}, &bl, &extent_map, &ctx);
+ &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+ &bl, &extent_map, &ctx);
req->send();
ASSERT_EQ(0, ctx.wait());
}
C_SaferCond ctx;
auto req = MockObjectReadRequest::create(
&mock_image_ctx, ictx->get_object_name(0), 0, 0,
- ictx->sparse_read_threshold_bytes, CEPH_NOSNAP, 0, false, {},
- &bl, &extent_map, &ctx);
+ ictx->sparse_read_threshold_bytes, CEPH_NOSNAP, 0, {}, &bl, &extent_map,
+ &ctx);
req->send();
ASSERT_EQ(0, ctx.wait());
}
ExtentMap extent_map;
C_SaferCond ctx;
auto req = MockObjectReadRequest::create(
- &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
- false, {}, &bl, &extent_map, &ctx);
+ &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+ &bl, &extent_map, &ctx);
req->send();
ASSERT_EQ(-EPERM, ctx.wait());
}
ExtentMap extent_map;
C_SaferCond ctx;
auto req = MockObjectReadRequest::create(
- &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
- false, {}, &bl, &extent_map, &ctx);
+ &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+ &bl, &extent_map, &ctx);
req->send();
ASSERT_EQ(0, ctx.wait());
}
ExtentMap extent_map;
C_SaferCond ctx;
auto req = MockObjectReadRequest::create(
- &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
- false, {}, &bl, &extent_map, &ctx);
+ &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+ &bl, &extent_map, &ctx);
req->send();
ASSERT_EQ(-EPERM, ctx.wait());
}
ExtentMap extent_map;
C_SaferCond ctx;
auto req = MockObjectReadRequest::create(
- &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
- false, {}, &bl, &extent_map, &ctx);
+ &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+ &bl, &extent_map, &ctx);
req->send();
ASSERT_EQ(0, ctx.wait());
}