diff options
author | Eric Blake <eblake@redhat.com> | 2016-07-15 17:22:54 -0600 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-07-20 14:11:55 +0100 |
commit | 1c6c4bb7f0a4cc3987e58880ef96159985dc1228 (patch) | |
tree | 701615001a4bdce0a17e1d892c127da44ad21d8e /block/block-backend.c | |
parent | 60ebac16bca3e3bf07c7ae67a69a7730aaa48712 (diff) |
block: Convert BB interface to byte-based discards
Change sector-based blk_discard(), blk_co_discard(), and
blk_aio_discard() to instead be byte-based blk_pdiscard(),
blk_co_pdiscard(), and blk_aio_pdiscard(). NBD gets a lot
simpler now that ignoring the unaligned portion of a
byte-based discard request is handled under the hood by
the block layer.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1468624988-423-6-git-send-email-eblake@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/block-backend.c')
-rw-r--r-- | block/block-backend.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index 8b16b95aab..effa038924 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1065,17 +1065,16 @@ BlockAIOCB *blk_aio_flush(BlockBackend *blk, return bdrv_aio_flush(blk_bs(blk), cb, opaque); } -BlockAIOCB *blk_aio_discard(BlockBackend *blk, - int64_t sector_num, int nb_sectors, - BlockCompletionFunc *cb, void *opaque) +BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, + int64_t offset, int count, + BlockCompletionFunc *cb, void *opaque) { - int ret = blk_check_request(blk, sector_num, nb_sectors); + int ret = blk_check_byte_request(blk, offset, count); if (ret < 0) { return blk_abort_aio_request(blk, cb, opaque, ret); } - return bdrv_aio_pdiscard(blk_bs(blk), sector_num << BDRV_SECTOR_BITS, - nb_sectors << BDRV_SECTOR_BITS, cb, opaque); + return bdrv_aio_pdiscard(blk_bs(blk), offset, count, cb, opaque); } void blk_aio_cancel(BlockAIOCB *acb) @@ -1107,15 +1106,14 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf, return bdrv_aio_ioctl(blk_bs(blk), req, buf, cb, opaque); } -int blk_co_discard(BlockBackend *blk, int64_t sector_num, int nb_sectors) +int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int count) { - int ret = blk_check_request(blk, sector_num, nb_sectors); + int ret = blk_check_byte_request(blk, offset, count); if (ret < 0) { return ret; } - return bdrv_co_pdiscard(blk_bs(blk), sector_num << BDRV_SECTOR_BITS, - nb_sectors << BDRV_SECTOR_BITS); + return bdrv_co_pdiscard(blk_bs(blk), offset, count); } int blk_co_flush(BlockBackend *blk) @@ -1506,15 +1504,14 @@ int blk_truncate(BlockBackend *blk, int64_t offset) return bdrv_truncate(blk_bs(blk), offset); } -int blk_discard(BlockBackend *blk, int64_t sector_num, int nb_sectors) +int blk_pdiscard(BlockBackend *blk, int64_t offset, int count) { - int ret = blk_check_request(blk, sector_num, nb_sectors); + int ret = blk_check_byte_request(blk, offset, count); if (ret < 0) { return ret; } - return bdrv_pdiscard(blk_bs(blk), sector_num << BDRV_SECTOR_BITS, - nb_sectors << BDRV_SECTOR_BITS); + return bdrv_pdiscard(blk_bs(blk), offset, count); } int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, |