[sheepdog] Call to sd_truncate()

Hadrien KOHL hadrien.kohl at gmail.com
Thu Dec 12 12:25:52 CET 2013


I just sent the question to the qemu developer mailing list. But as I did,
I remembered this sd_truncate is also called
from  sd_co_writev(BlockDriverState *bs, int64_t sector_num, int
nb_sectors, QEMUIOVector *qiov):

static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t
sector_num,
                        int nb_sectors, QEMUIOVector *qiov)
{
    SheepdogAIOCB *acb;
     int ret;

    if (bs->growable && sector_num + nb_sectors > bs->total_sectors) {
        ret = sd_truncate(bs, (sector_num + nb_sectors) * BDRV_SECTOR_SIZE);
        if (ret < 0) {
            return ret;
        }
        bs->total_sectors = sector_num + nb_sectors;
    }

    acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);
    acb->aio_done_func = sd_write_done;
    acb->aiocb_type = AIOCB_WRITE_UDATA;

    ret = sd_co_rw_vector(acb);
...
}

This function is mapped to bdrv_co_writev in the qemu driver.
Looking at the test in this function, the only way a shrink could happen -
I guess - is if the units in sector_num and nb_sectors are inconsistent
(esp since there's a conversion to "BDRV_SECTOR_SIZE") in relation to
bs->total_sectors.
I am using qcow2 file format and created the image with qemu-img -t qcow2
create sheepdog:name. Could it be related?

What do you think?

Hadrien


2013/12/12 Liu Yuan <namei.unix at gmail.com>

> On Thu, Dec 12, 2013 at 11:36:06AM +0100, Hadrien KOHL wrote:
> > Hi,
> >
> > Thanks, that's interesting. I don't have any component I can think of
> that
> > does this though.
> > Could it be possible that the kernel/filesystem of the host is doing it
> on
> > it's own?
> >
>
> IMO only 'qemu-img resize'(probably libvirt has similar function) and
> 'dog vdi resize' can resize the volume.
>
> But any higher component in QEMU might call .bdrv_truncate() too, which is
> out
> of my cscope. I'd suggest you ask the qemu list that anyone else execept
> 'qemu-img resize' would call .bdrv_truncate() while VM is running.
>
> Thanks
> Yuan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20131212/c8a6db17/attachment-0004.html>


More information about the sheepdog mailing list