summaryrefslogtreecommitdiffstats
path: root/src/test/librbd
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2023-06-13 13:36:02 +0200
committerIlya Dryomov <idryomov@gmail.com>2023-06-18 17:25:01 +0200
commit584f865ae116185087176715ced014b625f04e82 (patch)
treed8778616505dcf1cdfde95bffad8cee97d21337f /src/test/librbd
parentlibrbd: use an up-to-date snap context when owning the exclusive lock (diff)
downloadceph-584f865ae116185087176715ced014b625f04e82.tar.xz
ceph-584f865ae116185087176715ced014b625f04e82.zip
librbd: stop passing IOContext to image dispatch write methods
This is a major footgun since any value passed e.g. at the API layer may be stale by the time we get to object dispatch. All callers are passing the IOContext returned by get_data_io_context() for their ImageCtx anyway, highlighting that the parameter is fictitious. Only the read method can meaningfully take IOContext. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'src/test/librbd')
-rw-r--r--src/test/librbd/io/test_mock_ImageRequest.cc39
-rw-r--r--src/test/librbd/journal/test_mock_Replay.cc8
-rw-r--r--src/test/librbd/mock/io/MockImageDispatch.h17
3 files changed, 27 insertions, 37 deletions
diff --git a/src/test/librbd/io/test_mock_ImageRequest.cc b/src/test/librbd/io/test_mock_ImageRequest.cc
index 546f2d04d96..9d6423d66c4 100644
--- a/src/test/librbd/io/test_mock_ImageRequest.cc
+++ b/src/test/librbd/io/test_mock_ImageRequest.cc
@@ -211,7 +211,7 @@ TEST_F(TestMockIoImageRequest, AioWriteModifyTimestamp) {
bl.append("1");
MockImageWriteRequest mock_aio_image_write_1(
mock_image_ctx, aio_comp_1, {{0, 1}}, ImageArea::DATA, std::move(bl),
- mock_image_ctx.get_data_io_context(), 0, {});
+ 0, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_write_1.send();
@@ -224,7 +224,7 @@ TEST_F(TestMockIoImageRequest, AioWriteModifyTimestamp) {
bl.append("1");
MockImageWriteRequest mock_aio_image_write_2(
mock_image_ctx, aio_comp_2, {{0, 1}}, ImageArea::DATA, std::move(bl),
- mock_image_ctx.get_data_io_context(), 0, {});
+ 0, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_write_2.send();
@@ -306,7 +306,7 @@ TEST_F(TestMockIoImageRequest, PartialDiscard) {
&aio_comp_ctx, ictx, AIO_TYPE_DISCARD);
MockImageDiscardRequest mock_aio_image_discard(
mock_image_ctx, aio_comp, {{16, 63}, {84, 100}}, ImageArea::DATA,
- ictx->discard_granularity_bytes, mock_image_ctx.get_data_io_context(), {});
+ ictx->discard_granularity_bytes, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_discard.send();
@@ -334,7 +334,7 @@ TEST_F(TestMockIoImageRequest, TailDiscard) {
MockImageDiscardRequest mock_aio_image_discard(
mock_image_ctx, aio_comp,
{{ictx->layout.object_size - 1024, 1024}}, ImageArea::DATA,
- ictx->discard_granularity_bytes, mock_image_ctx.get_data_io_context(), {});
+ ictx->discard_granularity_bytes, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_discard.send();
@@ -364,8 +364,7 @@ TEST_F(TestMockIoImageRequest, DiscardGranularity) {
MockImageDiscardRequest mock_aio_image_discard(
mock_image_ctx, aio_comp,
{{16, 63}, {96, 31}, {84, 100}, {ictx->layout.object_size - 33, 33}},
- ImageArea::DATA, ictx->discard_granularity_bytes,
- mock_image_ctx.get_data_io_context(), {});
+ ImageArea::DATA, ictx->discard_granularity_bytes, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_discard.send();
@@ -397,7 +396,7 @@ TEST_F(TestMockIoImageRequest, PartialDiscardJournalAppendEnabled) {
&aio_comp_ctx, ictx, AIO_TYPE_DISCARD);
MockImageDiscardRequest mock_aio_image_discard(
mock_image_ctx, aio_comp, {{16, 63}, {84, 100}}, ImageArea::DATA,
- ictx->discard_granularity_bytes, mock_image_ctx.get_data_io_context(), {});
+ ictx->discard_granularity_bytes, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_discard.send();
@@ -431,7 +430,7 @@ TEST_F(TestMockIoImageRequest, TailDiscardJournalAppendEnabled) {
MockImageDiscardRequest mock_aio_image_discard(
mock_image_ctx, aio_comp,
{{ictx->layout.object_size - 1024, 1024}}, ImageArea::DATA,
- ictx->discard_granularity_bytes, mock_image_ctx.get_data_io_context(), {});
+ ictx->discard_granularity_bytes, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_discard.send();
@@ -460,9 +459,8 @@ TEST_F(TestMockIoImageRequest, PruneRequiredDiscardJournalAppendEnabled) {
AioCompletion *aio_comp = AioCompletion::create_and_start(
&aio_comp_ctx, ictx, AIO_TYPE_DISCARD);
MockImageDiscardRequest mock_aio_image_discard(
- mock_image_ctx, aio_comp, {{96, 31}},
- ImageArea::DATA, ictx->discard_granularity_bytes,
- mock_image_ctx.get_data_io_context(), {});
+ mock_image_ctx, aio_comp, {{96, 31}}, ImageArea::DATA,
+ ictx->discard_granularity_bytes, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_discard.send();
@@ -491,9 +489,8 @@ TEST_F(TestMockIoImageRequest, LengthModifiedDiscardJournalAppendEnabled) {
AioCompletion *aio_comp = AioCompletion::create_and_start(
&aio_comp_ctx, ictx, AIO_TYPE_DISCARD);
MockImageDiscardRequest mock_aio_image_discard(
- mock_image_ctx, aio_comp, {{16, 63}},
- ImageArea::DATA, ictx->discard_granularity_bytes,
- mock_image_ctx.get_data_io_context(), {});
+ mock_image_ctx, aio_comp, {{16, 63}}, ImageArea::DATA,
+ ictx->discard_granularity_bytes, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_discard.send();
@@ -531,8 +528,7 @@ TEST_F(TestMockIoImageRequest, DiscardGranularityJournalAppendEnabled) {
MockImageDiscardRequest mock_aio_image_discard(
mock_image_ctx, aio_comp,
{{16, 63}, {96, 31}, {84, 100}, {ictx->layout.object_size - 33, 33}},
- ImageArea::DATA, ictx->discard_granularity_bytes,
- mock_image_ctx.get_data_io_context(), {});
+ ImageArea::DATA, ictx->discard_granularity_bytes, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_discard.send();
@@ -562,8 +558,7 @@ TEST_F(TestMockIoImageRequest, AioWriteJournalAppendDisabled) {
bufferlist bl;
bl.append("1");
MockImageWriteRequest mock_aio_image_write(
- mock_image_ctx, aio_comp, {{0, 1}}, ImageArea::DATA, std::move(bl),
- mock_image_ctx.get_data_io_context(), 0, {});
+ mock_image_ctx, aio_comp, {{0, 1}}, ImageArea::DATA, std::move(bl), 0, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_write.send();
@@ -592,7 +587,7 @@ TEST_F(TestMockIoImageRequest, AioDiscardJournalAppendDisabled) {
&aio_comp_ctx, ictx, AIO_TYPE_DISCARD);
MockImageDiscardRequest mock_aio_image_discard(
mock_image_ctx, aio_comp, {{0, 1}}, ImageArea::DATA,
- ictx->discard_granularity_bytes, mock_image_ctx.get_data_io_context(), {});
+ ictx->discard_granularity_bytes, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_discard.send();
@@ -650,8 +645,7 @@ TEST_F(TestMockIoImageRequest, AioWriteSameJournalAppendDisabled) {
bufferlist bl;
bl.append("1");
MockImageWriteSameRequest mock_aio_image_writesame(
- mock_image_ctx, aio_comp, {{0, 1}}, ImageArea::DATA, std::move(bl),
- mock_image_ctx.get_data_io_context(), 0, {});
+ mock_image_ctx, aio_comp, {{0, 1}}, ImageArea::DATA, std::move(bl), 0, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_writesame.send();
@@ -685,8 +679,7 @@ TEST_F(TestMockIoImageRequest, AioCompareAndWriteJournalAppendDisabled) {
uint64_t mismatch_offset;
MockImageCompareAndWriteRequest mock_aio_image_write(
mock_image_ctx, aio_comp, {{0, 1}}, ImageArea::DATA,
- std::move(cmp_bl), std::move(write_bl), &mismatch_offset,
- mock_image_ctx.get_data_io_context(), 0, {});
+ std::move(cmp_bl), std::move(write_bl), &mismatch_offset, 0, {});
{
std::shared_lock owner_locker{mock_image_ctx.owner_lock};
mock_aio_image_write.send();
diff --git a/src/test/librbd/journal/test_mock_Replay.cc b/src/test/librbd/journal/test_mock_Replay.cc
index 7bed2532aa8..9eb31618e0e 100644
--- a/src/test/librbd/journal/test_mock_Replay.cc
+++ b/src/test/librbd/journal/test_mock_Replay.cc
@@ -32,7 +32,7 @@ struct ImageRequest<MockReplayImageCtx> {
const bufferlist &bl, int op_flags));
static void aio_write(MockReplayImageCtx *ictx, AioCompletion *c,
Extents&& image_extents, ImageArea area,
- bufferlist&& bl, IOContext io_context, int op_flags,
+ bufferlist&& bl, int op_flags,
const ZTracer::Trace &parent_trace) {
ceph_assert(s_instance != nullptr);
s_instance->aio_write(c, image_extents, bl, op_flags);
@@ -43,7 +43,6 @@ struct ImageRequest<MockReplayImageCtx> {
static void aio_discard(MockReplayImageCtx *ictx, AioCompletion *c,
Extents&& image_extents, ImageArea area,
uint32_t discard_granularity_bytes,
- IOContext io_context,
const ZTracer::Trace &parent_trace) {
ceph_assert(s_instance != nullptr);
s_instance->aio_discard(c, image_extents, discard_granularity_bytes);
@@ -62,7 +61,7 @@ struct ImageRequest<MockReplayImageCtx> {
int op_flags));
static void aio_writesame(MockReplayImageCtx *ictx, AioCompletion *c,
Extents&& image_extents, ImageArea area,
- bufferlist&& bl, IOContext io_context, int op_flags,
+ bufferlist&& bl, int op_flags,
const ZTracer::Trace &parent_trace) {
ceph_assert(s_instance != nullptr);
s_instance->aio_writesame(c, image_extents, bl, op_flags);
@@ -75,8 +74,7 @@ struct ImageRequest<MockReplayImageCtx> {
static void aio_compare_and_write(MockReplayImageCtx *ictx, AioCompletion *c,
Extents&& image_extents, ImageArea area,
bufferlist&& cmp_bl, bufferlist&& bl,
- uint64_t* mismatch_offset,
- IOContext io_context, int op_flags,
+ uint64_t* mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace) {
ceph_assert(s_instance != nullptr);
s_instance->aio_compare_and_write(c, image_extents, cmp_bl, bl,
diff --git a/src/test/librbd/mock/io/MockImageDispatch.h b/src/test/librbd/mock/io/MockImageDispatch.h
index 02dff3487b6..f9552bebeff 100644
--- a/src/test/librbd/mock/io/MockImageDispatch.h
+++ b/src/test/librbd/mock/io/MockImageDispatch.h
@@ -32,7 +32,7 @@ public:
bool write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
- IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
+ int op_flags, const ZTracer::Trace &parent_trace,
uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
DispatchResult* dispatch_result, Context** on_finish,
Context* on_dispatched) override {
@@ -41,9 +41,8 @@ public:
bool discard(
AioCompletion* aio_comp, Extents &&image_extents,
- uint32_t discard_granularity_bytes, IOContext io_context,
- const ZTracer::Trace &parent_trace, uint64_t tid,
- std::atomic<uint32_t>* image_dispatch_flags,
+ uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace,
+ uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
DispatchResult* dispatch_result, Context** on_finish,
Context* on_dispatched) override {
return false;
@@ -51,7 +50,7 @@ public:
bool write_same(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
- IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
+ int op_flags, const ZTracer::Trace &parent_trace,
uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
DispatchResult* dispatch_result, Context** on_finish,
Context* on_dispatched) override {
@@ -59,10 +58,10 @@ public:
}
bool compare_and_write(
- AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl,
- bufferlist &&bl, uint64_t *mismatch_offset, IOContext io_context,
- int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
- std::atomic<uint32_t>* image_dispatch_flags,
+ AioCompletion* aio_comp, Extents &&image_extents,
+ bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset,
+ int op_flags, const ZTracer::Trace &parent_trace,
+ uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
DispatchResult* dispatch_result, Context** on_finish,
Context* on_dispatched) override {
return false;