aboutsummaryrefslogtreecommitdiff
path: root/block/nbd-client.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-07-15 17:23:02 -0600
committerStefan Hajnoczi <stefanha@redhat.com>2016-07-20 14:24:25 +0100
commit447e57c3b056c310463238268d514798b23c376f (patch)
tree39862b70579c97d2b212eeb10db8bc04f34c8d84 /block/nbd-client.c
parent97c7e85cfea4f4edc1536c50ca2f3c1627d8e443 (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/nbd-client.c')
-rw-r--r--block/nbd-client.c11
1 files changed, 6 insertions, 5 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);