[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-2.7 05/15] raw-posix: Implement .bdrv_lockf
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH for-2.7 05/15] raw-posix: Implement .bdrv_lockf |
Date: |
Thu, 14 Apr 2016 10:24:18 +0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, 04/13 10:21, Daniel P. Berrange wrote:
> On Wed, Apr 13, 2016 at 05:09:54PM +0800, Fam Zheng wrote:
> > Because virtlockd in libvirt already uses the fcntl lock on the image file,
> > we
> > have to workaround this by locking a digest-mapped temporary file.
> >
> > Signed-off-by: Fam Zheng <address@hidden>
> > ---
> > block/raw-posix.c | 97
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 97 insertions(+)
> >
> > diff --git a/block/raw-posix.c b/block/raw-posix.c
> > index 906d5c9..277f20d 100644
> > --- a/block/raw-posix.c
> > +++ b/block/raw-posix.c
> > @@ -35,6 +35,7 @@
> > #include "raw-aio.h"
> > #include "qapi/util.h"
> > #include "qapi/qmp/qstring.h"
> > +#include "glib.h"
> >
> > #if defined(__APPLE__) && (__MACH__)
> > #include <paths.h>
> > @@ -149,6 +150,9 @@ typedef struct BDRVRawState {
> > bool discard_zeroes:1;
> > bool has_fallocate;
> > bool needs_alignment;
> > + bool image_locked;
> > + int lock_file_fd;
> > + char *lock_file_name;
> > } BDRVRawState;
> >
> > typedef struct BDRVRawReopenState {
> > @@ -397,6 +401,87 @@ static void raw_attach_aio_context(BlockDriverState
> > *bs,
> > #endif
> > }
> >
> > +static int raw_do_lockf(int fd, BdrvLockfCmd cmd)
> > +{
> > + int ret;
> > + struct flock fl = (struct flock) {
> > + .l_start = 0,
> > + .l_whence = SEEK_SET,
> > + .l_len = 0,
> > + };
>
> If you change this to
>
> .l_start = 1,
> .l_len = 1,
>
> then you would be telling a selective lock at byte 1 which would
> not interfere with anything virtlockd currently does, and also
> leave the other bytes unlocked for future use by QEMU or libvirt
> as needed.
That's brillent, thanks a lot!
Fam
- [Qemu-devel] [PATCH for-2.7 00/15] block: Lock images when opening, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 01/15] block: Add BDRV_O_NO_LOCK, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 02/15] qapi: Add lock-image in blockdev-add options, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 03/15] blockdev: Add and parse "lock-image" option for block devices, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 04/15] block: Introduce image file locking interface, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 05/15] raw-posix: Implement .bdrv_lockf, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 07/15] qemu-io: Add "-L" option for BDRV_O_NO_LOCK, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 06/15] gluster: Implement .bdrv_lockf, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 08/15] qemu-iotests: 140: Disable image lock for qemu-io access, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 09/15] qemu-iotests: 046: Move version detection out from verify_io, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 11/15] qemu-iotests: Disable image lock when checking test image, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 10/15] qemu-iotests: Fix lock-image for shared disk in test case 091, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 13/15] ahci-test: Specify "lock-image=off" in CLI, Fam Zheng, 2016/04/13
- [Qemu-devel] [PATCH for-2.7 15/15] block: Turn on image locking by default, Fam Zheng, 2016/04/13