From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D36FC433F5 for ; Fri, 19 Nov 2021 03:14:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BABD161A55 for ; Fri, 19 Nov 2021 03:14:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BABD161A55 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:43238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnuMR-0005nC-Me for qemu-devel@archiver.kernel.org; Thu, 18 Nov 2021 22:14:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnuL8-0004qL-1U for qemu-devel@nongnu.org; Thu, 18 Nov 2021 22:13:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50726) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnuL4-00036J-R6 for qemu-devel@nongnu.org; Thu, 18 Nov 2021 22:13:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637291601; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=z7KWoPp1r7ItMD61SrHlsc351O58KyCY2KWC1XGxhg0=; b=geRwwDSxE8Wfi/AS9jgQny1hPUmLw1gKNRe1Ms2Z/vgaKlDI63rW+WmlQuqKf4BjgvG148 xsbKufftPNI8jbwod/aKtXsuMlhXLFenabgid8VqKIQfdhAWoKrRLJGpEgzysbANhrHuPA GcB00lurYpLJrWDM5whzstchDidsYcg= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-581-y_GvwhWoMr6gkGxR2TDcEw-1; Thu, 18 Nov 2021 22:13:18 -0500 X-MC-Unique: y_GvwhWoMr6gkGxR2TDcEw-1 Received: by mail-pf1-f198.google.com with SMTP id c131-20020a621c89000000b004a343484969so1777959pfc.3 for ; Thu, 18 Nov 2021 19:13:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z7KWoPp1r7ItMD61SrHlsc351O58KyCY2KWC1XGxhg0=; b=tOSNHvFWpOcKVgjgIf/lOiFYxDe9muWVT/x0XOOIBZ4O2nD156lkEJcI/SzwjsBtNL hzlc+WHjDgUUGNNByn7X9zK4Q9utUaJ5oMa1b3a8PnhlhYJNL0AhjwunbA8Ju4eOZtPS H+9YqsgaEvCyRKY6JBFC3wQ0EezA9jAWoDgXpIgHstrqLinN6W9TvL/ACe2YPKrXUs8u JDJuO4UNI+Tbs7lrnMHMLMkiW5/eJKo44v4mVSQBk/SQ1aQxPZ+kqX99w7ATQYEzMpdR O1PxKFVFpeVJ8hS47JX2id31AdHomZhwGzPvp7xbn83K8/xjP/MHLhCWeSNJ28QNtHjr KVlA== X-Gm-Message-State: AOAM530zqDOzH6+hTz8JtB8r1w72m7U/Op8Gc+cT+lZKtgbHnKKQZlpH 2CNGErFsFWrDnJ/bEzsPUwVMr3ZnLMa1jryyQzBU793Ow4MHswWN4FPkP7uYPhip/X9DIL7ODag gMZ/km+rIa946T/+2Uvh3Kh9XoBgQLBo= X-Received: by 2002:a17:902:8544:b0:142:66e7:afbb with SMTP id d4-20020a170902854400b0014266e7afbbmr73361205plo.62.1637291597066; Thu, 18 Nov 2021 19:13:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXndTp28PTxl3JCV5B8IRw4T2X65Uv3lUaIZ8uAo6d35TiwMJqAnxDlqaWLgzokoyb5t3HqoNs6uR/lVsLybs= X-Received: by 2002:a17:902:8544:b0:142:66e7:afbb with SMTP id d4-20020a170902854400b0014266e7afbbmr73361167plo.62.1637291596777; Thu, 18 Nov 2021 19:13:16 -0800 (PST) MIME-Version: 1.0 References: <20211025101735.2060852-1-eesposit@redhat.com> <93821bd8-2ac0-a19e-7029-900e6a6d9be1@redhat.com> <3e55da77-66e1-d9ac-e23a-3fa0beceec8e@redhat.com> In-Reply-To: <3e55da77-66e1-d9ac-e23a-3fa0beceec8e@redhat.com> From: Paolo Bonzini Date: Fri, 19 Nov 2021 04:13:03 +0100 Message-ID: Subject: Re: [PATCH v4 00/25] block layer: split block APIs in global state and I/O To: Hanna Reitz Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="00000000000005299f05d11ba8d3" Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emanuele Giuseppe Esposito , Kevin Wolf , Vladimir Sementsov-Ogievskiy , =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , "open list:Block layer core" , Juan Quintela , Eric Blake , Richard Henderson , qemu-devel , Markus Armbruster , Stefan Hajnoczi , Fam Zheng , John Snow , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000005299f05d11ba8d3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable El jue., 18 nov. 2021 16:31, Hanna Reitz escribi=C3=B3: > On 18.11.21 14:50, Paolo Bonzini wrote: > > On 11/15/21 17:03, Hanna Reitz wrote: > >> > >> I only really see four solutions for this: > >> (1) We somehow make the amend job run in the main context under the > >> BQL and have it prevent all concurrent I/O access (seems bad) > >> (2) We can make the permission functions part of the I/O path (seems > >> wrong and probably impossible?) > >> (3) We can drop the permissions update and permanently require the > >> permissions that we need when updating keys (I think this might break > >> existing use cases) > >> (4) We can acquire the BQL around the permission update call and > >> perhaps that works? > >> > >> I don=E2=80=99t know how (4) would work but it=E2=80=99s basically the= only > >> reasonable solution I can come up with. Would this be a way to call > >> a BQL function from an I/O function? > > > > I think that would deadlock: > > > > main I/O thread > > -------- ----- > > start bdrv_co_amend > > take BQL > > bdrv_drain > > ... hangs ... > > :/ > > Is there really nothing we can do? Forgive me if I=E2=80=99m talking com= plete > nonsense here (because frankly I don=E2=80=99t even really know what a bo= ttom > half is exactly), but can=E2=80=99t we schedule some coroutine in the mai= n > thread to do the perm notifications and wait for them in the I/O thread? > I think you still get a deadlock, just one with a longer chain. You still have a cycle of things depending on each other, but one of them is now the I/O thread waiting for the bottom half. Hmm... Perhaps. We would need to undo the permission change when the > job finishes, though, i.e. in JobDriver.prepare() or JobDriver.clean(). > Doing the change in qmp_x_blockdev_amend() would be asymmetric then, so > we=E2=80=99d probably want a new JobDriver method that runs in the main t= hread > before .run() is invoked. (Unfortunately, =E2=80=9C.prepare()=E2=80=9D is= now taken > already...) > Ok at least it's feasible. Doesn=E2=80=99t solve the FUSE problem, but there we could try to just take= the > RESIZE permission permanently and if that fails, we just don=E2=80=99t al= low > truncates for that export. Not nice, but should work for common cases. > Yeah definitely not nice. Probably permissions could be protected by their own mutex, even a global one like the one we have for jobs. For now I suggest just ignoring the problem and adding a comment, since it's not really something that didn't exist. Paolo --00000000000005299f05d11ba8d3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


