Commit 97f145c8 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

scsi: convert unmap command to bdev blocks API



Use spdk_bdev_unmap_blocks() in place of spdk_bdev_unmap(), since the
SCSI UNMAP descriptor already natively operates in blocks rather than
bytes.

Change-Id: I16a0c38d203cf5f60484229e7872783b11d8de6e
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393202


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatar <shuhei.matsumoto.xt@hitachi.com>
parent a520198d
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -1610,22 +1610,20 @@ spdk_bdev_scsi_unmap(struct spdk_bdev *bdev,

	for (i = 0; i < desc_count; i++) {
		struct spdk_scsi_unmap_bdesc	*desc;
		uint64_t block_size;
		uint64_t offset;
		uint64_t nbytes;
		uint64_t offset_blocks;
		uint64_t num_blocks;

		desc = &ctx->desc[i];

		block_size = spdk_bdev_get_block_size(bdev);
		offset = from_be64(&desc->lba) * block_size;
		nbytes = from_be32(&desc->block_count) * block_size;
		offset_blocks = from_be64(&desc->lba);
		num_blocks = from_be32(&desc->block_count);

		if (nbytes == 0) {
		if (num_blocks == 0) {
			continue;
		}

		ctx->count++;
		rc = spdk_bdev_unmap(task->desc, task->ch, offset, nbytes,
		rc = spdk_bdev_unmap_blocks(task->desc, task->ch, offset_blocks, num_blocks,
					    spdk_bdev_scsi_task_complete_unmap_cmd, ctx);

		if (rc) {
+3 −3
Original line number Diff line number Diff line
@@ -206,8 +206,8 @@ spdk_bdev_writev(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
}

int
spdk_bdev_unmap(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
		uint64_t offset, uint64_t length,
spdk_bdev_unmap_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
		       uint64_t offset_blocks, uint64_t num_blocks,
		       spdk_bdev_io_completion_cb cb, void *cb_arg)
{
	return 0;