[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/4] block: Add GET LBA STATUS support
From: |
Lin Ma |
Subject: |
[PATCH 2/4] block: Add GET LBA STATUS support |
Date: |
Tue, 2 Jun 2020 15:41:59 +0800 |
Signed-off-by: Lin Ma <lma@suse.com>
---
block/block-backend.c | 38 ++++++++++++++++++++++++++++++++++
include/sysemu/block-backend.h | 2 ++
2 files changed, 40 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index 6936b25c83..feb1f38b98 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1650,6 +1650,44 @@ int blk_pdiscard(BlockBackend *blk, int64_t offset, int
bytes)
return blk_prw(blk, offset, NULL, bytes, blk_pdiscard_entry, 0);
}
+static int coroutine_fn
+blk_do_get_lba_status(BlockBackend *blk, int64_t offset, int bytes,
+ uint32_t *num_blocks, uint32_t *is_deallocated)
+{
+ int ret;
+
+ blk_wait_while_drained(blk);
+
+ ret = blk_check_byte_request(blk, offset, bytes);
+ if (ret < 0) {
+ return ret;
+ }
+
+ return bdrv_co_get_lba_status(blk->root, offset, bytes, num_blocks,
+ is_deallocated);
+}
+
+static void blk_aio_get_lba_status_entry(void *opaque)
+{
+ BlkAioEmAIOCB *acb = opaque;
+ BlkRwCo *rwco = &acb->rwco;
+
+ void *data = acb->common.opaque;
+ uint32_t *num_blocks = &data[0];
+ uint32_t *is_deallocated = &data[sizeof(uint32_t)];
+
+ rwco->ret = blk_do_get_lba_status(rwco->blk, rwco->offset, acb->bytes,
+ num_blocks, is_deallocated);
+ blk_aio_complete(acb);
+}
+
+BlockAIOCB *blk_aio_get_lba_status(BlockBackend *blk, int64_t offset, int
bytes,
+ BlockCompletionFunc *cb, void *opaque)
+{
+ return blk_aio_prwv(blk, offset, bytes, NULL, blk_aio_get_lba_status_entry,
+ 0, cb, opaque);
+}
+
/* To be called between exactly one pair of blk_inc/dec_in_flight() */
static int coroutine_fn blk_do_flush(BlockBackend *blk)
{
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 8203d7f6f9..cd527ec0c9 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -171,6 +171,8 @@ BlockAIOCB *blk_aio_flush(BlockBackend *blk,
BlockCompletionFunc *cb, void *opaque);
BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, int64_t offset, int bytes,
BlockCompletionFunc *cb, void *opaque);
+BlockAIOCB *blk_aio_get_lba_status(BlockBackend *blk, int64_t offset, int
bytes,
+ BlockCompletionFunc *cb, void *opaque);
void blk_aio_cancel(BlockAIOCB *acb);
void blk_aio_cancel_async(BlockAIOCB *acb);
int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf);
--
2.24.0
- [PATCH 0/4] Add Support for GET LBA STATUS 16 command in scsi emulation, Lin Ma, 2020/06/02
- [PATCH 1/4] block: Add bdrv_co_get_lba_status, Lin Ma, 2020/06/02
- [PATCH 2/4] block: Add GET LBA STATUS support,
Lin Ma <=
- [PATCH 3/4] block: Add block accounting code for GET LBA STATUS, Lin Ma, 2020/06/02
- [PATCH 4/4] scsi-disk: Add support for the GET LBA STATUS 16 command, Lin Ma, 2020/06/02
- Re: [PATCH 0/4] Add Support for GET LBA STATUS 16 command in scsi emulation, no-reply, 2020/06/02
- Re: [PATCH 0/4] Add Support for GET LBA STATUS 16 command in scsi emulation, no-reply, 2020/06/02
- Re: [PATCH 0/4] Add Support for GET LBA STATUS 16 command in scsi emulation, no-reply, 2020/06/02
- Re: [PATCH 0/4] Add Support for GET LBA STATUS 16 command in scsi emulation, no-reply, 2020/06/02