Skip to content

Commit

Permalink
ide: account UNMAP (TRIM) operations
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-id: 20190923121737.83281-5-anton.nefedov@virtuozzo.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
  • Loading branch information
xantnef authored and XanClic committed Oct 10, 2019
1 parent f344446 commit 99f1803
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hw/ide/core.c
Expand Up @@ -442,6 +442,14 @@ static void ide_issue_trim_cb(void *opaque, int ret)
TrimAIOCB *iocb = opaque;
IDEState *s = iocb->s;

if (iocb->i >= 0) {
if (ret >= 0) {
block_acct_done(blk_get_stats(s->blk), &s->acct);
} else {
block_acct_failed(blk_get_stats(s->blk), &s->acct);
}
}

if (ret >= 0) {
while (iocb->j < iocb->qiov->niov) {
int j = iocb->j;
Expand All @@ -459,10 +467,14 @@ static void ide_issue_trim_cb(void *opaque, int ret)
}

if (!ide_sect_range_ok(s, sector, count)) {
block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_UNMAP);
iocb->ret = -EINVAL;
goto done;
}

block_acct_start(blk_get_stats(s->blk), &s->acct,
count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNMAP);

/* Got an entry! Submit and exit. */
iocb->aiocb = blk_aio_pdiscard(s->blk,
sector << BDRV_SECTOR_BITS,
Expand Down

0 comments on commit 99f1803

Please sign in to comment.