From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1cmU-0008KS-BO for qemu-devel@nongnu.org; Wed, 25 Nov 2015 11:18:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1cmT-0006K4-5d for qemu-devel@nongnu.org; Wed, 25 Nov 2015 11:18:54 -0500 Date: Wed, 25 Nov 2015 17:18:43 +0100 From: Kevin Wolf Message-ID: <20151125161843.GH12581@noname.str.redhat.com> References: <1447108773-6836-1-git-send-email-mreitz@redhat.com> <1447108773-6836-13-git-send-email-mreitz@redhat.com> <20151125155706.GE12581@noname.str.redhat.com> <5655DBD3.2020203@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0OAP2g/MAC+5xKAE" Content-Disposition: inline In-Reply-To: <5655DBD3.2020203@redhat.com> Subject: Re: [Qemu-devel] [PATCH v7 12/24] virtio-blk: Functions for op blocker management List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini --0OAP2g/MAC+5xKAE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 25.11.2015 um 17:03 hat Max Reitz geschrieben: > On 25.11.2015 16:57, Kevin Wolf wrote: > > Am 09.11.2015 um 23:39 hat Max Reitz geschrieben: > >> Put the code for setting up and removing op blockers into an own > >> function, respectively. Then, we can invoke those functions whenever a > >> BDS is removed from an virtio-blk BB or inserted into it. > >> > >> Signed-off-by: Max Reitz > >=20 > > Do you know of a case where this is observable? >=20 > Actually, no. >=20 > > I don't think you can > > change the medium of a virtio-blk device, and blk_set_bs() isn't > > converted to a wrapper around blk_remove/insert_bs() yet. If this patch > > is necessary to fix something observable, the latter is probably a bug. >=20 > So I guess that implies "Otherwise, this patch should be dropped"? I'm not sure. I guess you had a reason to include these patches other than putting the notifiers to use? With blk_set_bs() changed, I think it would have an effect: The op blockers would move from the old BDS to the new top-level one. This sounds desirable to me. > >> diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virt= io-blk.c > >> index c42ddeb..4c95d5b 100644 > >> --- a/hw/block/dataplane/virtio-blk.c > >> +++ b/hw/block/dataplane/virtio-blk.c > >> @@ -39,6 +39,8 @@ struct VirtIOBlockDataPlane { > >> EventNotifier *guest_notifier; /* irq */ > >> QEMUBH *bh; /* bh for guest notification */ > >> =20 > >> + Notifier insert_notifier, remove_notifier; > >> + > >> /* Note that these EventNotifiers are assigned by value. This is > >> * fine as long as you do not call event_notifier_cleanup on them > >> * (because you don't own the file descriptor or handle; you just > >> @@ -137,6 +139,54 @@ static void handle_notify(EventNotifier *e) > >> blk_io_unplug(s->conf->conf.blk); > >> } > >> =20 > >> +static void data_plane_set_up_op_blockers(VirtIOBlockDataPlane *s) > >> +{ > >> + assert(!s->blocker); > >> + error_setg(&s->blocker, "block device is in use by data plane"); > >> + blk_op_block_all(s->conf->conf.blk, s->blocker); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_RESIZE, s->blocke= r); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_DRIVE_DEL, s->blo= cker); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_BACKUP_SOURCE, s-= >blocker); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_CHANGE, s->blocke= r); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_COMMIT_SOURCE, s-= >blocker); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_COMMIT_TARGET, s-= >blocker); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_EJECT, s->blocker= ); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, > >> + s->blocker); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_INTERNAL_SNAPSHOT, > >> + s->blocker); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_INTERNAL_SNAPSHOT= _DELETE, > >> + s->blocker); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_MIRROR, s->blocke= r); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_STREAM, s->blocke= r); > >> + blk_op_unblock(s->conf->conf.blk, BLOCK_OP_TYPE_REPLACE, s->block= er); > >> +} > >=20 > > This makes me wonder: What do we even block here any more? If I didn't > > miss anything, it's only BLOCK_OP_TYPE_BACKUP_TARGET, and I'm not sure > > why this needs to be blocked, or if we simply forgot to enable it. >=20 > Well, even though in practice this wall of code doesn't make much sense, > of course it will be safe for potential additions of new op blockers. >=20 > And of course we actually don't want these blockers at all anymore... Yes, but dataplane shouldn't really be special enough any more that we want to disable features for it initially. By now it sounds more like an easy way to forget unblocking a new feature even though it would work. So perhaps we should really just remove the blockers from dataplane. Then we don't have to answer the question above... Kevin --0OAP2g/MAC+5xKAE Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWVd9jAAoJEH8JsnLIjy/WTosP/iXGFpXPcvx2mLKOVZT+jngZ eRC96hB5HKYehaD/vyUceRJHkVdAVL91vYZ79aNrAMxBrRzOfanIC4bGhku+pN+d 62xierVNwM0Mxh57qrUu3J0TZnzT12Je/a+vezxZel8RhXlynXu3j3org93PN/aJ 1/Wb25g78HWJpN9vpgCn6ZR2mMhmN7I0YhFt7qjt/7U0qQURiQdsfm7nrF2Fv5+U Mfr5Rk26mnS80+a/PpIH+mtY9T+co1PtXVV57YrXdDiHLkspeiPWOgm593qS5cQO nI/MoF5jL5n0uc3gv7YbZiR8Abo8H7zq0JSM1LHPEU19JGQjQDyeeuyjCVGpUfiK 7hjGMC/OuqayhWdz7yNqbQ/IPXR4WQR8yEii+z+gUh7LvpEPlDNUWXjGhioPw1qD XkNPBXPCtK5vVDap8P2reSTYrSbN57I0S+TX/vWnXpIMLZsucKU/FfZ6kIYMQ2BC nYVJDqq/FjWT8jI3SJk9yHsq3umB2eyeN/RLQ6+oczlxlW/wn1Pw6rnefnPHmLiI RCfzTzyM2Q2xD/5/Lx2eTuuGGsJSB29VJwfvdBZ18bWwK828uEi6PpfR7flIu1oG hHiez8OzX9cZrpNwLiCs5O6qJdFyUI1cLH/X+XThRxbNuOM5v3BOwuQV+BnobJxX pquyK6oCLYSWPvsyWShi =MQmU -----END PGP SIGNATURE----- --0OAP2g/MAC+5xKAE--