El jue., 18 nov. 2021 16:31, Hanna Reitz <hreitz@redhat.com> escribi=C3=B3:
<= /div>
On 18.11.21 14:50, Paolo Bonzini wrote:=
> On 11/15/21 17:03, Hanna Reitz wrote:
>>
>> I only really see four solutions for this:
>> (1) We somehow make the amend job run in the main context under th= e
>> BQL and have it prevent all concurrent I/O access (seems bad)
>> (2) We can make the permission functions part of the I/O path (see= ms
>> wrong and probably impossible?)
>> (3) We can drop the permissions update and permanently require the=
>> permissions that we need when updating keys (I think this might br= eak
>> existing use cases)
>> (4) We can acquire the BQL around the permission update call and <= br> >> perhaps that works?
>>
>> I don=E2=80=99t know how (4) would work but it=E2=80=99s basically= the only
>> reasonable solution I can come up with.=C2=A0 Would this be a way = to call
>> a BQL function from an I/O function?
>
> I think that would deadlock:
>
> =C2=A0=C2=A0=C2=A0=C2=A0main=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 I/O thread
> =C2=A0=C2=A0=C2=A0=C2=A0--------=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -----
> =C2=A0=C2=A0=C2=A0=C2=A0start bdrv_co_amend
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 take BQL
> =C2=A0=C2=A0=C2=A0=C2=A0bdrv_drain
> =C2=A0=C2=A0=C2=A0=C2=A0... hangs ...

:/

Is there really nothing we can do?=C2=A0 Forgive me if I=E2=80=99m talking = complete
nonsense here (because frankly I don=E2=80=99t even really know what a bott= om
half is exactly), but can=E2=80=99t we schedule some coroutine in the main =
thread to do the perm notifications and wait for them in the I/O thread?

I t= hink you still get a deadlock, just one with a longer chain. You still have= a cycle of things depending on each other, but one of them is now the I/O = thread waiting for the bottom half.

Hmm..= .=C2=A0 Perhaps.=C2=A0 We would need to undo the permission change when the=
job finishes, though, i.e. in JobDriver.prepare() or JobDriver.clean().=C2= =A0
Doing the change in qmp_x_blockdev_amend() would be asymmetric then, so we=E2=80=99d probably want a new JobDriver method that runs in the main thr= ead
before .run() is invoked. (Unfortunately, =E2=80=9C.prepare()=E2=80=9D is n= ow taken
already...)

Ok at least it's feasible.

=
Doesn=E2=80=99t solve the FUSE problem, but there we could try to just tak= e the
RESIZE permission permanently and if that fails, we just don=E2=80=99t allo= w
truncates for that export.=C2=A0 Not nice, but should work for common cases= .

Yeah definitely not nice. Probably permissions could be protected by their= own mutex, even a global one like the one we have for jobs. For now I sugg= est just ignoring the problem and adding a comment, since it's not real= ly something that didn't exist.

Paolo
--00000000000005299f05d11ba8d3--