[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] Combine bdrv_read and bdrv_write to bdrv_rw
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] Combine bdrv_read and bdrv_write to bdrv_rw |
Date: |
Wed, 29 Feb 2012 17:07:13 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 |
Il 29/02/2012 17:00, Michael Tokarev ha scritto:
> And how it will be a cleanup?
>
> The whole cow code (and a few others) is not reenterant. Merely
> moving this lock/unlock stuff inth actual methods eliminates two
> current wrappers in cow_co_write() and cow_co_read(), which are
> exactly the same now, and moves this exactly the same code into
> actual methods, which has nothing to do with locking - they're
> not reenterant, and they deal with internal to the format stuff.
> Having this common locking layer on top and _outside_ of the
> actual work helps removing irrelevant code from important paths.
> Also, it will be too easy to forgot to unlock it there by doing
> just "return" somewhere.
It's not very different from leaking memory. It's just the way C works.
In the future, you may add unlock around image access like in qcow2, and
then an unlock/lock pair would be confusing without the lock/unlock outside.
If you are worried about forgetting to unlock, add owner tracking to
qemu-coroutine-lock.c, similar to PTHREAD_MUTEX_ERRORCHECK. That would
be quite useful.
Paolo