Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-0…
Browse files Browse the repository at this point in the history
…7-15' into staging

Block patches for 4.1-rc1:
- Fixes for the NVMe block driver, the gluster block driver, and for
  running multiple block jobs concurrently on a single chain

# gpg: Signature made Mon 15 Jul 2019 14:51:43 BST
# gpg:                using RSA key 91BEB60A30DB3E8857D11829F407DB0061D5CF40
# gpg:                issuer "mreitz@redhat.com"
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>" [full]
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* remotes/maxreitz/tags/pull-block-2019-07-15:
  gluster: fix .bdrv_reopen_prepare when backing file is a JSON object
  iotests: Add read-only test case to 030
  iotests: Add new case to 030
  iotests: Add @use_log to VM.run_job()
  iotests: Compare error messages in 030
  iotests: Fix throttling in 030
  block: Deep-clear inherits_from
  block/stream: Swap backing file change order
  block/stream: Fix error path
  block: Add BDS.never_freeze
  nvme: Set number of queues later in nvme_init()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jul 15, 2019
2 parents a68725f + 0b1847b commit 5ea8ec2
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 50 deletions.
42 changes: 32 additions & 10 deletions block.c
Expand Up @@ -2472,18 +2472,20 @@ void bdrv_root_unref_child(BdrvChild *child)
bdrv_unref(child_bs);
}

void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
/**
* Clear all inherits_from pointers from children and grandchildren of
* @root that point to @root, where necessary.
*/
static void bdrv_unset_inherits_from(BlockDriverState *root, BdrvChild *child)
{
if (child == NULL) {
return;
}

if (child->bs->inherits_from == parent) {
BdrvChild *c;
BdrvChild *c;

/* Remove inherits_from only when the last reference between parent and
* child->bs goes away. */
QLIST_FOREACH(c, &parent->children, next) {
if (child->bs->inherits_from == root) {
/*
* Remove inherits_from only when the last reference between root and
* child->bs goes away.
*/
QLIST_FOREACH(c, &root->children, next) {
if (c != child && c->bs == child->bs) {
break;
}
Expand All @@ -2493,6 +2495,18 @@ void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
}
}

QLIST_FOREACH(c, &child->bs->children, next) {
bdrv_unset_inherits_from(root, c);
}
}

void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
{
if (child == NULL) {
return;
}

bdrv_unset_inherits_from(parent, child);
bdrv_root_unref_child(child);
}

Expand Down Expand Up @@ -4416,6 +4430,14 @@ int bdrv_freeze_backing_chain(BlockDriverState *bs, BlockDriverState *base,
return -EPERM;
}

for (i = bs; i != base; i = backing_bs(i)) {
if (i->backing && backing_bs(i)->never_freeze) {
error_setg(errp, "Cannot freeze '%s' link to '%s'",
i->backing->name, backing_bs(i)->node_name);
return -EPERM;
}
}

for (i = bs; i != base; i = backing_bs(i)) {
if (i->backing) {
i->backing->frozen = true;
Expand Down
4 changes: 4 additions & 0 deletions block/commit.c
Expand Up @@ -298,6 +298,10 @@ void commit_start(const char *job_id, BlockDriverState *bs,
if (!filter_node_name) {
commit_top_bs->implicit = true;
}

/* So that we can always drop this node */
commit_top_bs->never_freeze = true;

commit_top_bs->total_sectors = top->total_sectors;

bdrv_append(commit_top_bs, top, &local_err);
Expand Down
12 changes: 11 additions & 1 deletion block/gluster.c
Expand Up @@ -931,7 +931,17 @@ static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
gconf->has_debug = true;
gconf->logfile = g_strdup(s->logfile);
gconf->has_logfile = true;
reop_s->glfs = qemu_gluster_init(gconf, state->bs->filename, NULL, errp);

/*
* If 'state->bs->exact_filename' is empty, 'state->options' should contain
* the JSON parameters already parsed.
*/
if (state->bs->exact_filename[0] != '\0') {
reop_s->glfs = qemu_gluster_init(gconf, state->bs->exact_filename, NULL,
errp);
} else {
reop_s->glfs = qemu_gluster_init(gconf, NULL, state->options, errp);
}
if (reop_s->glfs == NULL) {
ret = -errno;
goto exit;
Expand Down
4 changes: 4 additions & 0 deletions block/mirror.c
Expand Up @@ -1551,6 +1551,10 @@ static BlockJob *mirror_start_job(
if (!filter_node_name) {
mirror_top_bs->implicit = true;
}

/* So that we can always drop this node */
mirror_top_bs->never_freeze = true;

mirror_top_bs->total_sectors = bs->total_sectors;
mirror_top_bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED;
mirror_top_bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
Expand Down
2 changes: 1 addition & 1 deletion block/nvme.c
Expand Up @@ -613,12 +613,12 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,

/* Set up admin queue. */
s->queues = g_new(NVMeQueuePair *, 1);
s->nr_queues = 1;
s->queues[0] = nvme_create_queue_pair(bs, 0, NVME_QUEUE_SIZE, errp);
if (!s->queues[0]) {
ret = -EINVAL;
goto out;
}
s->nr_queues = 1;
QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000);
s->regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << 16) | NVME_QUEUE_SIZE);
s->regs->asq = cpu_to_le64(s->queues[0]->sq.iova);
Expand Down
4 changes: 2 additions & 2 deletions block/stream.c
Expand Up @@ -78,8 +78,8 @@ static int stream_prepare(Job *job)
base_fmt = base->drv->format_name;
}
}
ret = bdrv_change_backing_file(bs, base_id, base_fmt);
bdrv_set_backing_hd(bs, base, &local_err);
ret = bdrv_change_backing_file(bs, base_id, base_fmt);
if (local_err) {
error_report_err(local_err);
return -EPERM;
Expand Down Expand Up @@ -284,5 +284,5 @@ void stream_start(const char *job_id, BlockDriverState *bs,
if (bs_read_only) {
bdrv_reopen_set_read_only(bs, true, NULL);
}
bdrv_unfreeze_backing_chain(bs, base);
bdrv_unfreeze_backing_chain(bs, bottom);
}
3 changes: 3 additions & 0 deletions include/block/block_int.h
Expand Up @@ -885,6 +885,9 @@ struct BlockDriverState {

/* Only read/written by whoever has set active_flush_req to true. */
unsigned int flushed_gen; /* Flushed write generation */

/* BdrvChild links to this node may never be frozen */
bool never_freeze;
};

struct BlockBackendRootState {
Expand Down

0 comments on commit 5ea8ec2

Please sign in to comment.