Block layer patches
The following changes since commit cfe68ae025f704f336d7dd3d1903ce37b445831d:
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-5.0-pull-request' into staging (2020-03-26 20:55:54 +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 df74b1d3dff80983e7a30db1346a4a05847d65fa:
qcow2: Remove unused fields from BDRVQcow2State (2020-03-27 14:47:23 +0100)
----------------------------------------------------------------
Block layer patches:
- Fix another case of mirror block job deadlocks
- Minor fixes
----------------------------------------------------------------
Chen Qun (1):
block/iscsi:use the flags in iscsi_open() prevent Clang warning
Kevin Wolf (3):
Revert "mirror: Don't let an operation wait for itself"
mirror: Wait only for in-flight operations
qcow2: Remove unused fields from BDRVQcow2State
Minwoo Im (1):
nvme: Print 'cqid' for nvme_del_cq
Vladimir Sementsov-Ogievskiy (1):
block: fix bdrv_root_attach_child forget to unref child_bs
block/qcow2.h | 3 --- block.c | 1 + block/iscsi.c | 2 +- block/mirror.c | 30 +++++++++++++++++------------- hw/block/trace-events | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-)
[PULL 4/6] Revert "mirror: Don't let an operation wait for itself"
This reverts commit 7e6c4ff792734e196c8ca82564c56b5e7c6288ca.
The fix was incomplete as it only protected against requests waiting for themselves, but not against requests waiting for each other. We need a different solution.
Message-Id: <[email protected]>
--- block/mirror.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
block/mirror.c +9 -12
@@ -283,14 +283,11 @@ static int mirror_cow_align(MirrorBlockJob *s, int64_t *offset, } static inline void coroutine_fn -mirror_wait_for_any_operation (MirrorBlockJob *s,MirrorOp *self,bool active) +mirror_wait_for_any_operation (MirrorBlockJob *s,bool active) {MirrorOp *op; QTAILQ_FOREACH(op, &s->ops_in_flight, next) { -if (self == op) { -continue ; - }/* Do not wait on pseudo ops, because it may in turn wait on * some other operation to start, which may in fact be the * caller of this function. Since there is only one pseudo op
@@ -305,10 +302,10 @@ mirror_wait_for_any_operation(MirrorBlockJob *s, MirrorOp *self, bool active) } static inline void coroutine_fn -mirror_wait_for_free_in_flight_slot (MirrorBlockJob *s,MirrorOp *self) +mirror_wait_for_free_in_flight_slot (MirrorBlockJob *s) {/* Only non-active operations use up in-flight slots */ -mirror_wait_for_any_operation (s, self, false); +mirror_wait_for_any_operation (s, false); }/* Perform a mirror copy operation.
@@ -351,7 +348,7 @@ static void coroutine_fn mirror_co_read(void *opaque)while (s->buf_free_count < nb_chunks) {trace_mirror_yield_in_flight (s, op->offset, s->in_flight); -mirror_wait_for_free_in_flight_slot (s, op); +mirror_wait_for_free_in_flight_slot (s); }/* Now make a QEMUIOVector taking enough granularity-sized chunks
@@ -558,7 +555,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)while (s->in_flight >=MAX_IN_FLIGHT ) {trace_mirror_yield_in_flight (s, offset, s->in_flight); -mirror_wait_for_free_in_flight_slot (s, pseudo_op); +mirror_wait_for_free_in_flight_slot (s); }if (s->ret <0 ) {
@@ -612,7 +609,7 @@ static void mirror_free_init(MirrorBlockJob *s) static void coroutine_fn mirror_wait_for_all_io(MirrorBlockJob *s) {while (s->in_flight >0 ) { -mirror_wait_for_free_in_flight_slot (s,NULL ); +mirror_wait_for_free_in_flight_slot (s); } }
@@ -810,7 +807,7 @@ static int coroutine_fn mirror_dirty_init(MirrorBlockJob *s)if (s->in_flight >=MAX_IN_FLIGHT ) {trace_mirror_yield (s,UINT64_MAX , s->buf_free_count, s->in_flight); -mirror_wait_for_free_in_flight_slot (s,NULL ); +mirror_wait_for_free_in_flight_slot (s);continue ; }
@@ -963,7 +960,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)/* Do not start passive operations while there are active * writes in progress */ while (s->in_active_write_counter) { -mirror_wait_for_any_operation (s,NULL , true); +mirror_wait_for_any_operation (s, true); }if (s->ret <0 ) {
@@ -989,7 +986,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)if (s->in_flight >=MAX_IN_FLIGHT || s->buf_free_count ==0 || (cnt ==0 && s->in_flight >0 )) {trace_mirror_yield (s, cnt, s->buf_free_count, s->in_flight); -mirror_wait_for_free_in_flight_slot (s,NULL ); +mirror_wait_for_free_in_flight_slot (s);continue ; }else if (cnt !=0 ) { delay_ns =mirror_iteration (s);
Signature · 1 line
2.20.1
[PULL 5/6] mirror: Wait only for in-flight operations
In reply to Kevin Wolfmirror_wait_for_free_in_flight_slot() just picks a random operation to wait for. However, a MirrorOp is already in s->ops_in_flight when mirror_co_read() waits for free slots, so if not enough slots are immediately available, an operation can end up waiting for itself, or two or more operations can wait for each other to complete, which results in a hang.
Fix this by adding a flag to MirrorOp that tells us if the request is already in flight (and therefore occupies slots that it will later free), and picking only such operations for waiting.
Message-Id: <[email protected]>
--- block/mirror.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
block/mirror.c +8 -1
@@ -102,6 +102,7 @@ struct MirrorOp {bool is_pseudo_op;bool is_active_write; +bool is_in_flight;CoQueue waiting_requests;Coroutine *co;
@@ -293,7 +294,9 @@ mirror_wait_for_any_operation(MirrorBlockJob *s, bool active)* caller of this function. Since there is only one pseudo op * at any given time, we will always find some real operation * to wait on. */ -if (!op->is_pseudo_op && op->is_active_write == active) { +if (!op->is_pseudo_op && op->is_in_flight && + op->is_active_write == active) + {qemu_co_queue_wait (&op->waiting_requests,NULL );return ; }
@@ -367,6 +370,7 @@ static void coroutine_fn mirror_co_read(void *opaque)/* Copy the dirty cluster. */ s->in_flight++; s->bytes_in_flight += op->bytes; + op->is_in_flight = true;trace_mirror_one_iteration (s, op->offset, op->bytes); ret = bdrv_co_preadv(s->mirror_top_bs->backing, op->offset, op->bytes,
@@ -382,6 +386,7 @@ static void coroutine_fn mirror_co_zero(void *opaque) op->s->in_flight++; op->s->bytes_in_flight += op->bytes; *op->bytes_handled = op->bytes; + op->is_in_flight = true; ret =blk_co_pwrite_zeroes (op->s->target, op->offset, op->bytes, op->s->unmap ?BDRV_REQ_MAY_UNMAP :0 );
@@ -396,6 +401,7 @@ static void coroutine_fn mirror_co_discard(void *opaque) op->s->in_flight++; op->s->bytes_in_flight += op->bytes; *op->bytes_handled = op->bytes; + op->is_in_flight = true; ret =blk_co_pdiscard (op->s->target, op->offset, op->bytes);mirror_write_complete (op, ret);
@@ -1319,6 +1325,7 @@ static MirrorOp *coroutine_fn active_write_prepare(MirrorBlockJob *s, .offset = offset, .bytes = bytes, .is_active_write = true, + .is_in_flight = true, };qemu_co_queue_init (&op->waiting_requests);QTAILQ_INSERT_TAIL (&s->ops_in_flight, op, next);
Signature · 1 line
2.20.1
[PULL 1/6] block/iscsi:use the flags in iscsi_open() prevent Clang warning
In reply to Kevin WolfFrom: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read
flags &= ~BDRV_O_RDWR;
^ ~~~~~~~~~~~~In iscsi_allocmap_init() only checks BDRV_O_NOCACHE, which is the same in both of flags and bs->open_flags.
We can use the flags instead bs->open_flags to prevent Clang warning.
Message-Id: <[email protected]>
--- block/iscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/iscsi.c +1 -1
@@ -2002,7 +2002,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, iscsilun->cluster_size = iscsilun->bl.opt_unmap_gran * iscsilun->block_size;if (iscsilun->lbprz) { - ret =iscsi_allocmap_init (iscsilun, bs->open_flags); + ret =iscsi_allocmap_init (iscsilun, flags); } }
Signature · 1 line
2.20.1
[PULL 6/6] qcow2: Remove unused fields from BDRVQcow2State
In reply to Kevin WolfThese fields were already removed in commit c3c10f72, but then commit b58deb34 revived them probably due to bad merge conflict resolution. They are still unused, so remove them again.
Message-Id: <[email protected]>
--- block/qcow2.h | 3 --- 1 file changed, 3 deletions(-)
block/qcow2.h +0 -3
@@ -301,9 +301,6 @@ typedef struct BDRVQcow2State {QEMUTimer *cache_clean_timer;unsigned cache_clean_interval; -uint8_t *cluster_cache; -uint8_t *cluster_data; -uint64_t cluster_cache_offset; QLIST_HEAD(, QCowL2Meta) cluster_allocs;uint64_t *refcount_table;
Signature · 1 line
2.20.1
[PULL 2/6] block: fix bdrv_root_attach_child forget to unref child_bs
In reply to Kevin WolfFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
bdrv_root_attach_child promises to drop child_bs reference on failure. It does it on first handled failure path, but not on the second. Fix that.
Message-Id: <[email protected]>
--- block.c | 1 + 1 file changed, 1 insertion(+)
block.c +1 -0
@@ -2617,6 +2617,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,error_propagate (errp, local_err);g_free (child);bdrv_abort_perm_update (child_bs); +bdrv_unref (child_bs);return NULL ; } }
Signature · 1 line
2.20.1
[PULL 3/6] nvme: Print 'cqid' for nvme_del_cq
In reply to Kevin WolfFrom: Minwoo Im <[email protected]>
The given argument for this trace should be cqid, not sqid.
Message-Id: <[email protected]>
--- hw/block/trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/trace-events +1 -1
@@ -37,7 +37,7 @@ nvme_rw(const char *verb, uint32_t blk_count, uint64_t byte_count, uint64_t lba) nvme_create_sq(uint64_t addr, uint16_t sqid, uint16_t cqid, uint16_t qsize, uint16_t qflags) "create submission queue, addr=0x%"PRIx64", sqid=%"PRIu16", cqid=%"PRIu16", qsize=%"PRIu16", qflags=%"PRIu16"" nvme_create_cq(uint64_t addr, uint16_t cqid, uint16_t vector, uint16_t size, uint16_t qflags, int ien) "create completion queue, addr=0x%"PRIx64", cqid=%"PRIu16", vector=%"PRIu16", qsize=%"PRIu16", qflags=%"PRIu16", ien=%d" nvme_del_sq(uint16_t qid) "deleting submission queue sqid=%"PRIu16"" -nvme_del_cq(uint16_t cqid) "deleted completion queue, sqid=%"PRIu16"" +nvme_del_cq(uint16_t cqid) "deleted completion queue, cqid=%"PRIu16"" nvme_identify_ctrl(void) "identify controller" nvme_identify_ns(uint16_t ns) "identify namespace, nsid=%"PRIu16"" nvme_identify_nslist(uint16_t ns) "identify namespace list, nsid=%"PRIu16""
Signature · 1 line
2.20.1
Peter Maydell
AppliedQuoted 11 lines · Kevin Wolf
The following changes since commit
cfe68ae025f704f336d7dd3d1903ce37b445831d:Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-5.0-pull-request' into staging (2020-03-26 20:55:54 +0000)
are available in the Git repository at:
git://repo.or.cz/qemu/kevin.gittags/for-upstreamfor you to fetch changes up to
df74b1d3dff80983e7a30db1346a4a05847d65fa:
Quoted 7 lines
qcow2: Remove unused fields from BDRVQcow2State (2020-03-27 14:47:23 +0100)
----------------------------------------------------------------
Block layer patches:- Fix another case of mirror block job deadlocks
- Minor fixes
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.0
for any user-visible changes.
-- PMM