From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, kwolf@redhat.com, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 2/3] vvfat: Switch to byte-based calls
Date: Thu, 26 Apr 2018 08:43:04 -0500 [thread overview]
Message-ID: <20180426134305.642080-3-eblake@redhat.com> (raw)
In-Reply-To: <20180426134305.642080-1-eblake@redhat.com>
We are gradually moving away from sector-based interfaces, towards
byte-based. Make the change for the last few sector-based calls
into the block layer from the vvfat driver.
Ideally, the vvfat driver should switch to doing everything
byte-based, but that's a more invasive change that requires a
bit more auditing.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
block/vvfat.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/block/vvfat.c b/block/vvfat.c
index 1569783b0f9..ba27f86a951 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -1503,8 +1503,8 @@ static int vvfat_read(BlockDriverState *bs, int64_t sector_num,
DLOG(fprintf(stderr, "sectors %" PRId64 "+%" PRId64
" allocated\n", sector_num,
n >> BDRV_SECTOR_BITS));
- if (bdrv_read(s->qcow, sector_num, buf + i * 0x200,
- n >> BDRV_SECTOR_BITS)) {
+ if (bdrv_pread(s->qcow, sector_num * BDRV_SECTOR_BITS,
+ buf + i * 0x200, n) < 0) {
return -1;
}
i += (n >> BDRV_SECTOR_BITS) - 1;
@@ -1992,7 +1992,8 @@ static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s,
if (res) {
return -1;
}
- res = bdrv_write(s->qcow, offset, s->cluster_buffer, 1);
+ res = bdrv_pwrite(s->qcow, offset * BDRV_SECTOR_SIZE,
+ s->cluster_buffer, BDRV_SECTOR_SIZE);
if (res) {
return -2;
}
@@ -2155,7 +2156,7 @@ DLOG(checkpoint());
* - get modified FAT
* - compare the two FATs (TODO)
* - get buffer for marking used clusters
- * - recurse direntries from root (using bs->bdrv_read to make
+ * - recurse direntries from root (using bs->bdrv_pread to make
* sure to get the new data)
* - check that the FAT agrees with the size
* - count the number of clusters occupied by this directory and
@@ -2902,9 +2903,9 @@ static int handle_deletes(BDRVVVFATState* s)
/*
* synchronize mapping with new state:
*
- * - copy FAT (with bdrv_read)
+ * - copy FAT (with bdrv_pread)
* - mark all filenames corresponding to mappings as deleted
- * - recurse direntries from root (using bs->bdrv_read)
+ * - recurse direntries from root (using bs->bdrv_pread)
* - delete files corresponding to mappings marked as deleted
*/
static int do_commit(BDRVVVFATState* s)
@@ -2924,10 +2925,10 @@ static int do_commit(BDRVVVFATState* s)
return ret;
}
- /* copy FAT (with bdrv_read) */
+ /* copy FAT (with bdrv_pread) */
memcpy(s->fat.pointer, s->fat2, 0x200 * s->sectors_per_fat);
- /* recurse direntries from root (using bs->bdrv_read) */
+ /* recurse direntries from root (using bs->bdrv_pread) */
ret = commit_direntries(s, 0, -1);
if (ret) {
fprintf(stderr, "Fatal: error while committing (%d)\n", ret);
@@ -3041,7 +3042,8 @@ DLOG(checkpoint());
* Use qcow backend. Commit later.
*/
DLOG(fprintf(stderr, "Write to qcow backend: %d + %d\n", (int)sector_num, nb_sectors));
- ret = bdrv_write(s->qcow, sector_num, buf, nb_sectors);
+ ret = bdrv_pwrite(s->qcow, sector_num * BDRV_SECTOR_SIZE, buf,
+ nb_sectors * BDRV_SECTOR_SIZE);
if (ret < 0) {
fprintf(stderr, "Error writing to qcow backend\n");
return ret;
--
2.14.3
next prev parent reply other threads:[~2018-04-26 13:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-26 13:43 [Qemu-devel] [PATCH 0/3] block: byte-based blocking read/write Eric Blake
2018-04-26 13:43 ` [Qemu-devel] [PATCH 1/3] vdi: Switch to byte-based calls Eric Blake
2018-04-27 13:52 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-04-26 13:43 ` Eric Blake [this message]
2018-04-27 13:59 ` [Qemu-devel] [Qemu-block] [PATCH 2/3] vvfat: " Alberto Garcia
2018-04-26 13:43 ` [Qemu-devel] [PATCH 3/3] block: Removed unused sector-based blocking I/O Eric Blake
2018-04-27 14:01 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-04-27 15:43 ` Eric Blake
2018-05-03 13:36 ` Alberto Garcia
2018-11-14 17:30 ` Eric Blake
2018-05-08 12:45 ` Stefan Hajnoczi
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=20180426134305.642080-3-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).