using librbd::util::create_context_callback;
using librbd::util::data_object_name;
+template <typename I>
+uint64_t get_file_offset(I* image_ctx, uint64_t object_no,
+ uint64_t object_off) {
+ auto off = io::util::raw_to_area_offset(
+ *image_ctx, Striper::get_file_offset(image_ctx->cct, &image_ctx->layout,
+ object_no, object_off));
+ ceph_assert(off.second == io::ImageArea::DATA);
+ return off.first;
+}
+
template <typename I>
struct C_AlignedObjectReadRequest : public Context {
I* image_ctx;
r = 0;
for (auto& extent: *extents) {
auto crypto_ret = crypto->decrypt_aligned_extent(
- extent,
- io::util::get_file_offset(
- image_ctx, object_no, extent.offset));
+ extent, get_file_offset(image_ctx, object_no, extent.offset));
if (crypto_ret != 0) {
ceph_assert(crypto_ret < 0);
r = crypto_ret;
if (m_crypto->is_aligned(object_off, data.length())) {
auto r = m_crypto->encrypt(
- &data,
- io::util::get_file_offset(m_image_ctx, object_no, object_off));
+ &data, get_file_offset(m_image_ctx, object_no, object_off));
*dispatch_result = r == 0 ? io::DISPATCH_RESULT_CONTINUE
: io::DISPATCH_RESULT_COMPLETE;
on_dispatched->complete(r);
return {extents[0].first, area};
}
-template <typename I>
-uint64_t get_file_offset(I* image_ctx, uint64_t object_no, uint64_t offset) {
- auto off = Striper::get_file_offset(image_ctx->cct, &image_ctx->layout,
- object_no, offset);
- Extents extents = {{off, 0}};
- image_ctx->io_image_dispatcher->remap_to_logical(extents);
- return extents[0].first;
-}
-
} // namespace util
} // namespace io
} // namespace librbd
template auto librbd::io::util::raw_to_area_offset(
const librbd::ImageCtx& image_ctx, uint64_t offset)
-> std::pair<uint64_t, ImageArea>;
-template uint64_t librbd::io::util::get_file_offset(
- librbd::ImageCtx *image_ctx, uint64_t object_no, uint64_t offset);
-
std::pair<uint64_t, ImageArea> raw_to_area_offset(const ImageCtxT& image_ctx,
uint64_t offset);
-template <typename ImageCtxT = librbd::ImageCtx>
-uint64_t get_file_offset(ImageCtxT *image_ctx, uint64_t object_no,
- uint64_t offset);
-
inline ObjectDispatchLayer get_previous_layer(ObjectDispatchLayer layer) {
return (ObjectDispatchLayer)(((int)layer) - 1);
}
namespace util {
-template <> uint64_t get_file_offset(
- MockImageCtx *image_ctx, uint64_t object_no, uint64_t offset) {
- return Striper::get_file_offset(image_ctx->cct, &image_ctx->layout,
- object_no, offset);
-}
-
namespace {
struct Mock {
namespace librbd {
namespace crypto {
+template <>
+uint64_t get_file_offset(MockImageCtx *image_ctx, uint64_t object_no,
+ uint64_t offset) {
+ return Striper::get_file_offset(image_ctx->cct, &image_ctx->layout,
+ object_no, offset);
+}
+
using ::testing::_;
using ::testing::ElementsAre;
using ::testing::Invoke;
ASSERT_EQ(++it, snap2_result.end());
}
-} // namespace io
+} // namespace crypto
} // namespace librbd