mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-24 12:09:58 +00:00
scsi: account unmap operations
Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-id: 20190923121737.83281-8-anton.nefedov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
90ebf8431e
commit
4989ef5781
@ -1617,10 +1617,16 @@ static void scsi_unmap_complete_noio(UnmapCBData *data, int ret)
|
||||
r->sector_count = (ldl_be_p(&data->inbuf[8]) & 0xffffffffULL)
|
||||
* (s->qdev.blocksize / BDRV_SECTOR_SIZE);
|
||||
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 * BDRV_SECTOR_SIZE,
|
||||
BLOCK_ACCT_UNMAP);
|
||||
|
||||
r->req.aiocb = blk_aio_pdiscard(s->qdev.conf.blk,
|
||||
r->sector * BDRV_SECTOR_SIZE,
|
||||
r->sector_count * BDRV_SECTOR_SIZE,
|
||||
@ -1647,10 +1653,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));
|
||||
@ -1682,6 +1689,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;
|
||||
}
|
||||
@ -1697,10 +1705,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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user