[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v8 7/9] scsi: account unmap operations
From: |
Anton Nefedov |
Subject: |
[Qemu-block] [PATCH v8 7/9] scsi: account unmap operations |
Date: |
Thu, 16 May 2019 17:33:12 +0300 |
Signed-off-by: Anton Nefedov <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
hw/scsi/scsi-disk.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 6eff496b54..5c77981d60 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -1609,10 +1609,16 @@ static void scsi_unmap_complete_noio(UnmapCBData *data,
int ret)
r->sector = ldq_be_p(&data->inbuf[0]);
r->sector_count = ldl_be_p(&data->inbuf[8]) & 0xffffffffULL;
if (!check_lba_range(s, r->sector, r->sector_count)) {
+ block_acct_invalid(blk_get_stats(s->qdev.conf.blk),
+ BLOCK_ACCT_UNMAP);
scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE));
goto done;
}
+ block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct,
+ r->sector_count * s->qdev.blocksize,
+ BLOCK_ACCT_UNMAP);
+
r->req.aiocb = blk_aio_pdiscard(s->qdev.conf.blk,
r->sector * s->qdev.blocksize,
r->sector_count * s->qdev.blocksize,
@@ -1639,10 +1645,11 @@ static void scsi_unmap_complete(void *opaque, int ret)
r->req.aiocb = NULL;
aio_context_acquire(blk_get_aio_context(s->qdev.conf.blk));
- if (scsi_disk_req_check_error(r, ret, false)) {
+ if (scsi_disk_req_check_error(r, ret, true)) {
scsi_req_unref(&r->req);
g_free(data);
} else {
+ block_acct_done(blk_get_stats(s->qdev.conf.blk), &r->acct);
scsi_unmap_complete_noio(data, ret);
}
aio_context_release(blk_get_aio_context(s->qdev.conf.blk));
@@ -1674,6 +1681,7 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r,
uint8_t *inbuf)
}
if (blk_is_read_only(s->qdev.conf.blk)) {
+ block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNMAP);
scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED));
return;
}
@@ -1689,10 +1697,12 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r,
uint8_t *inbuf)
return;
invalid_param_len:
+ block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNMAP);
scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN));
return;
invalid_field:
+ block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNMAP);
scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
}
--
2.17.1
- Re: [Qemu-block] [PATCH v8 8/9] file-posix: account discard operations, (continued)
- [Qemu-block] [PATCH v8 6/9] scsi: move unmap error checking to the complete callback, Anton Nefedov, 2019/05/16
- [Qemu-block] [PATCH v8 1/9] qapi: group BlockDeviceStats fields, Anton Nefedov, 2019/05/16
- [Qemu-block] [PATCH v8 3/9] block: add empty account cookie type, Anton Nefedov, 2019/05/16
- [Qemu-block] [PATCH v8 9/9] qapi: query-blockstat: add driver specific file-posix stats, Anton Nefedov, 2019/05/16
- [Qemu-block] [PATCH v8 5/9] scsi: store unmap offset and nb_sectors in request struct, Anton Nefedov, 2019/05/16
- [Qemu-block] [PATCH v8 4/9] ide: account UNMAP (TRIM) operations, Anton Nefedov, 2019/05/16
- [Qemu-block] [PATCH v8 2/9] qapi: add unmap to BlockDeviceStats, Anton Nefedov, 2019/05/16
- [Qemu-block] [PATCH v8 7/9] scsi: account unmap operations,
Anton Nefedov <=