On 5/12/2017 6:21 PM, Alberto Garcia wrote:
On Mon 20 Nov 2017 05:50:59 PM CET, Anton Nefedov wrote:
Signed-off-by: Anton Nefedov <anton.nefe...@virtuozzo.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
---
  hw/ide/core.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 471d0c9..2e4dea7 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -389,6 +389,7 @@ typedef struct TrimAIOCB {
      QEMUIOVector *qiov;
      BlockAIOCB *aiocb;
      int i, j;
+    BlockAcctCookie acct;
  } TrimAIOCB;
static void trim_aio_cancel(BlockAIOCB *acb)
@@ -426,6 +427,14 @@ static void ide_trim_bh_cb(void *opaque)
  static void ide_issue_trim_cb(void *opaque, int ret)
  {
      TrimAIOCB *iocb = opaque;
+    if (iocb->i >= 0) {
+        if (ret >= 0) {
+            block_acct_done(blk_get_stats(iocb->blk), &iocb->acct);
+        } else {
+            block_acct_failed(blk_get_stats(iocb->blk), &iocb->acct);
+        }
+    }

This part looks fine, but don't you also need to account for invalid
requests (in ide_dma_cb() or somewhere else) ?

Berto


Good point; in fact, the TRIM sector range is never checked.
(well it should be, down at the block layer, and then counted as error).

The motivation was:

    commit d66168ed687325aa6d338ce3a3cff18ce3098ed6
    Author: Michael Tokarev <m...@tls.msk.ru>
    Date:   Wed Aug 13 11:23:31 2014 +0400

    ide: only constrain read/write requests to drive size, not other types

    Commit 58ac321135a introduced a check to ide dma processing which
    constrains all requests to drive size.  However, apparently, some
    valid requests (like TRIM) does not fit in this constraint, and
    fails in 2.1.  So check the range only for reads and writes.


It seems like the removed check was at the wrong place (trim request has
to be parsed first to get offset and nbytes).
Probably it should be put to ide_issue_trim_cb() instead.

cc John (should have done it earlier)

/Anton

Reply via email to