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: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393202
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Daniel Verkamp 2017-12-28 12:50:59 -07:00
parent a520198dba
commit 97f145c8b8
2 changed files with 10 additions and 12 deletions

View File

@ -1610,23 +1610,21 @@ 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,
spdk_bdev_scsi_task_complete_unmap_cmd, ctx);
rc = spdk_bdev_unmap_blocks(task->desc, task->ch, offset_blocks, num_blocks,
spdk_bdev_scsi_task_complete_unmap_cmd, ctx);
if (rc) {
SPDK_ERRLOG("SCSI Unmapping failed\n");

View File

@ -206,9 +206,9 @@ 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_io_completion_cb cb, void *cb_arg)
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;
}