Skip to contentSkip to conversation

rbd: Add support for bdrv_invalidate_cache

PATCH Applied [email protected] 3 participants 4 messages Oct 9, 2014 – Oct 28, 2014 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rbd: Add support for bdrv_invalidate_cache

From: Adam Crume <[email protected]>

This fixes Ceph issue 2467.

---
 block/rbd.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
block/rbd.c +16 -0
index 96947e3..d88ba70 100644
@@ -887,6 +887,19 @@ static BlockDriverAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs,
 }
 #endif
 
+#ifdef LIBRBD_SUPPORTS_INVALIDATE
+static void qemu_rbd_invalidate_cache(BlockDriverState *bs,
+                                      Error **errp)
+{
+    BDRVRBDState *s = bs->opaque;
+    int r = rbd_invalidate_cache(s->image);
+    if (r < 0) {
+        error_setg_errno(errp, -r, "Failed to invalidate the cache");
+    }
+    return r;
+}
+#endif
+
 static QemuOptsList qemu_rbd_create_opts = {
     .name = "rbd-create-opts",
     .head = QTAILQ_HEAD_INITIALIZER(qemu_rbd_create_opts.head),
@@ -936,6 +949,9 @@ static BlockDriver bdrv_rbd = {
     .bdrv_snapshot_delete   = qemu_rbd_snap_remove,
     .bdrv_snapshot_list     = qemu_rbd_snap_list,
     .bdrv_snapshot_goto     = qemu_rbd_snap_rollback,
+#ifdef LIBRBD_SUPPORTS_INVALIDATE
+    .bdrv_invalidate_cache  = qemu_rbd_invalidate_cache,
+#endif
 };
 
 static void bdrv_rbd_init(void)
Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/1
#1 lore raw

[adding block maintainers to cc]

Quoted 17 lines · On 10/09/2014 11:44 AM, [email protected] wrote:

From: Adam Crume <[email protected]>

This fixes Ceph issue 2467.

---
  block/rbd.c |   16 ++++++++++++++++
  1 file changed, 16 insertions(+)
block/rbd.c +0 -0
index 96947e3..d88ba70 100644
@@ -887,6 +887,19 @@ static BlockDriverAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs,
  }
  #endif
 

block/rbd.c static BlockDriverAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs, · line 899

Quoted 10 lines
block/rbd.c +10 -0
+#ifdef LIBRBD_SUPPORTS_INVALIDATE
+static void qemu_rbd_invalidate_cache(BlockDriverState *bs,
+                                      Error **errp)
+{
+    BDRVRBDState *s = bs->opaque;
+    int r = rbd_invalidate_cache(s->image);
+    if (r < 0) {
+        error_setg_errno(errp, -r, "Failed to invalidate the cache");
+    }
+    return r;

No return needed here. With that fixed:

Quoted 17 lines
block/rbd.c +6 -0
+}
+#endif
+
  static QemuOptsList qemu_rbd_create_opts = {
      .name = "rbd-create-opts",
      .head = QTAILQ_HEAD_INITIALIZER(qemu_rbd_create_opts.head),
@@ -936,6 +949,9 @@ static BlockDriver bdrv_rbd = {
      .bdrv_snapshot_delete   = qemu_rbd_snap_remove,
      .bdrv_snapshot_list     = qemu_rbd_snap_list,
      .bdrv_snapshot_goto     = qemu_rbd_snap_rollback,
+#ifdef LIBRBD_SUPPORTS_INVALIDATE
+    .bdrv_invalidate_cache  = qemu_rbd_invalidate_cache,
+#endif
  };
 
  static void bdrv_rbd_init(void)
#3 lore raw
In reply to [email protected]
Quoted 8 lines · On Thu, Oct 09, 2014 at 11:44:32AM -0700, [email protected] wrote:

From: Adam Crume <[email protected]>

This fixes Ceph issue 2467.

---
 block/rbd.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Added URL to commit description and dropped return statement as requested by Josh.

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan