diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/block-backend.c | 3 | ||||
-rw-r--r-- | block/io.c | 19 | ||||
-rw-r--r-- | block/qcow2-refcount.c | 4 |
3 files changed, 12 insertions, 14 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index d982cf9d29..83b6407ea6 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1512,7 +1512,8 @@ int blk_discard(BlockBackend *blk, int64_t sector_num, int nb_sectors) return ret; } - return bdrv_discard(blk_bs(blk), sector_num, nb_sectors); + return bdrv_pdiscard(blk_bs(blk), sector_num << BDRV_SECTOR_BITS, + nb_sectors << BDRV_SECTOR_BITS); } int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, diff --git a/block/io.c b/block/io.c index 14d448d50c..8d413058be 100644 --- a/block/io.c +++ b/block/io.c @@ -2391,16 +2391,15 @@ int bdrv_flush(BlockDriverState *bs) typedef struct DiscardCo { BlockDriverState *bs; - int64_t sector_num; - int nb_sectors; + int64_t offset; + int count; int ret; } DiscardCo; -static void coroutine_fn bdrv_discard_co_entry(void *opaque) +static void coroutine_fn bdrv_pdiscard_co_entry(void *opaque) { DiscardCo *rwco = opaque; - rwco->ret = bdrv_co_pdiscard(rwco->bs, rwco->sector_num << BDRV_SECTOR_BITS, - rwco->nb_sectors << BDRV_SECTOR_BITS); + rwco->ret = bdrv_co_pdiscard(rwco->bs, rwco->offset, rwco->count); } int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, @@ -2495,23 +2494,23 @@ out: return ret; } -int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) +int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int count) { Coroutine *co; DiscardCo rwco = { .bs = bs, - .sector_num = sector_num, - .nb_sectors = nb_sectors, + .offset = offset, + .count = count, .ret = NOT_DONE, }; if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ - bdrv_discard_co_entry(&rwco); + bdrv_pdiscard_co_entry(&rwco); } else { AioContext *aio_context = bdrv_get_aio_context(bs); - co = qemu_coroutine_create(bdrv_discard_co_entry, &rwco); + co = qemu_coroutine_create(bdrv_pdiscard_co_entry, &rwco); qemu_coroutine_enter(co); while (rwco.ret == NOT_DONE) { aio_poll(aio_context, true); diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 49b6ce6bfd..cbfb3fe064 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -615,9 +615,7 @@ void qcow2_process_discards(BlockDriverState *bs, int ret) /* Discard is optional, ignore the return value */ if (ret >= 0) { - bdrv_discard(bs->file->bs, - d->offset >> BDRV_SECTOR_BITS, - d->bytes >> BDRV_SECTOR_BITS); + bdrv_pdiscard(bs->file->bs, d->offset, d->bytes); } g_free(d); |