diff options
author | Eric Blake <eblake@redhat.com> | 2016-07-15 17:23:01 -0600 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-07-20 14:24:25 +0100 |
commit | 97c7e85cfea4f4edc1536c50ca2f3c1627d8e443 (patch) | |
tree | 864bf8ba784cbd0b0afb76636014aec5da2ec38d /block | |
parent | 1014170b825c4d9252fe531d13658f104447f31c (diff) | |
download | qemu-97c7e85cfea4f4edc1536c50ca2f3c1627d8e443.zip qemu-97c7e85cfea4f4edc1536c50ca2f3c1627d8e443.tar.gz qemu-97c7e85cfea4f4edc1536c50ca2f3c1627d8e443.tar.bz2 |
iscsi: Switch .bdrv_co_discard() to byte-based
Another step towards killing off sector-based block APIs.
Unlike write_zeroes, where we can be handed unaligned requests
and must fail gracefully with -ENOTSUP for a fallback, we are
guaranteed that discard requests are always aligned because the
block layer already ignored unaligned head/tail.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1468624988-423-13-git-send-email-eblake@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/iscsi.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/block/iscsi.c b/block/iscsi.c index 5602abd..95ce9e1 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1042,29 +1042,26 @@ iscsi_getlength(BlockDriverState *bs) } static int -coroutine_fn iscsi_co_discard(BlockDriverState *bs, int64_t sector_num, - int nb_sectors) +coroutine_fn iscsi_co_pdiscard(BlockDriverState *bs, int64_t offset, int count) { IscsiLun *iscsilun = bs->opaque; struct IscsiTask iTask; struct unmap_list list; - if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { - return -EINVAL; - } + assert(is_byte_request_lun_aligned(offset, count, iscsilun)); if (!iscsilun->lbp.lbpu) { /* UNMAP is not supported by the target */ return 0; } - list.lba = sector_qemu2lun(sector_num, iscsilun); - list.num = sector_qemu2lun(nb_sectors, iscsilun); + list.lba = offset / iscsilun->block_size; + list.num = count / iscsilun->block_size; iscsi_co_init_iscsitask(iscsilun, &iTask); retry: if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1, - iscsi_co_generic_cb, &iTask) == NULL) { + iscsi_co_generic_cb, &iTask) == NULL) { return -ENOMEM; } @@ -1094,7 +1091,8 @@ retry: return iTask.err_code; } - iscsi_allocmap_set_invalid(iscsilun, sector_num, nb_sectors); + iscsi_allocmap_set_invalid(iscsilun, offset >> BDRV_SECTOR_BITS, + count >> BDRV_SECTOR_BITS); return 0; } @@ -1998,7 +1996,7 @@ static BlockDriver bdrv_iscsi = { .bdrv_refresh_limits = iscsi_refresh_limits, .bdrv_co_get_block_status = iscsi_co_get_block_status, - .bdrv_co_discard = iscsi_co_discard, + .bdrv_co_pdiscard = iscsi_co_pdiscard, .bdrv_co_pwrite_zeroes = iscsi_co_pwrite_zeroes, .bdrv_co_readv = iscsi_co_readv, .bdrv_co_writev_flags = iscsi_co_writev_flags, |