[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [RFC PATCH 06/41] block: Involve block drivers in permi
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-block] [RFC PATCH 06/41] block: Involve block drivers in permission granting |
Date: |
Tue, 14 Feb 2017 11:36:10 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Am 14.02.2017 um 06:51 hat Fam Zheng geschrieben:
> On Mon, 02/13 18:22, Kevin Wolf wrote:
> > +int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
> > + Error **errp)
> > +{
> > + int ret;
> > +
> > + ret = bdrv_child_check_perm(c, perm, shared, errp);
> > + if (ret < 0) {
> > + return ret;
> > + }
> > +
> > + bdrv_child_set_perm(c, perm, shared);
>
> This has an issue of TOCTOU, which means image locking cannot fit in easily.
> Maybe squash them into one callback (.bdrv_try_set_perm) that can return
> error?
That doesn't work, it would leave us with broken error handling. If one
driver in the middle of the update process fails to update the
permissions, we would end up with half of the nodes having the old
permissions and half having the new ones.
I think the file driver needs to lock the file already on check, and
then we need to add a callback for the failure case so that it gives up
the lock again. In other words, we might need a transaction with
prepare/commit/abort here (*sigh*). Hm, or maybe just prepare/abort
could be enough? Needs some thinking about.
Kevin
- [Qemu-block] [RFC PATCH 00/41] New op blocker system, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 02/41] block: Add op blocker permission constants, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 01/41] block: Attach bs->file only during .bdrv_open(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 03/41] block: Add Error argument to bdrv_attach_child(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 04/41] block: Let callers request permissions when attaching a child node, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 05/41] tests: Use opened block node for block job tests, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 06/41] block: Involve block drivers in permission granting, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 07/41] block: Default .bdrv_child_perm() for filter drivers, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 08/41] block: Request child permissions in filter drivers, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 09/41] block: Default .bdrv_child_perm() for format drivers, Kevin Wolf, 2017/02/13
- Re: [Qemu-block] [RFC PATCH 09/41] block: Default .bdrv_child_perm() for format drivers, Max Reitz, 2017/02/15