diff mbox

[v2,3/8] ide: account UNMAP (TRIM) operations

Message ID 1516366207-109842-4-git-send-email-anton.nefedov@virtuozzo.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anton Nefedov Jan. 19, 2018, 12:50 p.m. UTC
Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
---
 hw/ide/core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Eric Blake Jan. 22, 2018, 8:48 p.m. UTC | #1
On 01/19/2018 06:50 AM, Anton Nefedov wrote:
> Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
> ---
>  hw/ide/core.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 

> @@ -460,10 +468,15 @@ 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->is_invalid = true;
>                      goto done;
>                  }
>  
> +                block_acct_start(blk_get_stats(s->blk), &s->acct,
> +                                 count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNMAP);

We're still mixing bytes- and block-based reporting; how easy or hard
would it be to flip block_acct_start() and friends to be byte-based?
But not the subject of this series, per se.
Anton Nefedov Jan. 23, 2018, 10:39 a.m. UTC | #2
On 22/1/2018 11:48 PM, Eric Blake wrote:
> On 01/19/2018 06:50 AM, Anton Nefedov wrote:
>> Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
>> ---
>>   hw/ide/core.c | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
> 
>> @@ -460,10 +468,15 @@ 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->is_invalid = true;
>>                       goto done;
>>                   }
>>   
>> +                block_acct_start(blk_get_stats(s->blk), &s->acct,
>> +                                 count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNMAP);
> 
> We're still mixing bytes- and block-based reporting; how easy or hard
> would it be to flip block_acct_start() and friends to be byte-based?

Quite easy, they already are :)
Alberto Garcia Feb. 7, 2018, 2:39 p.m. UTC | #3
On Fri 19 Jan 2018 01:50:02 PM CET, Anton Nefedov wrote:
> Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto
diff mbox

Patch

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 5be72d4..6fdc936 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -443,6 +443,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;
@@ -460,10 +468,15 @@  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->is_invalid = true;
                     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,