Commit 4b527a3c authored by Jim Harris's avatar Jim Harris
Browse files

scsi: simplify split path



Currently the splitting code for unmap and write_same is a bit complicated,
since it needs to handle case where we get a 0-length unmap descriptor and
spdk_bdev_unmap_blocks() didn't handle 0-length calls.

But spdk_bdev_unmap_blocks() has been updated now to handle 0-length calls,
so we can eliminate this extra complexity.

This also alleviates a small regression identified when this splitting code
path was updated.

Fixes issue #3249.
Fixes b735c429 ("scsi: Improve child IO split mechanism").

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent 14b087b7
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -1357,7 +1357,6 @@ struct spdk_bdev_scsi_split_ctx {
	uint16_t			remaining_count;
	uint16_t			current_count;
	uint16_t			outstanding_count;
	/* Return 0 on successly submitting child IO, 1 on skipping child IO, negative number on failure */
	int	(*fn)(struct spdk_bdev_scsi_split_ctx *ctx);
};

@@ -1380,11 +1379,10 @@ bdev_scsi_split(struct spdk_bdev_scsi_split_ctx *ctx)

	while (ctx->remaining_count != 0) {
		rc = ctx->fn(ctx);
		if (rc >= 0) {
		if (rc == 0) {
			ctx->current_count++;
			ctx->remaining_count--;
			/* 0 on success, 1 on skipping child IO. !rc is good enough */
			ctx->outstanding_count += !rc;
			ctx->outstanding_count++;
			continue;
		} else if (rc == -ENOMEM) {
			break;
@@ -1502,10 +1500,6 @@ _bdev_scsi_unmap(struct spdk_bdev_scsi_split_ctx *ctx)
	offset_blocks = from_be64(&desc->lba);
	num_blocks = from_be32(&desc->block_count);

	if (num_blocks == 0) {
		return 1;
	}

	return spdk_bdev_unmap_blocks(lun->bdev_desc,
				      lun->io_channel,
				      offset_blocks,
+3 −3
Original line number Diff line number Diff line
@@ -1096,7 +1096,7 @@ unmap_split_test(void)

	ut_bdev_io_retry();

	/* descriptor 3 and 4. (descriptor 2 should be ignored) */
	/* descriptor 2 and 3 (descriptor 2 is valid even though it is 0 blocks) */
	CU_ASSERT(g_outstanding_bdev_io_count == 2);
	CU_ASSERT(g_pending_bdev_io_count == 0);

@@ -1108,8 +1108,8 @@ unmap_split_test(void)

	ut_bdev_io_retry();

	/* descriptor 5 */
	CU_ASSERT(g_outstanding_bdev_io_count == 1);
	/* descriptor 4 and 5 */
	CU_ASSERT(g_outstanding_bdev_io_count == 2);
	CU_ASSERT(g_pending_bdev_io_count == 0);

	ut_bdev_io_complete();