diff options
Diffstat (limited to 'nbd')
-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 fbc82de932..29e2099b5e 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; |