[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 08/27] osdep: Add qemu_lock_fd and qemu_unloc
From: |
Richard W.M. Jones |
Subject: |
Re: [Qemu-devel] [PATCH v4 08/27] osdep: Add qemu_lock_fd and qemu_unlock_fd |
Date: |
Tue, 10 May 2016 08:54:31 +0100 |
User-agent: |
Mutt/1.5.20 (2009-12-10) |
On Tue, May 10, 2016 at 10:50:40AM +0800, Fam Zheng wrote:
> +int qemu_lock_fd(int fd, int64_t start, int64_t len, bool readonly)
I find this new API to be very unintuitive. When I was reading the
other code in block/raw-posix.c I had to refer back to this file to
find out what all the integers meant.
It is also misleading. There's aren't really such a thing as
"readonly locks", or "read locks" or "write locks". I know that
(some) POSIX APIs use these terms, but the terms are wrong.
There are shared locks, and there are exclusive locks. The locks have
nothing to do with reading or writing. In fact the locks only apply
when writing, and are to do with whether you want to allow multiple
writers at the same time (shared lock), or only a single writer
(exclusive lock).
Anyway, I think the boolean "readonly" should be replaced by
some flag like:
#define QEMU_LOCK_SHARED 1
#define QEMU_LOCK_EXCLUSIVE 2
or similar.
Not sure about the start/len. Do we need them in the API at all given
that we've decided to lock a particular byte of the file?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html
- [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 01/27] block: Add BDRV_O_NO_LOCK, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 02/27] qapi: Add lock-image in blockdev-add options, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 04/27] block: Introduce image file locking, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 03/27] blockdev: Add and parse "lock-image" option for block devices, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 06/27] block: Make bdrv_reopen_{commit, abort} private functions, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 05/27] block: Add bdrv_image_locked, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 07/27] block: Handle image locking during reopen, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 09/27] osdep: Introduce qemu_dup, Fam Zheng, 2016/05/09
- [Qemu-devel] [PATCH v4 08/27] osdep: Add qemu_lock_fd and qemu_unlock_fd, Fam Zheng, 2016/05/09
[Qemu-devel] [PATCH v4 10/27] raw-posix: Use qemu_dup, Fam Zheng, 2016/05/09
[Qemu-devel] [PATCH v4 11/27] raw-posix: Implement .bdrv_lockf, Fam Zheng, 2016/05/09
[Qemu-devel] [PATCH v4 13/27] qemu-io: Add "-L" option for BDRV_O_NO_LOCK, Fam Zheng, 2016/05/09
[Qemu-devel] [PATCH v4 12/27] gluster: Implement .bdrv_lockf, Fam Zheng, 2016/05/09