From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, pl@kamp.de, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 23/24] block: Make bdrv_pwrite() a bdrv_prwv_co() wrapper
Date: Sat, 11 Jan 2014 23:22:55 +0100 [thread overview]
Message-ID: <52D1C43F.1010801@redhat.com> (raw)
In-Reply-To: <1386940979-3824-24-git-send-email-kwolf@redhat.com>
On 13.12.2013 14:22, Kevin Wolf wrote:
> Instead of implementing the alignment adjustment here, use the now
> existing functionality of bdrv_co_do_pwritev().
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block.c | 64 +++++++++-------------------------------------------------------
> 1 file changed, 9 insertions(+), 55 deletions(-)
>
> diff --git a/block.c b/block.c
> index ab165c5..350cb81 100644
> --- a/block.c
> +++ b/block.c
> @@ -2496,11 +2496,6 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num,
> return bdrv_rw_co(bs, sector_num, (uint8_t *)buf, nb_sectors, true, 0);
> }
>
> -int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov)
> -{
> - return bdrv_prwv_co(bs, sector_num << BDRV_SECTOR_BITS, qiov, true, 0);
> -}
This function seems unused, so removing it should be okay. But I think
it should be removed from block.h as well.
Max
> -
> int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
> int nb_sectors, BdrvRequestFlags flags)
> {
> @@ -2569,70 +2564,29 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset, void *buf, int bytes)
>
> int bdrv_pwritev(BlockDriverState *bs, int64_t offset, QEMUIOVector *qiov)
> {
> - uint8_t tmp_buf[BDRV_SECTOR_SIZE];
> - int len, nb_sectors, count;
> - int64_t sector_num;
> int ret;
>
> - count = qiov->size;
> -
> - /* first write to align to sector start */
> - len = (BDRV_SECTOR_SIZE - offset) & (BDRV_SECTOR_SIZE - 1);
> - if (len > count)
> - len = count;
> - sector_num = offset >> BDRV_SECTOR_BITS;
> - if (len > 0) {
> - if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0)
> - return ret;
> - qemu_iovec_to_buf(qiov, 0, tmp_buf + (offset & (BDRV_SECTOR_SIZE - 1)),
> - len);
> - if ((ret = bdrv_write(bs, sector_num, tmp_buf, 1)) < 0)
> - return ret;
> - count -= len;
> - if (count == 0)
> - return qiov->size;
> - sector_num++;
> - }
> -
> - /* write the sectors "in place" */
> - nb_sectors = count >> BDRV_SECTOR_BITS;
> - if (nb_sectors > 0) {
> - QEMUIOVector qiov_inplace;
> -
> - qemu_iovec_init(&qiov_inplace, qiov->niov);
> - qemu_iovec_concat(&qiov_inplace, qiov, len,
> - nb_sectors << BDRV_SECTOR_BITS);
> - ret = bdrv_writev(bs, sector_num, &qiov_inplace);
> - qemu_iovec_destroy(&qiov_inplace);
> - if (ret < 0) {
> - return ret;
> - }
> -
> - sector_num += nb_sectors;
> - len = nb_sectors << BDRV_SECTOR_BITS;
> - count -= len;
> + ret = bdrv_prwv_co(bs, offset, qiov, true, 0);
> + if (ret < 0) {
> + return ret;
> }
>
> - /* add data from the last sector */
> - if (count > 0) {
> - if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0)
> - return ret;
> - qemu_iovec_to_buf(qiov, qiov->size - count, tmp_buf, count);
> - if ((ret = bdrv_write(bs, sector_num, tmp_buf, 1)) < 0)
> - return ret;
> - }
> return qiov->size;
> }
>
> int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
> - const void *buf, int count1)
> + const void *buf, int bytes)
> {
> QEMUIOVector qiov;
> struct iovec iov = {
> .iov_base = (void *) buf,
> - .iov_len = count1,
> + .iov_len = bytes,
> };
>
> + if (bytes < 0) {
> + return -EINVAL;
> + }
> +
> qemu_iovec_init_external(&qiov, &iov, 1);
> return bdrv_pwritev(bs, offset, &qiov);
> }
next prev parent reply other threads:[~2014-01-11 22:21 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-13 13:22 [Qemu-devel] [PATCH v2 00/24] block: Support for 512b-on-4k emulatio Kevin Wolf
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 01/24] block: Move initialisation of BlockLimits to bdrv_refresh_limits() Kevin Wolf
2014-01-11 22:24 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 02/24] block: Inherit opt_transfer_length Kevin Wolf
2014-01-11 22:24 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 03/24] block: Update BlockLimits when they might have changed Kevin Wolf
2014-01-11 22:24 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 04/24] qemu_memalign: Allow small alignments Kevin Wolf
2014-01-11 22:25 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 05/24] block: Detect unaligned length in bdrv_qiov_is_aligned() Kevin Wolf
2014-01-11 22:25 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 06/24] block: Don't use guest sector size for qemu_blockalign() Kevin Wolf
2014-01-11 22:25 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 07/24] block: rename buffer_alignment to guest_block_size Kevin Wolf
2014-01-11 22:26 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 08/24] raw: Probe required direct I/O alignment Kevin Wolf
2013-12-24 3:39 ` Wenchao Xia
2014-01-11 22:26 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 09/24] block: Introduce bdrv_aligned_preadv() Kevin Wolf
2013-12-24 7:23 ` Wenchao Xia
2014-01-11 22:27 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 10/24] block: Introduce bdrv_co_do_preadv() Kevin Wolf
2013-12-26 4:08 ` Wenchao Xia
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 11/24] block: Introduce bdrv_aligned_pwritev() Kevin Wolf
2014-01-11 22:27 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 12/24] block: write: Handle COR dependency after I/O throttling Kevin Wolf
2014-01-11 22:27 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 13/24] block: Introduce bdrv_co_do_pwritev() Kevin Wolf
2014-01-10 18:11 ` Max Reitz
2014-01-16 12:25 ` Kevin Wolf
2014-01-17 1:38 ` Fam Zheng
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 14/24] block: Switch BdrvTrackedRequest to byte granularity Kevin Wolf
2014-01-10 18:34 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 15/24] block: Allow waiting for overlapping requests between begin/end Kevin Wolf
2014-01-11 22:28 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 16/24] block: Make zero-after-EOF work with larger alignment Kevin Wolf
2014-01-10 19:07 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 17/24] block: Generalise and optimise COR serialisation Kevin Wolf
2014-01-11 22:28 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 18/24] block: Make overlap range for serialisation dynamic Kevin Wolf
2014-01-11 22:28 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 19/24] block: Allow wait_serialising_requests() at any point Kevin Wolf
2013-12-27 4:17 ` Wenchao Xia
2014-01-13 11:29 ` Kevin Wolf
2014-01-14 3:13 ` Wenchao Xia
2014-01-11 22:29 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 20/24] block: Align requests in bdrv_co_do_pwritev() Kevin Wolf
2014-01-11 22:29 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 21/24] block: Change coroutine wrapper to byte granularity Kevin Wolf
2014-01-11 22:29 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 22/24] block: Make bdrv_pread() a bdrv_prwv_co() wrapper Kevin Wolf
2014-01-11 22:29 ` Max Reitz
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 23/24] block: Make bdrv_pwrite() " Kevin Wolf
2014-01-11 22:22 ` Max Reitz [this message]
2013-12-13 13:22 ` [Qemu-devel] [PATCH v2 24/24] iscsi: Set bs->request_alignment Kevin Wolf
2014-01-11 22:30 ` Max Reitz
2013-12-27 4:27 ` [Qemu-devel] [PATCH v2 00/24] block: Support for 512b-on-4k emulatio Wenchao Xia
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=52D1C43F.1010801@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).