diff mbox

[05/10] vvfat: use public block layer interface

Message ID 1321030042-20446-6-git-send-email-stefanha@linux.vnet.ibm.com
State New
Headers show

Commit Message

Stefan Hajnoczi Nov. 11, 2011, 4:47 p.m. UTC
For some reason vvfat.c invokes BlockDriver functions directly and does
not go through block.h functions.  Change all direct calls except for
the .bdrv_make_empty() call for which there is no public interface.

This change makes the conversion to .bdrv_co_is_allocated() possible.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 block/vvfat.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

Comments

Kevin Wolf Nov. 11, 2011, 4:59 p.m. UTC | #1
Am 11.11.2011 17:47, schrieb Stefan Hajnoczi:
> For some reason vvfat.c invokes BlockDriver functions directly and does
> not go through block.h functions.  Change all direct calls except for
> the .bdrv_make_empty() call for which there is no public interface.
> 
> This change makes the conversion to .bdrv_co_is_allocated() possible.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

This conflicts with the block branch (I made more or less the same
change in order to fix read-write vvfat disks)

Kevin
Stefan Hajnoczi Nov. 14, 2011, 11:47 a.m. UTC | #2
On Fri, Nov 11, 2011 at 05:59:19PM +0100, Kevin Wolf wrote:
> Am 11.11.2011 17:47, schrieb Stefan Hajnoczi:
> > For some reason vvfat.c invokes BlockDriver functions directly and does
> > not go through block.h functions.  Change all direct calls except for
> > the .bdrv_make_empty() call for which there is no public interface.
> > 
> > This change makes the conversion to .bdrv_co_is_allocated() possible.
> > 
> > Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> 
> This conflicts with the block branch (I made more or less the same
> change in order to fix read-write vvfat disks)

Okay, I'll rebase on your block branch.

Stefan
diff mbox

Patch

diff --git a/block/vvfat.c b/block/vvfat.c
index 8511fe5..ce8049f 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -1254,10 +1254,9 @@  static int vvfat_read(BlockDriverState *bs, int64_t sector_num,
 	   return -1;
 	if (s->qcow) {
 	    int n;
-	    if (s->qcow->drv->bdrv_is_allocated(s->qcow,
-			sector_num, nb_sectors-i, &n)) {
+	    if (bdrv_is_allocated(s->qcow, sector_num, nb_sectors-i, &n)) {
 DLOG(fprintf(stderr, "sectors %d+%d allocated\n", (int)sector_num, n));
-		if (s->qcow->drv->bdrv_read(s->qcow, sector_num, buf+i*0x200, n))
+		if (bdrv_read(s->qcow, sector_num, buf+i*0x200, n))
 		    return -1;
 		i += n - 1;
 		sector_num += n - 1;
@@ -1516,7 +1515,7 @@  static inline int cluster_was_modified(BDRVVVFATState* s, uint32_t cluster_num)
 	return 0;
 
     for (i = 0; !was_modified && i < s->sectors_per_cluster; i++)
-	was_modified = s->qcow->drv->bdrv_is_allocated(s->qcow,
+	was_modified = bdrv_is_allocated(s->qcow,
 		cluster2sector(s, cluster_num) + i, 1, &dummy);
 
     return was_modified;
@@ -1666,13 +1665,11 @@  static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s,
 
 		vvfat_close_current_file(s);
 		for (i = 0; i < s->sectors_per_cluster; i++)
-		    if (!s->qcow->drv->bdrv_is_allocated(s->qcow,
-				offset + i, 1, &dummy)) {
+		    if (!bdrv_is_allocated(s->qcow, offset + i, 1, &dummy)) {
 			if (vvfat_read(s->bs,
 				    offset, s->cluster_buffer, 1))
 			    return -1;
-			if (s->qcow->drv->bdrv_write(s->qcow,
-				    offset, s->cluster_buffer, 1))
+			if (bdrv_write(s->qcow, offset, s->cluster_buffer, 1))
 			    return -2;
 		    }
 	    }
@@ -2714,7 +2711,7 @@  DLOG(checkpoint());
      * Use qcow backend. Commit later.
      */
 DLOG(fprintf(stderr, "Write to qcow backend: %d + %d\n", (int)sector_num, nb_sectors));
-    ret = s->qcow->drv->bdrv_write(s->qcow, sector_num, buf, nb_sectors);
+    ret = bdrv_write(s->qcow, sector_num, buf, nb_sectors);
     if (ret < 0) {
 	fprintf(stderr, "Error writing to qcow backend\n");
 	return ret;