Skip to contentSkip to conversation

[6824] Drop internal bdrv_pread()/bdrv_pwrite() APIs (Avi Kivity)

Qemu-devel Anthony Liguori 1 participant 1 message Mar 12, 2009

lore
Share & tools
lore
#0 lore raw

Revision: 6824

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6824
Author:   aliguori
Date:     2009-03-12 19:57:16 +0000 (Thu, 12 Mar 2009)

Log Message:
-----------
Drop internal bdrv_pread()/bdrv_pwrite() APIs (Avi Kivity)

Now that scsi generic no longer uses bdrv_pread() and bdrv_pwrite(), we can drop the corresponding internal APIs, which overlap bdrv_read()/bdrv_write() and, being byte oriented, are unnatural for a block device.

Modified Paths:
--------------

    trunk/block-raw-posix.c
    trunk/block-raw-win32.c
    trunk/block.c
    trunk/block_int.h

Modified: trunk/block-raw-posix.c
===================================================================

block-raw-posix.c +16 -4
@@ -358,6 +358,12 @@
     return raw_pread_aligned(bs, offset, buf, count) + sum;
 }
 
+static int raw_read(BlockDriverState *bs, int64_t sector_num,
+                    uint8_t *buf, int nb_sectors)
+{
+    return raw_pread(bs, sector_num * 512, buf, (uint64_t)nb_sectors * 512);
+}
+
 /*
  * offset and count are in bytes and possibly not aligned. For files opened
  * with O_DIRECT, necessary alignments are ensured before calling
@@ -436,6 +442,12 @@
     return raw_pwrite_aligned(bs, offset, buf, count) + sum;
 }
 
+static int raw_write(BlockDriverState *bs, int64_t sector_num,
+                     const uint8_t *buf, int nb_sectors)
+{
+    return raw_pwrite(bs, sector_num * 512, buf, (uint64_t)nb_sectors * 512);
+}
+
 #ifdef CONFIG_AIO
 /***********************************************************/
 /* Unix AIO using POSIX AIO */
@@ -843,8 +855,8 @@
     .aiocb_size = sizeof(RawAIOCB),
 #endif
 
-    .bdrv_pread = raw_pread,
-    .bdrv_pwrite = raw_pwrite,
+    .bdrv_read = raw_read,
+    .bdrv_write = raw_write,
     .bdrv_truncate = raw_truncate,
     .bdrv_getlength = raw_getlength,
 };
@@ -1219,8 +1231,8 @@
     .aiocb_size		= sizeof(RawAIOCB),
 #endif
 
-    .bdrv_pread		= raw_pread,
-    .bdrv_pwrite	= raw_pwrite,
+    .bdrv_read          = raw_read,
+    .bdrv_write         = raw_write,
     .bdrv_getlength	= raw_getlength,
 
     /* removable device support */

Modified: trunk/block-raw-win32.c
===================================================================

block-raw-win32.c +12 -8
@@ -122,13 +122,15 @@
     return 0;
 }
 
-static int raw_pread(BlockDriverState *bs, int64_t offset,
-                     uint8_t *buf, int count)
+static int raw_read(BlockDriverState *bs, int64_t sector_num,
+                    uint8_t *buf, int nb_sectors)
 {
     BDRVRawState *s = bs->opaque;
     OVERLAPPED ov;
     DWORD ret_count;
     int ret;
+    int64_t offset = sector_num * 512;
+    int count = nb_sectors * 512;
 
     memset(&ov, 0, sizeof(ov));
     ov.Offset = offset;
@@ -146,13 +148,15 @@
     return ret_count;
 }
 
-static int raw_pwrite(BlockDriverState *bs, int64_t offset,
-                      const uint8_t *buf, int count)
+static int raw_write(BlockDriverState *bs, int64_t sector_num,
+                     const uint8_t *buf, int nb_sectors)
 {
     BDRVRawState *s = bs->opaque;
     OVERLAPPED ov;
     DWORD ret_count;
     int ret;
+    int64_t offset = sector_num * 512;
+    int count = nb_sectors * 512;
 
     memset(&ov, 0, sizeof(ov));
     ov.Offset = offset;
@@ -359,8 +363,8 @@
     .bdrv_aio_cancel = raw_aio_cancel,
     .aiocb_size = sizeof(RawAIOCB);
 #endif
-    .bdrv_pread = raw_pread,
-    .bdrv_pwrite = raw_pwrite,
+    .bdrv_read = raw_read,
+    .bdrv_write = raw_write,
     .bdrv_truncate = raw_truncate,
     .bdrv_getlength = raw_getlength,
 };
@@ -508,7 +512,7 @@
     .bdrv_aio_cancel	= raw_aio_cancel,
     .aiocb_size		= sizeof(RawAIOCB);
 #endif
-    .bdrv_pread		= raw_pread,
-    .bdrv_pwrite	= raw_pwrite,
+    .bdrv_read		= raw_read,
+    .bdrv_write	        = raw_write,
     .bdrv_getlength	= raw_getlength,
 };

Modified: trunk/block.c
===================================================================

block.c +6 -73

112 lines not on this page · raw message

Modified: trunk/block_int.h
===================================================================

block_int.h +0 -4
@@ -58,10 +58,6 @@
     int aiocb_size;
 
     const char *protocol_name;
-    int (*bdrv_pread)(BlockDriverState *bs, int64_t offset,
-                      uint8_t *buf, int count);
-    int (*bdrv_pwrite)(BlockDriverState *bs, int64_t offset,
-                       const uint8_t *buf, int count);
     int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset);
     int64_t (*bdrv_getlength)(BlockDriverState *bs);
     int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num,