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 /nbd/server.c | |
parent | 60ebac16bca3e3bf07c7ae67a69a7730aaa48712 (diff) | |
download | qemu-1c6c4bb7f0a4cc3987e58880ef96159985dc1228.zip qemu-1c6c4bb7f0a4cc3987e58880ef96159985dc1228.tar.gz qemu-1c6c4bb7f0a4cc3987e58880ef96159985dc1228.tar.bz2 |
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 'nbd/server.c')
-rw-r--r-- | nbd/server.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/nbd/server.c b/nbd/server.c index fbc82de..29e2099 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1182,20 +1182,11 @@ static void nbd_trip(void *opaque) break; case NBD_CMD_TRIM: TRACE("Request type is TRIM"); - /* Ignore unaligned head or tail, until block layer adds byte - * interface */ - if (request.len >= BDRV_SECTOR_SIZE) { - request.len -= (request.from + request.len) % BDRV_SECTOR_SIZE; - ret = blk_co_discard(exp->blk, - DIV_ROUND_UP(request.from + exp->dev_offset, - BDRV_SECTOR_SIZE), - request.len / BDRV_SECTOR_SIZE); - if (ret < 0) { - LOG("discard failed"); - reply.error = -ret; - } - } else { - TRACE("trim request too small, ignoring"); + ret = blk_co_pdiscard(exp->blk, request.from + exp->dev_offset, + request.len); + if (ret < 0) { + LOG("discard failed"); + reply.error = -ret; } if (nbd_co_send_reply(req, &reply, 0) < 0) { goto out; |