Commit fc30f5ed authored by Jim Harris's avatar Jim Harris Committed by Konrad Sztyber
Browse files

bdev: defer completion when copy operation has src == dst



Bdev convention has always been that successfully submitted
operations always return 0, and will never complete in the context
of the submission. But spdk_bdev_copy_blocks() broke this convention in
the case where src offset == dst offset. So fix that here - renaming
and reusing an spdk_thread_send_msg() function recently added for a similar
case in the unmap path.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: I3e6543ee28726cc715500e414ed3e39c5c84a644
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22051


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 4b527a3c
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -6211,7 +6211,7 @@ spdk_bdev_unmap(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
}

static void
bdev_unmap_complete_cb(void *ctx)
bdev_io_complete_cb(void *ctx)
{
	struct spdk_bdev_io *bdev_io = ctx;

@@ -6258,7 +6258,7 @@ spdk_bdev_unmap_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
	bdev_io->u.bdev.accel_sequence = NULL;

	if (num_blocks == 0) {
		spdk_thread_send_msg(spdk_get_thread(), bdev_unmap_complete_cb, bdev_io);
		spdk_thread_send_msg(spdk_get_thread(), bdev_io_complete_cb, bdev_io);
		return 0;
	}

@@ -10337,9 +10337,7 @@ spdk_bdev_copy_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
	bdev_io_init(bdev_io, bdev, cb_arg, cb);

	if (dst_offset_blocks == src_offset_blocks) {
		bdev_io->internal.status = SPDK_BDEV_IO_STATUS_SUCCESS;
		bdev_io->internal.cb(bdev_io, true, bdev_io->internal.caller_ctx);

		spdk_thread_send_msg(spdk_get_thread(), bdev_io_complete_cb, bdev_io);
		return 0;
	}