Block layer patches:

- Fix another case of mirror block job deadlocks
 - Minor fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJefhlNAAoJEH8JsnLIjy/WUwAQAJN1R/8kSJK+6HNjb16YFQqn
 oVscCY/5FQBzTFTMzI5aso6tMDxvc95C+zbhbP4pUAqfgbi5i2eFEKHaxJ+LY13c
 XOHANoRoOcd0ASDkPfmvvV37ucn3iQ0CDmXyRqlcjGYhrRi8DTyyYC8/NCoaYUpG
 FzoM162ouMA9NOC1hSpGhF2OYsmfefP+ogp3MHVyPbRejtqvU0EbUazXyrYGINM7
 IuKyIJZyZ9nvEF5c4yFh2rzzg6OJMmG9GxhHl+DnG8h0UUcz2ypo9eOBlP4NR3YP
 iRO0lvNtiQjlbvBln6uxudKvZNtJWgdpVM14lLzFR+fytBowSCTg+scpQ7KPSDWs
 Lf95376k8kJmejroZ3YZHvdr1YkXcPxfa8NbXuuIzJ+Rp5JCGOfh8m0IsLR8lrAn
 IWZAoDAhDKylocRLU+c/KV/PLZGN9wKoSLfydnUd0g7jGDDhWWIl4rEPJnAu3ceb
 b5cOWRTPi17ouVaZ0O7IOvgiHDAHhWwypfurCRn1pVP9YM+ly1MEc8kxqhi8nGDf
 RgM4PNbNEyh2zVuGcKpmGEVhHLbAzsO+uKrknOovkhDIQM9n0ffeuJi7lsFfv6DZ
 RmMT0gZnxkFTWSwzcGuNGTAKsCWI2titZnnzM5eqhdjk1L9LxlbX4mGqCr+3Kbt2
 a2Ep8MkV52eYLlYuwzOz
 =gcmy
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches:

- Fix another case of mirror block job deadlocks
- Minor fixes

# gpg: Signature made Fri 27 Mar 2020 15:18:37 GMT
# gpg:                using RSA key 7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream:
  qcow2: Remove unused fields from BDRVQcow2State
  mirror: Wait only for in-flight operations
  Revert "mirror: Don't let an operation wait for itself"
  nvme: Print 'cqid' for nvme_del_cq
  block: fix bdrv_root_attach_child forget to unref child_bs
  block/iscsi:use the flags in iscsi_open() prevent Clang warning

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-03-27 16:04:22 +00:00
commit 77a48a743f
5 changed files with 20 additions and 18 deletions

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -102,6 +102,7 @@ struct MirrorOp {
bool is_pseudo_op;
bool is_active_write;
bool is_in_flight;
CoQueue waiting_requests;
Coroutine *co;
@ -283,20 +284,19 @@ 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
* 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;
}
@ -305,10 +305,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 +351,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
@ -370,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,
@ -385,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);
@ -399,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);
@ -558,7 +561,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 +615,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 +813,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 +966,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 +992,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);
@ -1322,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);

View File

@ -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;

View File

@ -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""