qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH block v1 2/2] block: m25p80: Support read only b


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH block v1 2/2] block: m25p80: Support read only bdrvs.
Date: Thu, 19 Jun 2014 11:08:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

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 via email to

[Prev in Thread] Current Thread [Next in Thread]