qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH block v1 2/2] block: m25p80: Support read only bdrvs.
Date: Sat, 21 Jun 2014 17:06:29 +0800	[thread overview]
Message-ID: <20140621090629.GA11045@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <53A2A89A.3090505@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1409 bytes --]

On Thu, Jun 19, 2014 at 11:08:42AM +0200, Paolo Bonzini wrote:
> >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.

Since this issue was present before the patch and not caused by this
series I'm keeping it in the block queue.

It would be nice to address this in a separate series.

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2014-06-21  9:06 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
2014-06-21  9:06     ` Stefan Hajnoczi [this message]
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=20140621090629.GA11045@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=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).