From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Fam Zheng <famz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH for-2.11] block: Keep strong reference when draining all BDS
Date: Fri, 10 Nov 2017 17:43:19 +0100 [thread overview]
Message-ID: <39d87980-4fb0-faa4-4e9f-ba6d2e2f5acd@redhat.com> (raw)
In-Reply-To: <20171110162224.GG5466@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2157 bytes --]
On 2017-11-10 17:22, Kevin Wolf wrote:
> Am 10.11.2017 um 17:13 hat Max Reitz geschrieben:
>> On 2017-11-10 17:05, Kevin Wolf wrote:
>>> Am 10.11.2017 um 16:23 hat Max Reitz geschrieben:
>>>> On 2017-11-10 14:32, Fam Zheng wrote:
>>>>> On Fri, 11/10 14:17, Kevin Wolf wrote:
>>>>>> Do you actually need to keep references to all BDSes in the whole list
>>>>>> while using the iterator or would it be enough to just keep a reference
>>>>>> to the current one?
>>>>>
>>>>> To fix the bug we now see I think keeping the current is enough, but I think
>>>>> implementing just like this patch is also good with some future-proofing: we
>>>>> cannot know what will be wedged into the nexted aio_poll()'s over time (and yes,
>>>>> we should really reduce the number of them.)
>>>>
>>>> I don't really want to think about whether it's safe to only keep a
>>>> reference to the current BDS. I can't imagine any case where destroying
>>>> one root BDS leads to destroying another, but I'd rather be safe and not
>>>> have to think about it. (Unless there is an important reason to only
>>>> keep a strong reference to the current one.)
>>>
>>> Why would it be a problem if another BDS from the list went away? If it
>>> is one that was already processed, we don't care, and if it was in the
>>> yet unprocessed part of the list, we'll just never return it.
>>
>> You mean from bdrv_next() in its current form? Well, I know that when I
>> just put a bdrv_ref()/bdrv_unref() pair around the drain, I got a
>> segfault in blk_all_next() in bdrv_next(). I can investigate more, but
>> that's pretty much what I mean by "I don't really want to think about it".
>
> No, I mean a bdrv_next() that is modified to bdrv_ref() only what
> it->blk/it->bs point to currently instead of allocating a whole list.
Seems to work, I guess my issue was that I unref'd the BDS too early
(should do that only after the next pointer has been fetched...).
This also means adding a new function like bdrv_next_cleanup() that has
to be called if you don't want to iterate over all of the BDSs, but I
guess it's still less code to write.
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
next prev parent reply other threads:[~2017-11-10 16:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-09 20:43 [Qemu-devel] [PATCH for-2.11] block: Keep strong reference when draining all BDS Max Reitz
2017-11-09 21:02 ` Eric Blake
2017-11-10 2:45 ` Fam Zheng
2017-11-10 13:17 ` Kevin Wolf
2017-11-10 13:32 ` Fam Zheng
2017-11-10 15:23 ` Max Reitz
2017-11-10 15:31 ` Fam Zheng
2017-11-10 16:05 ` Kevin Wolf
2017-11-10 16:13 ` Max Reitz
2017-11-10 16:22 ` Kevin Wolf
2017-11-10 16:43 ` Max Reitz [this message]
2017-11-10 9:19 ` Stefan Hajnoczi
2017-11-10 15:26 ` Max Reitz
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=39d87980-4fb0-faa4-4e9f-ba6d2e2f5acd@redhat.com \
--to=mreitz@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--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).