Block layer fixes for 2.11.0-rc3
[Qemu-devel] [PULL 01/10] iotests: fix 075 and 078
In reply to Kevin WolfFrom: John Snow <[email protected]>
Both of these tests are for formats which now stipulate that they are read-only. Adjust the tests to match.
--- tests/qemu-iotests/075 | 18 +++++++++--------- tests/qemu-iotests/078 | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-)
tests/qemu-iotests/075 +9 -9
@@ -48,56 +48,56 @@ offsets_offset=136 echo echo "== check that the first sector can be read ==" _use_sample_img simple-pattern.cloop.bz2 -$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir +$QEMU_IO -r -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== check that the last sector can be read ==" _use_sample_img simple-pattern.cloop.bz2 -$QEMU_IO -c "read $((1024 * 1024 - 512)) 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir +$QEMU_IO -r -c "read $((1024 * 1024 - 512)) 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== block_size must be a multiple of 512 ==" _use_sample_img simple-pattern.cloop.bz2 poke_file "$TEST_IMG" "$block_size_offset" "\x00\x00\x02\x01" -$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir +$QEMU_IO -r -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== block_size cannot be zero ==" _use_sample_img simple-pattern.cloop.bz2 poke_file "$TEST_IMG" "$block_size_offset" "\x00\x00\x00\x00" -$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir +$QEMU_IO -r -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== huge block_size ===" _use_sample_img simple-pattern.cloop.bz2 poke_file "$TEST_IMG" "$block_size_offset" "\xff\xff\xfe\x00" -$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir +$QEMU_IO -r -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== offsets_size overflow ===" _use_sample_img simple-pattern.cloop.bz2 poke_file "$TEST_IMG" "$n_blocks_offset" "\xff\xff\xff\xff" -$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir +$QEMU_IO -r -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== refuse images that require too many offsets ===" _use_sample_img simple-pattern.cloop.bz2 poke_file "$TEST_IMG" "$n_blocks_offset" "\x04\x00\x00\x01" -$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir +$QEMU_IO -r -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== refuse images with non-monotonically increasing offsets ==" _use_sample_img simple-pattern.cloop.bz2 poke_file "$TEST_IMG" "$offsets_offset" "\x00\x00\x00\x00\xff\xff\xff\xff" poke_file "$TEST_IMG" $((offsets_offset + 8)) "\x00\x00\x00\x00\xff\xfe\x00\x00" -$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir +$QEMU_IO -r -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== refuse images with invalid compressed block size ==" _use_sample_img simple-pattern.cloop.bz2 poke_file "$TEST_IMG" "$offsets_offset" "\x00\x00\x00\x00\x00\x00\x00\x00" poke_file "$TEST_IMG" $((offsets_offset + 8)) "\xff\xff\xff\xff\xff\xff\xff\xff" -$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir +$QEMU_IO -r -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir # success, all done echo "*** done"
tests/qemu-iotests/078 +7 -7
@@ -48,41 +48,41 @@ disk_size_offset=$((0x58)) echo echo "== Read from a valid image ==" _use_sample_img empty.bochs.bz2 -{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir +{ $QEMU_IO -r -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== Negative catalog size ==" _use_sample_img empty.bochs.bz2 poke_file "$TEST_IMG" "$catalog_size_offset" "\xff\xff\xff\xff" -{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir +{ $QEMU_IO -r -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== Overflow for catalog size * sizeof(uint32_t) ==" _use_sample_img empty.bochs.bz2 poke_file "$TEST_IMG" "$catalog_size_offset" "\x00\x00\x00\x40" -{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir +{ $QEMU_IO -r -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== Too small catalog bitmap for image size ==" _use_sample_img empty.bochs.bz2 poke_file "$TEST_IMG" "$disk_size_offset" "\x00\xc0\x0f\x00\x00\x00\x00\x7f" -{ $QEMU_IO -c "read 2T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir +{ $QEMU_IO -r -c "read 2T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir _use_sample_img empty.bochs.bz2 poke_file "$TEST_IMG" "$catalog_size_offset" "\x10\x00\x00\x00" -{ $QEMU_IO -c "read 0xfbe00 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir +{ $QEMU_IO -r -c "read 0xfbe00 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== Negative extent size ==" _use_sample_img empty.bochs.bz2 poke_file "$TEST_IMG" "$extent_size_offset" "\x00\x00\x00\x80" -{ $QEMU_IO -c "read 768k 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir +{ $QEMU_IO -r -c "read 768k 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir echo echo "== Zero extent size ==" _use_sample_img empty.bochs.bz2 poke_file "$TEST_IMG" "$extent_size_offset" "\x00\x00\x00\x00" -{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir +{ $QEMU_IO -r -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir # success, all done echo "*** done"
Signature · 1 line
2.13.6
The following changes since commit e7b47c22e2df14d55e3e4426688c929bf8e3f7fb:
osdep.h: Make TIME_MAX handle different time_t types (2017-11-24 13:23:36 +0000)
are available in the git repository at:
git://repo.or.cz/qemu/kevin.git tags/for-upstream
for you to fetch changes up to 5591c001a1056910afd903df3fc3c03f30746623:
Merge remote-tracking branch 'mreitz/tags/pull-block-2017-11-29' into queue-block (2017-11-29 15:37:31 +0100)
----------------------------------------------------------------
Block layer patches for 2.11.0-rc3
----------------------------------------------------------------
Alberto Garcia (1):
blockjob: Remove the job from the list earlier in block_job_unref()
Fam Zheng (2):
docs: Add image locking subsection
qemu-options: Mention locking option of file driver
John Snow (1):
iotests: fix 075 and 078
Kashyap Chamarthy (1):
QAPI & interop: Clarify events emitted by 'block-job-cancel'
Kevin Wolf (2):
block: Expect graph changes in bdrv_parent_drained_begin/end
Merge remote-tracking branch 'mreitz/tags/pull-block-2017-11-29' into queue-block
Paolo Bonzini (3):
blockjob: remove clock argument from block_job_sleep_ns
blockjob: introduce block_job_do_yield
blockjob: reimplement block_job_sleep_ns to allow cancellation
Peter Lieven (1):
block/nfs: fix nfs_client_open for filesize greater than 1TB
qapi/block-core.json | 6 +++ include/block/blockjob.h | 8 +++- include/block/blockjob_int.h | 7 ++- block/backup.c | 4 +- block/commit.c | 2 +- block/io.c | 8 ++-- block/mirror.c | 6 +-- block/nfs.c | 7 ++- block/stream.c | 2 +- blockjob.c | 84 +++++++++++++++++++++++++++------- tests/test-blockjob-txn.c | 2 +- docs/interop/live-block-operations.rst | 50 ++++++++++++-------- docs/qemu-block-drivers.texi | 36 +++++++++++++++ qemu-doc.texi | 1 + qemu-options.hx | 4 ++ tests/qemu-iotests/075 | 18 ++++---- tests/qemu-iotests/078 | 14 +++--- 17 files changed, 187 insertions(+), 72 deletions(-)
[Qemu-devel] [PULL 03/10] qemu-options: Mention locking option of file driver
From: Fam Zheng <[email protected]>
--- qemu-options.hx | 4 ++++ 1 file changed, 4 insertions(+)
qemu-options.hx +4 -0
@@ -693,6 +693,10 @@ This is the protocol-level block driver for accessing regular files. The path to the image file in the local filesystem @item aio Specifies the AIO backend (threads/native, default: threads) +@item locking +Specifies whether the image file is protected with Linux OFD / POSIX locks. The +default is to use the Linux Open File Descriptor API if available, otherwise no +lock is applied. (auto/on/off, default: auto) @end table Example: @example
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 04/10] QAPI & interop: Clarify events emitted by 'block-job-cancel'
In reply to Kevin WolfFrom: Kashyap Chamarthy <[email protected]>
When you cancel an in-progress 'mirror' job (or "active block-commit") with QMP block-job-cancel, it emits the event: BLOCK_JOB_CANCELLED. However, when block-job-cancel is issued *after* drive-mirror has indicated (via the event BLOCK_JOB_READY) that the source and destination have reached synchronization:
[...] # Snip `drive-mirror` invocation & outputs
{
"execute":"block-job-cancel",
"arguments":{
"device":"virtio0"
}
}
{"return": {}}It (block-job-cancel) will counterintuitively emit the event 'BLOCK_JOB_COMPLETED':
{
"timestamp":{
"seconds":1510678024,
"microseconds":526240
},
"event":"BLOCK_JOB_COMPLETED",
"data":{
"device":"virtio0",
"len":41126400,
"offset":41126400,
"speed":0,
"type":"mirror"
}
}But this is expected behaviour, where the _COMPLETED event indicates that synchronization has successfully ended (and the destination now has a point-in-time copy, which is at the time of cancel).
So add a small note to this effect in 'block-core.json'. While at it, also update the "Live disk synchronization -- drive-mirror and blockdev-mirror" section in 'live-block-operations.rst'.
(Thanks: Max Reitz for reminding me of this caveat on IRC.)
--- qapi/block-core.json | 6 ++++ docs/interop/live-block-operations.rst | 50 ++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 18 deletions(-)
qapi/block-core.json +6 -0
@@ -2065,6 +2065,12 @@ # BLOCK_JOB_CANCELLED event. Before that happens the job is still visible when # enumerated using query-block-jobs. # +# Note that if you issue 'block-job-cancel' after 'drive-mirror' has indicated +# (via the event BLOCK_JOB_READY) that the source and destination are +# synchronized, then the event triggered by this command changes to +# BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the +# destination now has a point-in-time copy tied to the time of the cancellation. +# # For streaming, the image file retains its backing file unless the streaming # operation happens to complete just as it is being cancelled. A new streaming # operation can be started at a later time to finish copying all data from the
docs/interop/live-block-operations.rst +32 -18
58 lines not on this page · raw message
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 02/10] docs: Add image locking subsection
In reply to Kevin WolfFrom: Fam Zheng <[email protected]>
This documents the image locking feature and explains when and how related options can be used.
--- docs/qemu-block-drivers.texi | 36 ++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 1 + 2 files changed, 37 insertions(+)
docs/qemu-block-drivers.texi +36 -0
@@ -785,6 +785,42 @@ warning: ssh server @code{ssh.example.com:22} does not support fsync With sufficiently new versions of libssh2 and OpenSSH, @code{fsync} is supported. +@node disk_image_locking +@subsection Disk image file locking + +By default, QEMU tries to protect image files from unexpected concurrent +access, as long as it's supported by the block protocol driver and host +operating system. If multiple QEMU processes (including QEMU emulators and +utilities) try to open the same image with conflicting accessing modes, all but +the first one will get an error. + +This feature is currently supported by the file protocol on Linux with the Open +File Descriptor (OFD) locking API, and can be configured to fall back to POSIX +locking if the POSIX host doesn't support Linux OFD locking. + +To explicitly enable image locking, specify "locking=on" in the file protocol +driver options. If OFD locking is not possible, a warning will be printed and +the POSIX locking API will be used. In this case there is a risk that the lock +will get silently lost when doing hot plugging and block jobs, due to the +shortcomings of the POSIX locking API. + +QEMU transparently handles lock handover during shared storage migration. For +shared virtual disk images between multiple VMs, the "share-rw" device option +should be used. + +Alternatively, locking can be fully disabled by "locking=off" block device +option. In the command line, the option is usually in the form of +"file.locking=off" as the protocol driver is normally placed as a "file" child +under a format driver. For example: + +@code{-blockdev driver=qcow2,file.filename=/path/to/image,file.locking=off,file.driver=file} + +To check if image locking is active, check the output of the "lslocks" command +on host and see if there are locks held by the QEMU process on the image file. +More than one byte could be locked by the QEMU instance, each byte of which +reflects a particular permission that is acquired or protected by the running +block driver. + @c man end @ignore
qemu-doc.texi +1 -0
@@ -405,6 +405,7 @@ encrypted disk images. * disk_images_iscsi:: iSCSI LUNs * disk_images_gluster:: GlusterFS disk images * disk_images_ssh:: Secure Shell (ssh) disk images +* disk_image_locking:: Disk image file locking @end menu @node disk_images_quickstart
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 05/10] blockjob: Remove the job from the list earlier in block_job_unref()
In reply to Kevin WolfFrom: Alberto Garcia <[email protected]>
When destroying a block job in block_job_unref() we should remove it from the job list before calling block_job_remove_all_bdrv().
This is because removing the BDSs can trigger an aio_poll() and wake up other jobs that might attempt to use the block job list. If that happens the job we're currently destroying should not be in that list anymore.
--- blockjob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
blockjob.c +1 -1
@@ -152,6 +152,7 @@ void block_job_unref(BlockJob *job) {if (--job->refcnt ==0 ) {BlockDriverState *bs =blk_bs (job->blk); +QLIST_REMOVE (job, job_list); bs->job =NULL ;block_job_remove_all_bdrv (job); blk_remove_aio_context_notifier(job->blk,
@@ -160,7 +161,6 @@ void block_job_unref(BlockJob *job)blk_unref (job->blk);error_free (job->blocker);g_free (job->id); -QLIST_REMOVE (job, job_list);g_free (job); } }
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 06/10] block: Expect graph changes in bdrv_parent_drained_begin/end
In reply to Kevin WolfThe .drained_begin/end callbacks can (directly or indirectly via aio_poll()) cause block nodes to be removed or the current BdrvChild to point to a different child node.
Use QLIST_FOREACH_SAFE() to make sure we don't access invalid BlockDriverStates or accidentally continue iterating the parents of the new child node instead of the node we actually came from.
--- block/io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
block/io.c +4 -4
@@ -42,9 +42,9 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,void bdrv_parent_drained_begin (BlockDriverState *bs) { -BdrvChild *c; +BdrvChild *c, *next; - QLIST_FOREACH(c, &bs->parents, next_parent) { + QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) {if (c->role->drained_begin) { c->role->drained_begin (c); }
@@ -53,9 +53,9 @@ void bdrv_parent_drained_begin(BlockDriverState *bs)void bdrv_parent_drained_end (BlockDriverState *bs) { -BdrvChild *c; +BdrvChild *c, *next; - QLIST_FOREACH(c, &bs->parents, next_parent) { + QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) {if (c->role->drained_end) { c->role->drained_end (c); }
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 07/10] blockjob: remove clock argument from block_job_sleep_ns
In reply to Kevin WolfFrom: Paolo Bonzini <[email protected]>
All callers are using QEMU_CLOCK_REALTIME, and it will not be possible to support more than one clock when block_job_sleep_ns switches to a single timer stored in the BlockJob struct.
--- include/block/blockjob_int.h | 7 +++---- block/backup.c | 4 ++-- block/commit.c | 2 +- block/mirror.c | 6 +++--- block/stream.c | 2 +- blockjob.c | 5 +++-- tests/test-blockjob-txn.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-)
include/block/blockjob_int.h +3 -4
@@ -139,14 +139,13 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,/** * block_job_sleep_ns: * @job: The job that calls the function. -* @clock: The clock to sleep on. * @ns: How many nanoseconds to stop for. * * Put the job to sleep (assuming that it wasn't canceled) for @ns -* nanoseconds. Canceling the job will not interrupt the wait, so the -* cancel will not process until the coroutine wakes up. +* %QEMU_CLOCK_REALTIME nanoseconds. Canceling the job will not interrupt +* the wait, so the cancel will not process until the coroutine wakes up. */ -void block_job_sleep_ns (BlockJob *job,QEMUClockType type,int64_t ns); +void block_job_sleep_ns (BlockJob *job,int64_t ns);/** * block_job_yield:
block/backup.c +2 -2
@@ -346,9 +346,9 @@ static bool coroutine_fn yield_and_check(BackupBlockJob *job)uint64_t delay_ns =ratelimit_calculate_delay (&job->limit, job->bytes_read); job->bytes_read =0 ; -block_job_sleep_ns (&job->common,QEMU_CLOCK_REALTIME , delay_ns); +block_job_sleep_ns (&job->common, delay_ns); }else { -block_job_sleep_ns (&job->common,QEMU_CLOCK_REALTIME ,0 ); +block_job_sleep_ns (&job->common,0 ); }if (block_job_is_cancelled (&job->common)) {
block/commit.c +1 -1
@@ -174,7 +174,7 @@ static void coroutine_fn commit_run(void *opaque)/* Note that even when no rate limit is applied we need to yield * with no pending I/O here so that bdrv_drain_all() returns. */ -block_job_sleep_ns (&s->common,QEMU_CLOCK_REALTIME , delay_ns); +block_job_sleep_ns (&s->common, delay_ns);if (block_job_is_cancelled (&s->common)) {break ; }
block/mirror.c +3 -3
@@ -598,7 +598,7 @@ static void mirror_throttle(MirrorBlockJob *s)if (now - s->last_pause_ns >SLICE_TIME ) { s->last_pause_ns = now; -block_job_sleep_ns (&s->common,QEMU_CLOCK_REALTIME ,0 ); +block_job_sleep_ns (&s->common,0 ); }else {block_job_pause_point (&s->common); }
@@ -870,13 +870,13 @@ static void coroutine_fn mirror_run(void *opaque) ret =0 ;trace_mirror_before_sleep (s, cnt, s->synced, delay_ns);if (!s->synced) { -block_job_sleep_ns (&s->common,QEMU_CLOCK_REALTIME , delay_ns); +block_job_sleep_ns (&s->common, delay_ns);if (block_job_is_cancelled (&s->common)) {break ; } }else if (!should_complete) { delay_ns = (s->in_flight ==0 && cnt ==0 ?SLICE_TIME :0 ); -block_job_sleep_ns (&s->common,QEMU_CLOCK_REALTIME , delay_ns); +block_job_sleep_ns (&s->common, delay_ns); } s->last_pause_ns =qemu_clock_get_ns (QEMU_CLOCK_REALTIME ); }
block/stream.c +1 -1
@@ -141,7 +141,7 @@ static void coroutine_fn stream_run(void *opaque)/* Note that even when no rate limit is applied we need to yield * with no pending I/O here so that bdrv_drain_all() returns. */ -block_job_sleep_ns (&s->common,QEMU_CLOCK_REALTIME , delay_ns); +block_job_sleep_ns (&s->common, delay_ns);if (block_job_is_cancelled (&s->common)) {break ; }
blockjob.c +3 -2
@@ -788,7 +788,7 @@ bool block_job_is_cancelled(BlockJob *job)return job->cancelled; } -void block_job_sleep_ns (BlockJob *job,QEMUClockType type,int64_t ns) +void block_job_sleep_ns (BlockJob *job,int64_t ns) {assert (job->busy);
@@ -803,7 +803,8 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns)* it wakes and runs, otherwise we risk double-entry or entry after * completion. */ if (!block_job_should_pause (job)) { -co_aio_sleep_ns (blk_get_aio_context (job->blk), type, ns); +co_aio_sleep_ns (blk_get_aio_context (job->blk), +QEMU_CLOCK_REALTIME , ns); }block_job_pause_point (job);
tests/test-blockjob-txn.c +1 -1
@@ -44,7 +44,7 @@ static void coroutine_fn test_block_job_run(void *opaque)while (s->iterations--) {if (s->use_timer) { -block_job_sleep_ns (job,QEMU_CLOCK_REALTIME ,0 ); +block_job_sleep_ns (job,0 ); }else {block_job_yield (job); }
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 08/10] blockjob: introduce block_job_do_yield
In reply to Kevin WolfFrom: Paolo Bonzini <[email protected]>
Hide the clearing of job->busy in a single function, and set it in block_job_enter. This lets block_job_do_yield verify that qemu_coroutine_enter is not used while job->busy = false.
--- blockjob.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
blockjob.c +16 -8
@@ -729,6 +729,15 @@ static bool block_job_should_pause(BlockJob *job)return job->pause_count >0 ; } +static void block_job_do_yield (BlockJob *job) +{ + job->busy = false; +qemu_coroutine_yield (); + +/* Set by block_job_enter before re-entering the coroutine. */ +assert (job->busy); +} + void coroutine_fn block_job_pause_point(BlockJob *job) {assert (job &&block_job_started (job));
@@ -746,9 +755,7 @@ void coroutine_fn block_job_pause_point(BlockJob *job)if (block_job_should_pause (job) && !block_job_is_cancelled (job)) { job->paused = true; - job->busy = false; -qemu_coroutine_yield ();/* wait for block_job_resume() */ - job->busy = true; +block_job_do_yield (job); job->paused = false; }
@@ -778,9 +785,12 @@ void block_job_enter(BlockJob *job)return ; } -if (!job->busy) { -bdrv_coroutine_enter (blk_bs (job->blk), job->co); +if (job->busy) { +return ; } + + job->busy = true; +aio_co_wake (job->co); }bool block_job_is_cancelled (BlockJob *job)
@@ -819,11 +829,9 @@ void block_job_yield(BlockJob *job)return ; } - job->busy = false;if (!block_job_should_pause (job)) { -qemu_coroutine_yield (); +block_job_do_yield (job); } - job->busy = true;block_job_pause_point (job); }
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 09/10] blockjob: reimplement block_job_sleep_ns to allow cancellation
In reply to Kevin WolfFrom: Paolo Bonzini <[email protected]>
This reverts the effects of commit 4afeffc857 ("blockjob: do not allow coroutine double entry or entry-after-completion", 2017-11-21)
This fixed the symptom of a bug rather than the root cause. Canceling the wait on a sleeping blockjob coroutine is generally fine, we just need to make it work correctly across AioContexts. To do so, use a QEMUTimer that calls block_job_enter. Use a mutex to ensure that block_job_enter synchronizes correctly with block_job_sleep_ns.
--- include/block/blockjob.h | 8 +++++- include/block/blockjob_int.h | 4 +-- blockjob.c | 63 ++++++++++++++++++++++++++++++++++++-------- 3 files changed, 61 insertions(+), 14 deletions(-)
include/block/blockjob.h +7 -1
@@ -77,7 +77,7 @@ typedef struct BlockJob {/** * Set to false by the job while the coroutine has yielded and may be * re-entered by block_job_enter(). There may still be I/O or event loop -* activity pending. +* activity pending. Accessed under block_job_mutex (in blockjob.c). */ bool busy;
@@ -135,6 +135,12 @@ typedef struct BlockJob {*/ int ret; +/** +* Timer that is used by @block_job_sleep_ns. Accessed under +* block_job_mutex (in blockjob.c). +*/ +QEMUTimer sleep_timer; +/** Non-NULL if this job is part of a transaction */ BlockJobTxn *txn;QLIST_ENTRY (BlockJob) txn_list;
include/block/blockjob_int.h +2 -2
@@ -142,8 +142,8 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,* @ns: How many nanoseconds to stop for. * * Put the job to sleep (assuming that it wasn't canceled) for @ns -* %QEMU_CLOCK_REALTIME nanoseconds. Canceling the job will not interrupt -* the wait, so the cancel will not process until the coroutine wakes up. +* %QEMU_CLOCK_REALTIME nanoseconds. Canceling the job will immediately +* interrupt the wait. */ void block_job_sleep_ns (BlockJob *job,int64_t ns);
blockjob.c +52 -11
131 lines not on this page · raw message
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 10/10] block/nfs: fix nfs_client_open for filesize greater than 1TB
In reply to Kevin WolfFrom: Peter Lieven <[email protected]>
DIV_ROUND_UP(st.st_size, BDRV_SECTOR_SIZE) was overflowing ret (int) if st.st_size is greater than 1TB.
Message-id: [email protected]
--- block/nfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
block/nfs.c +3 -4
@@ -1,7 +1,7 @@/* * QEMU Block driver for native access to files on NFS shares * -* Copyright (c) 2014-2016 Peter Lieven <[email protected]> +* Copyright (c) 2014-2017 Peter Lieven <[email protected]> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal
@@ -496,7 +496,7 @@ out:static int64_t nfs_client_open (NFSClient *client,QDict *options,int flags,int open_flags,Error **errp) { -int ret = -EINVAL ; +int64_t ret = -EINVAL ;QemuOpts *opts =NULL ;Error *local_err =NULL ;struct stat st;
@@ -686,8 +686,7 @@ static QemuOptsList nfs_create_opts = {static int nfs_file_create (const char *url,QemuOpts *opts,Error **errp) { -int ret =0 ; -int64_t total_size =0 ; +int64_t ret, total_size;NFSClient *client =g_new0 (NFSClient,1 );QDict *options =NULL ;
Signature · 1 line
2.13.6
Peter Maydell
AppliedQuoted 6 lines · Kevin Wolf
The following changes since commit
e7b47c22e2df14d55e3e4426688c929bf8e3f7fb:
osdep.h: MakeTIME_MAXhandle differenttime_ttypes (2017-11-24 13:23:36 +0000)are available in the git repository at:
Quoted 9 lines
git://repo.or.cz/qemu/kevin.gittags/for-upstreamfor you to fetch changes up to
5591c001a1056910afd903df3fc3c03f30746623:Merge remote-tracking branch 'mreitz/tags/pull-block-2017-11-29' into queue-block (2017-11-29 15:37:31 +0100)
----------------------------------------------------------------
Block layer patches for 2.11.0-rc3
Applied, thanks.
-- PMM