Block patches
Subsystems (2)
The following changes since commit 3913d3707e3debfbf0d2d014a1a793394993b088:
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.7-20160718' into staging (2016-07-18 11:24:15 +0100)
are available in the git repository at:
git://github.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to e1029ae26d96d5de78c2d9af5eddcea92e73a46a:
MAINTAINERS: Add include/block/aio.h to block I/O path section (2016-07-18 15:10:52 +0100)
----------------------------------------------------------------
This is not quite a v2 because I have added more patches. "linux-aio: share one LinuxAioState within an AioContext" is now fixed under mingw.
----------------------------------------------------------------
Cao jin (3):
aio_ctx_check: follow CODING_STYLE
aio-posix: remove useless parameter
virtio-blk: dataplane cleanup
Fam Zheng (1):
MAINTAINERS: Add include/block/aio.h to block I/O path section
Paolo Bonzini (1):
linux-aio: share one LinuxAioState within an AioContext
Roman Pen (1):
linux-aio: prevent submitting more than MAX_EVENTS
Stefan Hajnoczi (1):
checkpatch: consider git extended headers valid patches
Vladimir Sementsov-Ogievskiy (1):
spec/parallels: fix a mistake
MAINTAINERS | 1 + aio-posix.c | 3 +- aio-win32.c | 2 +- async.c | 33 ++++++++--- block/linux-aio.c | 36 +++++++----- block/raw-aio.h | 68 ----------------------- block/raw-posix.c | 119 +++++----------------------------------- block/raw-win32.c | 2 +- block/win32-aio.c | 2 +- docs/specs/parallels.txt | 2 +- hw/block/dataplane/virtio-blk.c | 6 +- include/block/aio.h | 15 ++++- include/block/raw-aio.h | 68 +++++++++++++++++++++++ scripts/checkpatch.pl | 5 ++ 14 files changed, 158 insertions(+), 204 deletions(-) delete mode 100644 block/raw-aio.h create mode 100644 include/block/raw-aio.h
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 1/8] spec/parallels: fix a mistake
From: Vladimir Sementsov-Ogievskiy <[email protected]>
We have only one flag for now - Empty Image flag. The patch fixes unused bits specification and marks bit 1 as usused.
--- docs/specs/parallels.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
docs/specs/parallels.txt +1 -1
@@ -94,7 +94,7 @@ Bytes: Bit 0: Empty Image bit. If set, the image should be considered clear. - Bits 2-31: Unused. + Bits 1-31: Unused. 56 - 63: ext_off Format Extension offset, an offset, in sectors, from the start of
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 2/8] linux-aio: share one LinuxAioState within an AioContext
In reply to Stefan HajnocziFrom: Paolo Bonzini <[email protected]>
This has better performance because it executes fewer system calls and does not use a bottom half per disk.
Originally proposed by Ming Lei.
[Changed #include "raw-aio.h" to "block/raw-aio.h" in win32-aio.c to fix build error as reported by Peter Maydell <[email protected]>. --Stefan]
Message-id: [email protected]
squash! linux-aio: share one LinuxAioState within an AioContext
--- async.c | 23 ++++++++++ block/linux-aio.c | 10 ++-- block/raw-aio.h | 68 --------------------------- block/raw-posix.c | 119 ++++++------------------------------------------ block/raw-win32.c | 2 +- block/win32-aio.c | 2 +- include/block/aio.h | 13 ++++++ include/block/raw-aio.h | 68 +++++++++++++++++++++++++++ 8 files changed, 126 insertions(+), 179 deletions(-) delete mode 100644 block/raw-aio.h create mode 100644 include/block/raw-aio.h
async.c +23 -0
@@ -29,6 +29,7 @@#include "block/thread-pool.h" #include "qemu/main-loop.h" #include "qemu/atomic.h" +#include "block/raw-aio.h" /***********************************************************/ /* bottom halves (can be seen as timers which expire ASAP) */
@@ -242,6 +243,14 @@ aio_ctx_finalize(GSource *source)qemu_bh_delete (ctx->notify_dummy_bh);thread_pool_free (ctx->thread_pool); +#ifdef CONFIG_LINUX_AIO +if (ctx->linux_aio) { +laio_detach_aio_context (ctx->linux_aio, ctx); +laio_cleanup (ctx->linux_aio); + ctx->linux_aio =NULL ; + } +#endif +qemu_mutex_lock (&ctx->bh_lock);while (ctx->first_bh) {QEMUBH *next = ctx->first_bh->next;
@@ -282,6 +291,17 @@ ThreadPool *aio_get_thread_pool(AioContext *ctx)return ctx->thread_pool; } +#ifdef CONFIG_LINUX_AIO +LinuxAioState *aio_get_linux_aio (AioContext *ctx) +{ +if (!ctx->linux_aio) { + ctx->linux_aio =laio_init (); +laio_attach_aio_context (ctx->linux_aio, ctx); + } +return ctx->linux_aio; +} +#endif +void aio_notify (AioContext *ctx) {/* Write e.g. bh->scheduled before reading ctx->notify_me. Pairs
@@ -345,6 +365,9 @@ AioContext *aio_context_new(Error **errp) false, (EventNotifierHandler *) event_notifier_dummy_cb); +#ifdef CONFIG_LINUX_AIO + ctx->linux_aio =NULL ; +#endif ctx->thread_pool =NULL ;qemu_mutex_init (&ctx->bh_lock);rfifolock_init (&ctx->lock, aio_rfifolock_cb, ctx);
block/linux-aio.c +6 -4
@@ -50,6 +50,8 @@ typedef struct { } LaioQueue;struct LinuxAioState { +AioContext *aio_context; +io_context_t ctx;EventNotifier e;
@@ -227,15 +229,14 @@ static void ioq_submit(LinuxAioState *s)void laio_io_plug (BlockDriverState *bs,LinuxAioState *s) { -assert (!s->io_q.plugged); - s->io_q.plugged =1 ; + s->io_q.plugged++; }void laio_io_unplug (BlockDriverState *bs,LinuxAioState *s) {assert (s->io_q.plugged); - s->io_q.plugged =0 ; -if (!s->io_q.blocked && !QSIMPLEQ_EMPTY (&s->io_q.pending)) { +if (--s->io_q.plugged ==0 && + !s->io_q.blocked && !QSIMPLEQ_EMPTY (&s->io_q.pending)) {ioq_submit (s); } }
@@ -325,6 +326,7 @@ void laio_detach_aio_context(LinuxAioState *s, AioContext *old_context)void laio_attach_aio_context (LinuxAioState *s,AioContext *new_context) { + s->aio_context = new_context; s->completion_bh =aio_bh_new (new_context, qemu_laio_completion_bh, s);aio_set_event_notifier (new_context, &s->e, false, qemu_laio_completion_cb);
block/raw-aio.h deleted +0 -68
68 lines not on this page · raw message
block/raw-posix.c +14 -105
222 lines not on this page · raw message
block/raw-win32.c +1 -1
@@ -27,7 +27,7 @@#include "qemu/timer.h" #include "block/block_int.h" #include "qemu/module.h" -#include "raw-aio.h" +#include "block/raw-aio.h" #include "trace.h" #include "block/thread-pool.h" #include "qemu/iov.h"
block/win32-aio.c +1 -1
@@ -27,7 +27,7 @@#include "block/block_int.h" #include "qemu/module.h" #include "block/aio.h" -#include "raw-aio.h" +#include "block/raw-aio.h" #include "qemu/event_notifier.h" #include "qemu/iov.h" #include <windows.h>
include/block/aio.h +13 -0
@@ -47,6 +47,9 @@ typedef struct AioHandler AioHandler;typedef void QEMUBHFunc (void *opaque);typedef void IOHandler (void *opaque); +struct ThreadPool ; +struct LinuxAioState ; +struct AioContext {GSource source;
@@ -119,6 +122,13 @@ struct AioContext {/* Thread pool for performing work and receiving completion callbacks */ struct ThreadPool *thread_pool; +#ifdef CONFIG_LINUX_AIO +/* State for native Linux AIO. Uses aio_context_acquire/release for +* locking. +*/ +struct LinuxAioState *linux_aio; +#endif +/* TimerLists for calling timers - one per clock type */ QEMUTimerListGroup tlg;
@@ -335,6 +345,9 @@ GSource *aio_get_g_source(AioContext *ctx);/* Return the ThreadPool bound to this AioContext */ struct ThreadPool *aio_get_thread_pool (AioContext *ctx); +/* Return the LinuxAioState bound to this AioContext */ +struct LinuxAioState *aio_get_linux_aio (AioContext *ctx); +/** * aio_timer_new: * @ctx: the aio context
include/block/raw-aio.h new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 3/8] aio_ctx_check: follow CODING_STYLE
In reply to Stefan HajnocziFrom: Cao jin <[email protected]>
replace tab with spaces
Message-id: [email protected]
--- async.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
async.c +1 -1
@@ -218,7 +218,7 @@ aio_ctx_check(GSource *source)for (bh = ctx->first_bh; bh; bh = bh->next) {if (!bh->deleted && bh->scheduled) {return true; - } + } }return aio_pending (ctx) || (timerlistgroup_deadline_ns (&ctx->tlg) ==0 ); }
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 4/8] linux-aio: prevent submitting more than MAX_EVENTS
In reply to Stefan HajnocziFrom: Roman Pen <[email protected]>
Invoking io_setup(MAX_EVENTS) we ask kernel to create ring buffer for us with specified number of events. But kernel ring buffer allocation logic is a bit tricky (ring buffer is page size aligned + some percpu allocation are required) so eventually more than requested events number is allocated.
Quoted 1 line
From a userspace side we have to follow the convention and should not try
to io_submit() more or logic, which consumes completed events, should be changed accordingly. The pitfall is in the following sequence:
MAX_EVENTS = 128
io_setup(MAX_EVENTS)
io_submit(MAX_EVENTS)
io_submit(MAX_EVENTS)
/* now 256 events are in-flight */
io_getevents(MAX_EVENTS) = 128
/* we can handle only 128 events at once, to be sure
* that nothing is pended the io_getevents(MAX_EVENTS)
* call must be invoked once more or hang will happen. */To prevent the hang or reiteration of io_getevents() call this patch restricts the number of in-flights, which is now limited to MAX_EVENTS.
Message-id: [email protected]
--- block/linux-aio.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
block/linux-aio.c +16 -10
@@ -28,8 +28,6 @@*/ #define MAX_EVENTS 128 -#define MAX_QUEUED_IO 128 -struct qemu_laiocb {BlockAIOCB common;Coroutine *co;
@@ -44,7 +42,8 @@ struct qemu_laiocb {typedef struct {int plugged; -unsigned int n; +unsigned int in_queue; +unsigned int in_flight;bool blocked; QSIMPLEQ_HEAD(, qemu_laiocb) pending; }LaioQueue ;
@@ -131,6 +130,7 @@ static void qemu_laio_completion_bh(void *opaque) s->event_max =0 ;return ;/* no more events */ } + s->io_q.in_flight -= s->event_max; }/* Reschedule so nested event loops see currently pending completions */
@@ -192,7 +192,8 @@ static void ioq_init(LaioQueue *io_q) {QSIMPLEQ_INIT (&io_q->pending); io_q->plugged =0 ; - io_q->n =0 ; + io_q->in_queue =0 ; + io_q->in_flight =0 ; io_q->blocked = false; }
@@ -200,14 +201,17 @@ static void ioq_submit(LinuxAioState *s) {int ret, len;struct qemu_laiocb *aiocb; -struct iocb *iocbs[MAX_QUEUED_IO ]; +struct iocb *iocbs[MAX_EVENTS ]; QSIMPLEQ_HEAD(, qemu_laiocb) completed; do { + if (s->io_q.in_flight >= MAX_EVENTS) { + break; + } len = 0; QSIMPLEQ_FOREACH(aiocb, &s->io_q.pending, next) { iocbs[len++] = &aiocb->iocb; - if (len == MAX_QUEUED_IO) { + if (s->io_q.in_flight + len >= MAX_EVENTS) { break; } }
@@ -220,11 +224,12 @@ static void ioq_submit(LinuxAioState *s)abort (); } - s->io_q.n -= ret; + s->io_q.in_flight += ret; + s->io_q.in_queue -= ret; aiocb = container_of(iocbs[ret - 1], struct qemu_laiocb, iocb);QSIMPLEQ_SPLIT_AFTER (&s->io_q.pending, aiocb, next, &completed); }while (ret == len && !QSIMPLEQ_EMPTY (&s->io_q.pending)); - s->io_q.blocked = (s->io_q.n >0 ); + s->io_q.blocked = (s->io_q.in_queue >0 ); }void laio_io_plug (BlockDriverState *bs,LinuxAioState *s)
@@ -264,9 +269,10 @@ static int laio_do_submit(int fd, struct qemu_laiocb *laiocb, off_t offset,io_set_eventfd (&laiocb->iocb,event_notifier_get_fd (&s->e));QSIMPLEQ_INSERT_TAIL (&s->io_q.pending, laiocb, next); - s->io_q.n++; + s->io_q.in_queue++;if (!s->io_q.blocked && - (!s->io_q.plugged || s->io_q.n >=MAX_QUEUED_IO )) { + (!s->io_q.plugged || + s->io_q.in_flight + s->io_q.in_queue >=MAX_EVENTS )) {ioq_submit (s); }
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 5/8] aio-posix: remove useless parameter
In reply to Stefan HajnocziFrom: Cao jin <[email protected]>
Parameter **errp of aio_context_setup() is useless, remove it and clean up the related code.
Message-id: [email protected]
--- aio-posix.c | 3 ++- aio-win32.c | 2 +- async.c | 8 ++------ include/block/aio.h | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-)
aio-posix.c +2 -1
@@ -485,12 +485,13 @@ bool aio_poll(AioContext *ctx, bool blocking)return progress; } -void aio_context_setup (AioContext *ctx,Error **errp) +void aio_context_setup (AioContext *ctx) {#ifdef CONFIG_EPOLL_CREATE1 assert (!ctx->epollfd); ctx->epollfd =epoll_create1 (EPOLL_CLOEXEC );if (ctx->epollfd ==-1 ) { +fprintf (stderr,"Failed to create epoll instance: %s" ,strerror (errno)); ctx->epoll_available = false; }else { ctx->epoll_available = true;
aio-win32.c +1 -1
@@ -371,6 +371,6 @@ bool aio_poll(AioContext *ctx, bool blocking)return progress; } -void aio_context_setup (AioContext *ctx,Error **errp) +void aio_context_setup (AioContext *ctx) { }
async.c +2 -6
@@ -347,14 +347,10 @@ AioContext *aio_context_new(Error **errp) {int ret;AioContext *ctx; -Error *local_err =NULL ; ctx = (AioContext *)g_source_new (&aio_source_funcs,sizeof (AioContext)); -aio_context_setup (ctx, &local_err); -if (local_err) { -error_propagate (errp, local_err); - goto fail; - } +aio_context_setup (ctx); + ret =event_notifier_init (&ctx->notifier, false);if (ret <0 ) {error_setg_errno (errp, -ret,"Failed to initialize event notifier" );
include/block/aio.h +1 -1
@@ -452,6 +452,6 @@ static inline bool aio_node_check(AioContext *ctx, bool is_external)* * Initialize the aio context. */ -void aio_context_setup (AioContext *ctx,Error **errp); +void aio_context_setup (AioContext *ctx);#endif
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 6/8] checkpatch: consider git extended headers valid patches
In reply to Stefan HajnocziRenames look like this with git-diff(1) when diff.renames = true is set:
diff --git a/a b/b similarity index 100% rename from a rename to b
This raises the "Does not appear to be a unified-diff format patch" error because checkpatch.pl only considers a diff valid if it contains at least one "@@" hunk.
This patch accepts renames and copies too so that checkpatch.pl exits successfully when a diff only renames/copies files. The git diff extended header format is described on the git-diff(1) man page.
Message-id: [email protected]
--- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+)
scripts/checkpatch.pl +5 -0
@@ -1279,6 +1279,11 @@ sub process { } } +# Accept git diff extended headers as valid patches + if ($line =~ /^(?:rename|copy) (?:from|to) [\w\/\.\-]+\s*$/) { + $is_patch = 1; + } + #check the patch for a signoff: if ($line =~ /^\s*signed-off-by:/i) { # This is a signoff, if ugly, so do not double report.
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 7/8] virtio-blk: dataplane cleanup
In reply to Stefan HajnocziFrom: Cao jin <[email protected]>
No need duplicate the judgment, there is one in function entry.
Message-id: [email protected]
--- hw/block/dataplane/virtio-blk.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
hw/block/dataplane/virtio-blk.c +2 -4
@@ -112,10 +112,8 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, s->vdev = vdev; s->conf = conf; -if (conf->iothread) { - s->iothread = conf->iothread; -object_ref (OBJECT (s->iothread)); - } + s->iothread = conf->iothread; +object_ref (OBJECT (s->iothread)); s->ctx =iothread_get_aio_context (s->iothread); s->bh =aio_bh_new (s->ctx, notify_guest_bh, s); s->batch_notify_vqs =bitmap_new (conf->num_queues);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 8/8] MAINTAINERS: Add include/block/aio.h to block I/O path section
In reply to Stefan HajnocziFrom: Fam Zheng <[email protected]>
This file is actually the header for async.c and aio-*.c., so add it to the same section.
Message-id: [email protected]
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1027,6 +1027,7 @@ F: async.c F: aio-*.c F: block/io.c F: migration/block* +F: include/block/aio.h T: git git://github.com/stefanha/qemu.git block Block Jobs
Signature · 1 line
2.7.4
Peter Maydell
AppliedQuoted 10 lines · Stefan Hajnoczi
The following changes since commit
3913d3707e3debfbf0d2d014a1a793394993b088:Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.7-20160718' into staging (2016-07-18 11:24:15 +0100)
are available in the git repository at:
git://github.com/stefanha/qemu.gittags/block-pull-requestfor you to fetch changes up to
e1029ae26d96d5de78c2d9af5eddcea92e73a46a:
Quoted 8 lines
MAINTAINERS: Addinclude/block/aio.hto block I/O path section (2016-07-18 15:10:52 +0100)----------------------------------------------------------------
This is not quite a v2 because I have added more patches. "linux-aio: share one LinuxAioState within an AioContext" is now fixed under mingw.
----------------------------------------------------------------
Applied, thanks.
-- PMM