qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>, qemu-devel@nongnu.org
Cc: stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH block v1 2/2] block: m25p80: Support read only bdrvs.
Date: Thu, 19 Jun 2014 11:08:42 +0200	[thread overview]
Message-ID: <53A2A89A.3090505@redhat.com> (raw)
In-Reply-To: <78e1e234bb9d30f863bab5be6498bf827f906318.1403141617.git.peter.crosthwaite@xilinx.com>

> static void bdrv_sync_complete(void *opaque, int ret)
> {
>     /* do nothing. Masters do not directly interact with the backing store,
>      * only the working copy so no mutexing required.
>      */
> }
>
> static void flash_sync_page(Flash *s, int page)
> {
>     if (s->bdrv) {
>         int bdrv_sector, nb_sectors;
>         QEMUIOVector iov;
>
>         bdrv_sector = (page * s->pi->page_size) / BDRV_SECTOR_SIZE;
>         nb_sectors = DIV_ROUND_UP(s->pi->page_size, BDRV_SECTOR_SIZE);
>         qemu_iovec_init(&iov, 1);
>         qemu_iovec_add(&iov, s->storage + bdrv_sector * BDRV_SECTOR_SIZE,
>                                                 nb_sectors * BDRV_SECTOR_SIZE);
>         bdrv_aio_writev(s->bdrv, bdrv_sector, &iov, nb_sectors,
>                                                 bdrv_sync_complete, NULL);
>     }
> }

Using AIO is a good idea, but you could have overlapping writes here if 
you get close calls to flash_sync_page.  It can be bad.

Serializing can be done in fancy manners, but it can be as easy as 
adding bdrv_drain(s->bdrv) before the bdrv_aio_writev.

Paolo

  reply	other threads:[~2014-06-19  9:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19  1:36 [Qemu-devel] [PATCH block v1 1/2] block: m25p80: sync_page(): Deindent function body Peter Crosthwaite
2014-06-19  1:36 ` [Qemu-devel] [PATCH block v1 2/2] block: m25p80: Support read only bdrvs Peter Crosthwaite
2014-06-19  9:08   ` Paolo Bonzini [this message]
2014-06-21  9:06     ` Stefan Hajnoczi
2014-06-19  3:21 ` [Qemu-devel] [PATCH block v1 1/2] block: m25p80: sync_page(): Deindent function body 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=53A2A89A.3090505@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --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).