Patchwork [04/17] block: non-raw protocols never cache

login
register
mail settings
Submitter Paolo Bonzini
Date Dec. 13, 2011, 12:37 p.m.
Message ID <1323779840-4235-5-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/131070/
State New
Headers show

Comments

Paolo Bonzini - Dec. 13, 2011, 12:37 p.m.
Non-raw protocols never cache their data.  Make this visible by setting
BDRV_O_NOCACHE in the open_flags.  It will be used to handle block sizes
smaller than the backend's block size.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/curl.c     |    1 +
 block/iscsi.c    |    1 +
 block/nbd.c      |    1 +
 block/rbd.c      |    1 +
 block/sheepdog.c |    1 +
 block/vdi.c      |    1 +
 6 files changed, 6 insertions(+), 0 deletions(-)

Patch

diff --git a/block/curl.c b/block/curl.c
index e9102e3..e7243dd 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -409,6 +409,7 @@  static int curl_open(BlockDriverState *bs, const char *filename, int flags)
     curl_multi_setopt( s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb ); 
     curl_multi_do(s);
 
+    bs->open_flags |= BDRV_O_NOCACHE;
     return 0;
 
 out:
diff --git a/block/iscsi.c b/block/iscsi.c
index 938c568..4e6cf7a 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -474,6 +474,7 @@  static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)
         return -EINVAL;
     }
 
+    bs->open_flags |= BDRV_O_NOCACHE;
     memset(iscsilun, 0, sizeof(IscsiLun));
 
     /* Should really append the KVM name after the ':' here */
diff --git a/block/nbd.c b/block/nbd.c
index 882b2dc..d944ee7 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -176,6 +176,7 @@  static int nbd_open(BlockDriverState *bs, const char* filename, int flags)
      */
     result = nbd_establish_connection(bs);
 
+    bs->open_flags |= BDRV_O_NOCACHE;
     qemu_co_mutex_init(&s->lock);
     return result;
 }
diff --git a/block/rbd.c b/block/rbd.c
index 312584a..d20955f 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -492,6 +492,7 @@  static int qemu_rbd_open(BlockDriverState *bs, const char *filename, int flags)
     }
 
     bs->read_only = (s->snap != NULL);
+    bs->open_flags |= BDRV_O_NOCACHE;
 
     s->event_reader_pos = 0;
     r = qemu_pipe(s->fds);
diff --git a/block/sheepdog.c b/block/sheepdog.c
index aa9707f..3ea2872 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1248,6 +1248,7 @@  static int sd_open(BlockDriverState *bs, const char *filename, int flags)
     s->min_dirty_data_idx = UINT32_MAX;
     s->max_dirty_data_idx = 0;
 
+    bs->open_flags |= BDRV_O_NOCACHE;
     bs->total_sectors = s->inode.vdi_size / SECTOR_SIZE;
     strncpy(s->name, vdi, sizeof(s->name));
     qemu_co_mutex_init(&s->lock);
diff --git a/block/vdi.c b/block/vdi.c
index 31cdfab..dfae347 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -441,6 +441,7 @@  static int vdi_open(BlockDriverState *bs, int flags)
         goto fail;
     }
 
+    bs->open_flags |= BDRV_O_NOCACHE;
     bs->total_sectors = header.disk_size / SECTOR_SIZE;
 
     s->block_size = header.block_size;