From nobody Mon Mar 20 18:07:33 2023 X-Original-To: freebsd-fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PgN4h0vwpz402xV for ; Mon, 20 Mar 2023 18:07:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4PgN4g4rH6z4Snf for ; Mon, 20 Mar 2023 18:07:47 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.17.1/8.17.1) with ESMTPS id 32KI7XnD017087 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 20 Mar 2023 20:07:36 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 32KI7XnD017087 Received: (from kostik@localhost) by tom.home (8.17.1/8.17.1/Submit) id 32KI7XW7017086; Mon, 20 Mar 2023 20:07:33 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 20 Mar 2023 20:07:33 +0200 From: Konstantin Belousov To: Alexander Lochmann Cc: freebsd-fs@freebsd.org Subject: Re: Understanding locking for buf Message-ID: References: <8e9ac2ec-6387-27b0-5cdc-1d61dbe2c831@tu-dortmund.de> <1743b9f5-69be-b775-fb57-92b8115d4a81@tu-dortmund.de> <6b1181f7-a58f-8d71-a05e-2dcb0a66ae4c@tu-dortmund.de> <2c5e6f8d-037b-9bfe-bdad-4a367bdbc65d@tu-dortmund.de> List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2c5e6f8d-037b-9bfe-bdad-4a367bdbc65d@tu-dortmund.de> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on tom.home X-Rspamd-Queue-Id: 4PgN4g4rH6z4Snf X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On Mon, Mar 20, 2023 at 11:25:30AM +0100, Alexander Lochmann wrote: > > > On 16.03.23 12:24, Konstantin Belousov wrote: > > > Is the following correct? > > > The aforementioned accesses by 100033 in g_vfs_done() are no violations with > > > respect to the locking rule because from a global perspective the buf is > > > locked. It is the only concurrent access at that moment. > > I would formulate it differently: > > No other thread might legitimately get access to the buffer using > > either bread() or getblk() until current io operation finishes. > > The io operation is handled in two contexts: top-level, where a thread > > used getblk() as usual to claim buffer ownership, and completion > > thread context (geom up thread). The completion code legitimately > > manipulates the buffer, because the top-level code expects that after > > the buffer strategy routine is called, effectively moving the ownership > > to the geom up thread. > Thx. But the top-level thread, using getblk(), legitimately releases the > lock. Am I right? No. It does not, please re-read what I wrote.