diff options
author | Eric Blake <eblake@redhat.com> | 2016-07-15 17:23:02 -0600 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-07-20 14:24:25 +0100 |
commit | 447e57c3b056c310463238268d514798b23c376f (patch) | |
tree | 39862b70579c97d2b212eeb10db8bc04f34c8d84 /block | |
parent | 97c7e85cfea4f4edc1536c50ca2f3c1627d8e443 (diff) |
nbd: Switch .bdrv_co_discard() to byte-based
Another step towards killing off sector-based block APIs.
While at it, call directly into nbd-client.c instead of having
a pointless trivial wrapper in nbd.c.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1468624988-423-14-git-send-email-eblake@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/nbd-client.c | 11 | ||||
-rw-r--r-- | block/nbd-client.h | 3 | ||||
-rw-r--r-- | block/nbd.c | 12 |
3 files changed, 10 insertions, 16 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c index f184844e40..d22feea078 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -295,19 +295,20 @@ int nbd_client_co_flush(BlockDriverState *bs) return -reply.error; } -int nbd_client_co_discard(BlockDriverState *bs, int64_t sector_num, - int nb_sectors) +int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int count) { NbdClientSession *client = nbd_get_client_session(bs); - struct nbd_request request = { .type = NBD_CMD_TRIM }; + struct nbd_request request = { + .type = NBD_CMD_TRIM, + .from = offset, + .len = count, + }; struct nbd_reply reply; ssize_t ret; if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) { return 0; } - request.from = sector_num * 512; - request.len = nb_sectors * 512; nbd_coroutine_start(client, &request); ret = nbd_co_send_request(bs, &request, NULL); diff --git a/block/nbd-client.h b/block/nbd-client.h index c618dadc39..62dec33118 100644 --- a/block/nbd-client.h +++ b/block/nbd-client.h @@ -44,8 +44,7 @@ int nbd_client_init(BlockDriverState *bs, Error **errp); void nbd_client_close(BlockDriverState *bs); -int nbd_client_co_discard(BlockDriverState *bs, int64_t sector_num, - int nb_sectors); +int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int count); int nbd_client_co_flush(BlockDriverState *bs); int nbd_client_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags); diff --git a/block/nbd.c b/block/nbd.c index 8a130787c5..42cae0e1fd 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -360,12 +360,6 @@ static void nbd_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.max_transfer = NBD_MAX_BUFFER_SIZE; } -static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num, - int nb_sectors) -{ - return nbd_client_co_discard(bs, sector_num, nb_sectors); -} - static void nbd_close(BlockDriverState *bs) { nbd_client_close(bs); @@ -448,7 +442,7 @@ static BlockDriver bdrv_nbd = { .bdrv_co_writev_flags = nbd_client_co_writev, .bdrv_close = nbd_close, .bdrv_co_flush_to_os = nbd_co_flush, - .bdrv_co_discard = nbd_co_discard, + .bdrv_co_pdiscard = nbd_client_co_pdiscard, .bdrv_refresh_limits = nbd_refresh_limits, .bdrv_getlength = nbd_getlength, .bdrv_detach_aio_context = nbd_detach_aio_context, @@ -466,7 +460,7 @@ static BlockDriver bdrv_nbd_tcp = { .bdrv_co_writev_flags = nbd_client_co_writev, .bdrv_close = nbd_close, .bdrv_co_flush_to_os = nbd_co_flush, - .bdrv_co_discard = nbd_co_discard, + .bdrv_co_pdiscard = nbd_client_co_pdiscard, .bdrv_refresh_limits = nbd_refresh_limits, .bdrv_getlength = nbd_getlength, .bdrv_detach_aio_context = nbd_detach_aio_context, @@ -484,7 +478,7 @@ static BlockDriver bdrv_nbd_unix = { .bdrv_co_writev_flags = nbd_client_co_writev, .bdrv_close = nbd_close, .bdrv_co_flush_to_os = nbd_co_flush, - .bdrv_co_discard = nbd_co_discard, + .bdrv_co_pdiscard = nbd_client_co_pdiscard, .bdrv_refresh_limits = nbd_refresh_limits, .bdrv_getlength = nbd_getlength, .bdrv_detach_aio_context = nbd_detach_aio_context, |