qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-block] [PATCH 2/2] file-posix: Make .bdrv_co_trun


From: Kevin Wolf
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 2/2] file-posix: Make .bdrv_co_truncate asynchronous
Date: Mon, 25 Jun 2018 11:18:57 +0200
User-agent: Mutt/1.9.1 (2017-09-22)

Am 25.06.2018 um 10:56 hat Stefan Hajnoczi geschrieben:
> On Thu, Jun 21, 2018 at 07:06:57PM +0200, Kevin Wolf wrote:
> > +    RawPosixAIOData *acb = g_new(RawPosixAIOData, 1);
> > +    ThreadPool *pool;
> >  
> > -out:
> > -    if (result < 0) {
> > -        if (ftruncate(fd, current_length) < 0) {
> > -            error_report("Failed to restore old file length: %s",
> > -                         strerror(errno));
> > -        }
> > -    }
> > +    *acb = (RawPosixAIOData) {
> > +        .bs             = bs,
> > +        .aio_fildes     = fd,
> > +        .aio_type       = QEMU_AIO_TRUNCATE,
> > +        .aio_offset     = offset,
> > +        .prealloc       = prealloc,
> > +        .errp           = errp,
> > +    };
> >  
> > -    g_free(buf);
> > -    return result;
> > +    /* @bs can be NULL, bdrv_get_aio_context() returns the main context 
> > then */
> > +    pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
> > +    return thread_pool_submit_co(pool, aio_worker, acb);
> 
> Where is acb freed?

At the end of aio_worker(). This is why I even need to malloc it here.

Once my other patch is in that removes the callback-based paio_submit(),
we could allocate the acb on the stack for all callers instead.

Kevin

Attachment: signature.asc
Description: PGP signature


reply via email to

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