qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH 04/17] block: Convert bdrv_aio_discard() to byte-bas


From: Eric Blake
Subject: [Qemu-block] [PATCH 04/17] block: Convert bdrv_aio_discard() to byte-based
Date: Wed, 22 Jun 2016 09:51:01 -0600

Another step towards byte-based interfaces everywhere.  Replace
the sector-based bdrv_aio_discard() with a new byte-based
bdrv_aio_pdiscard(), which silently ignores any unaligned head
or tail.  Driver callbacks will be converted in followup patches.

Signed-off-by: Eric Blake <address@hidden>
---
 include/block/block.h |  6 +++---
 block/block-backend.c |  3 ++-
 block/io.c            | 15 +++++++--------
 block/trace-events    |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/block/block.h b/include/block/block.h
index a93bf11..71dfaa2 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -319,9 +319,9 @@ BlockAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t 
sector_num,
                             BlockCompletionFunc *cb, void *opaque);
 BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,
                            BlockCompletionFunc *cb, void *opaque);
-BlockAIOCB *bdrv_aio_discard(BlockDriverState *bs,
-                             int64_t sector_num, int nb_sectors,
-                             BlockCompletionFunc *cb, void *opaque);
+BlockAIOCB *bdrv_aio_pdiscard(BlockDriverState *bs,
+                              int64_t offset, int count,
+                              BlockCompletionFunc *cb, void *opaque);
 void bdrv_aio_cancel(BlockAIOCB *acb);
 void bdrv_aio_cancel_async(BlockAIOCB *acb);

diff --git a/block/block-backend.c b/block/block-backend.c
index f56c573..0a488f7 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1069,7 +1069,8 @@ BlockAIOCB *blk_aio_discard(BlockBackend *blk,
         return blk_abort_aio_request(blk, cb, opaque, ret);
     }

-    return bdrv_aio_discard(blk_bs(blk), sector_num, nb_sectors, cb, opaque);
+    return bdrv_aio_pdiscard(blk_bs(blk), sector_num << BDRV_SECTOR_BITS,
+                             nb_sectors << BDRV_SECTOR_BITS, cb, opaque);
 }

 void blk_aio_cancel(BlockAIOCB *acb)
diff --git a/block/io.c b/block/io.c
index d442ce7..5409679 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2187,7 +2187,7 @@ BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,
     return &acb->common;
 }

-static void coroutine_fn bdrv_aio_discard_co_entry(void *opaque)
+static void coroutine_fn bdrv_aio_pdiscard_co_entry(void *opaque)
 {
     BlockAIOCBCoroutine *acb = opaque;
     BlockDriverState *bs = acb->common.bs;
@@ -2197,22 +2197,21 @@ static void coroutine_fn bdrv_aio_discard_co_entry(void 
*opaque)
     bdrv_co_complete(acb);
 }

-BlockAIOCB *bdrv_aio_discard(BlockDriverState *bs,
-        int64_t sector_num, int nb_sectors,
-        BlockCompletionFunc *cb, void *opaque)
+BlockAIOCB *bdrv_aio_pdiscard(BlockDriverState *bs, int64_t offset, int count,
+                              BlockCompletionFunc *cb, void *opaque)
 {
     Coroutine *co;
     BlockAIOCBCoroutine *acb;
-    QEMUIOVector qiov = { .size = nb_sectors << BDRV_SECTOR_BITS, };
+    QEMUIOVector qiov = { .size = count, };

-    trace_bdrv_aio_discard(bs, sector_num, nb_sectors, opaque);
+    trace_bdrv_aio_pdiscard(bs, offset, count, opaque);

     acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);
     acb->need_bh = true;
     acb->req.error = -EINPROGRESS;
-    acb->req.offset = sector_num << BDRV_SECTOR_BITS;
+    acb->req.offset = offset;
     acb->req.qiov = &qiov;
-    co = qemu_coroutine_create(bdrv_aio_discard_co_entry);
+    co = qemu_coroutine_create(bdrv_aio_pdiscard_co_entry);
     qemu_coroutine_enter(co, acb);

     bdrv_co_maybe_schedule_bh(acb);
diff --git a/block/trace-events b/block/trace-events
index 354967e..90d618a 100644
--- a/block/trace-events
+++ b/block/trace-events
@@ -9,7 +9,7 @@ blk_co_preadv(void *blk, void *bs, int64_t offset, unsigned int 
bytes, int flags
 blk_co_pwritev(void *blk, void *bs, int64_t offset, unsigned int bytes, int 
flags) "blk %p bs %p offset %"PRId64" bytes %u flags %x"

 # block/io.c
-bdrv_aio_discard(void *bs, int64_t sector_num, int nb_sectors, void *opaque) 
"bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+bdrv_aio_pdiscard(void *bs, int64_t offset, int count, void *opaque) "bs %p 
offset %"PRId64" count %d opaque %p"
 bdrv_aio_flush(void *bs, void *opaque) "bs %p opaque %p"
 bdrv_aio_readv(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs 
%p sector_num %"PRId64" nb_sectors %d opaque %p"
 bdrv_aio_writev(void *bs, int64_t sector_num, int nb_sectors, void *opaque) 
"bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
-- 
2.5.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]