All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	Jeff Cody <jcody@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Eric Blake <eblake@redhat.com>,
	qemu-block@nongnu.org, rjones@redhat.com, stefanha@redhat.com,
	pbonzini@redhat.com, John Snow <jsnow@redhat.com>,
	berrange@redhat.com, den@openvz.org
Subject: [Qemu-devel] [PATCH v4 12/27] gluster: Implement .bdrv_lockf
Date: Tue, 10 May 2016 10:50:44 +0800	[thread overview]
Message-ID: <1462848659-28659-13-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1462848659-28659-1-git-send-email-famz@redhat.com>

Reviewed-by: Niels de Vos <ndevos@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/gluster.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/block/gluster.c b/block/gluster.c
index a8aaacf..f9c5050 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -723,6 +723,33 @@ static int64_t qemu_gluster_allocated_file_size(BlockDriverState *bs)
     }
 }
 
+
+static int qemu_gluster_lockf(BlockDriverState *bs, BdrvLockfCmd cmd)
+{
+    BDRVGlusterState *s = bs->opaque;
+    int ret;
+    struct flock fl = (struct flock) {
+        .l_start = 0,
+        .l_whence  = SEEK_SET,
+        .l_len = 0,
+    };
+    switch (cmd) {
+    case BDRV_LOCKF_RWLOCK:
+        fl.l_type = F_WRLCK;
+        break;
+    case BDRV_LOCKF_ROLOCK:
+        fl.l_type = F_RDLCK;
+        break;
+    case BDRV_LOCKF_UNLOCK:
+        fl.l_type = F_UNLCK;
+        break;
+    default:
+        abort();
+    }
+    ret = glfs_posix_lock(s->fd, F_SETLK, &fl);
+    return ret == -1 ? -errno : 0;
+}
+
 static int qemu_gluster_has_zero_init(BlockDriverState *bs)
 {
     /* GlusterFS volume could be backed by a block device */
@@ -764,6 +791,7 @@ static BlockDriver bdrv_gluster = {
     .bdrv_co_readv                = qemu_gluster_co_readv,
     .bdrv_co_writev               = qemu_gluster_co_writev,
     .bdrv_co_flush_to_disk        = qemu_gluster_co_flush_to_disk,
+    .bdrv_lockf                   = qemu_gluster_lockf,
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
 #ifdef CONFIG_GLUSTERFS_DISCARD
     .bdrv_co_discard              = qemu_gluster_co_discard,
@@ -791,6 +819,7 @@ static BlockDriver bdrv_gluster_tcp = {
     .bdrv_co_readv                = qemu_gluster_co_readv,
     .bdrv_co_writev               = qemu_gluster_co_writev,
     .bdrv_co_flush_to_disk        = qemu_gluster_co_flush_to_disk,
+    .bdrv_lockf                   = qemu_gluster_lockf,
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
 #ifdef CONFIG_GLUSTERFS_DISCARD
     .bdrv_co_discard              = qemu_gluster_co_discard,
@@ -818,6 +847,7 @@ static BlockDriver bdrv_gluster_unix = {
     .bdrv_co_readv                = qemu_gluster_co_readv,
     .bdrv_co_writev               = qemu_gluster_co_writev,
     .bdrv_co_flush_to_disk        = qemu_gluster_co_flush_to_disk,
+    .bdrv_lockf                   = qemu_gluster_lockf,
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
 #ifdef CONFIG_GLUSTERFS_DISCARD
     .bdrv_co_discard              = qemu_gluster_co_discard,
@@ -845,6 +875,7 @@ static BlockDriver bdrv_gluster_rdma = {
     .bdrv_co_readv                = qemu_gluster_co_readv,
     .bdrv_co_writev               = qemu_gluster_co_writev,
     .bdrv_co_flush_to_disk        = qemu_gluster_co_flush_to_disk,
+    .bdrv_lockf                   = qemu_gluster_lockf,
     .bdrv_has_zero_init           = qemu_gluster_has_zero_init,
 #ifdef CONFIG_GLUSTERFS_DISCARD
     .bdrv_co_discard              = qemu_gluster_co_discard,
-- 
2.8.2

  parent reply	other threads:[~2016-05-10  2:52 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-10  2:50 [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 01/27] block: Add BDRV_O_NO_LOCK Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 02/27] qapi: Add lock-image in blockdev-add options Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 03/27] blockdev: Add and parse "lock-image" option for block devices Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 04/27] block: Introduce image file locking Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 05/27] block: Add bdrv_image_locked Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 06/27] block: Make bdrv_reopen_{commit, abort} private functions Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 07/27] block: Handle image locking during reopen Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 08/27] osdep: Add qemu_lock_fd and qemu_unlock_fd Fam Zheng
