Re: [PATCH V12 05/15] block/export: track IOThread references

Zhang Chen <[email protected]>
Newsgroups org.nongnu.qemu-devel
Message-ID <CAK3tnvK=yWL+uV=u2FCM6sg-QKOasQBeGAohq8Ahr9jysr0CyQ@mail.gmail.com>
On Thu, Aug 20, 2026 at 2:32 AM Stefan Hajnoczi <[email protected]> wrote:
>
> On Sat, Aug 15, 2026 at 01:48:19AM +0800, Zhang Chen wrote:
> > @@ -139,7 +140,16 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
> >              goto fail;
> >          }
> >
> > -        new_ctx = iothread_get_aio_context(iothread);
> > +        holder_id = export->id;
> > +        const IOThreadHolder holder = {
> > +            .type = IO_THREAD_HOLDER_KIND_BLOCK_EXPORT,
> > +            .u.block_export.export_id = holder_id,
> > +        };
> > +
> > +        new_ctx = iothread_ref_and_get_aio_context(iothread, &holder);
> > +        multithread_count = 1;
>
> This changes behavior in:
>
>   ret = drv->create(exp, export, multithread_ctxs, multithread_count, errp);
>
> Now export drivers will see drv->create(exp, export, NULL, 1, errp);
>                                                      ^^^^  ^
>
> Before it was drv->create(exp, export, NULL, 0, errp).
>
> fuse_export_create() has an assertion that fails now:
>
>   if (multithread) {
>       ...
>   } else {
>       /* Guaranteed by common export code */
>       assert(mt_count == 0);
>       ...
>   }

Good catch, it looks like the multithread_count only designed for the
multi threads cases.
Will introduce a new iothread_count here.

Yes, iothread_holder_id is redundant because exp->id remains valid
until after the IOThread
references are released. I’ll remove it and use export->id before
BlockExport allocation and
exp->id afterwards.

Thanks
Chen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.