2016-05-10  7:54   ` Richard W.M. Jones
2016-05-10  8:57   ` Daniel P. Berrange
2016-05-10  9:06     ` Richard W.M. Jones
2016-05-10  9:20       ` Daniel P. Berrange
2016-05-11  0:48     ` Fam Zheng
2016-05-11  1:05       ` Fam Zheng
2016-05-11  9:01       ` Daniel P. Berrange
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 09/27] osdep: Introduce qemu_dup Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 10/27] raw-posix: Use qemu_dup Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 11/27] raw-posix: Implement .bdrv_lockf Fam Zheng
2016-05-10  2:50 ` Fam Zheng [this message]
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 13/27] qemu-io: Add "-L" option for BDRV_O_NO_LOCK Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 14/27] qemu-img: Add "-L" option to sub commands Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 15/27] qemu-img: Update documentation of "-L" option Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 16/27] qemu-nbd: Add "--no-lock/-L" option Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 17/27] block: Don't lock drive-backup target image in none mode Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 18/27] mirror: Disable image locking on target backing chain Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 19/27] qemu-iotests: 140: Disable image lock for qemu-io access Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 20/27] qemu-iotests: 046: Move version detection out from verify_io Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 21/27] qemu-iotests: Wait for QEMU processes before checking image in 091 Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 22/27] qemu-iotests: 030: Disable image lock when checking test image Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 23/27] iotests: 087: Disable image lock in cases where file is shared Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 24/27] iotests: Disable image locking in 085 Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 25/27] tests: Use null-co:// instead of /dev/null Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 26/27] block: Turn on image locking by default Fam Zheng
2016-05-10  2:50 ` [Qemu-devel] [PATCH v4 27/27] qemu-iotests: Add test case 153 for image locking Fam Zheng
2016-05-10  8:14 ` [Qemu-devel] [PATCH v4 00/27] block: Lock images when opening Richard W.M. Jones
2016-05-10  8:43   ` Richard W.M. Jones
2016-05-10  8:50     ` Daniel P. Berrange
2016-05-10  9:14       ` Kevin Wolf
2016-05-10  9:23         ` Daniel P. Berrange
2016-05-10  9:35           ` Kevin Wolf
2016-05-10  9:43             ` Daniel P. Berrange
2016-05-10 10:07               ` Kevin Wolf
2016-05-10 10:16                 ` Richard W.M. Jones
2016-05-10 11:08                   ` Kevin Wolf
2016-05-10 11:46                     ` Richard W.M. Jones
2016-05-10 12:01                       ` Kevin Wolf
2016-05-10 12:11                         ` Richard W.M. Jones
2016-05-10 12:22                           ` Daniel P. Berrange
2016-05-10 12:45                             ` Kevin Wolf
2016-05-11  8:04                             ` Markus Armbruster
2016-05-11  8:52                               ` Daniel P. Berrange
2016-05-11  8:04                             ` Fam Zheng
2016-05-11  9:28                               ` Richard W.M. Jones
2016-05-11 10:03                                 ` Kevin Wolf
2016-05-10 10:29                 ` Daniel P. Berrange
2016-05-10 11:14                   ` Kevin Wolf
2016-05-10 10:02         ` Richard W.M. Jones
2016-05-11 11:48 ` Richard W.M. Jones
2016-05-11 11:56   ` Kevin Wolf
2016-05-12  1:07     ` Fam Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462848659-28659-13-git-send-email-famz@redhat.com \
    --to=famz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.