Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2131573pxb; Thu, 11 Feb 2021 05:19:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBTL5U/yATAB8SKYo0o1t7b3HlImapzlggxV5yqoCNSUctcpYvHAnMmvDWKJUDXyH6fUkO X-Received: by 2002:aa7:d5c1:: with SMTP id d1mr8163041eds.359.1613049574567; Thu, 11 Feb 2021 05:19:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613049574; cv=none; d=google.com; s=arc-20160816; b=KFr5A8D7JbkRwPvZDtsMQVSdyMGeOcMXBWeaOOtb2xDw/3reevgiImTTQIC/f5Cz9f E0fWGJjqaCVmrhmlS4rcZ6OFWppCIoPOPOP/IV+55W/XnmQyYaLuYo2TKcRJoTI1tDCp +IcAQ7pU97jrWJTTrTIkKZGcW9138djEGqkVRwu8tVs5HDyofRI30roqnbU7IVq7+7c+ ipqF39ntgv6myMgoFH1pzbEqcOxIHqe5Rgr3iasQjL0uWjfs+g+PiPi7V1EGpTx0eXxO hgH3/cw+F8129/js548N9zfdic4pVV5Z3CJxLN9rsApGOmFp6/RU5aVIXs8ax4h5sIBz fwQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=tBCZyYjMbU4SIaBdDHRlk13ueigo0aL/9KW3wr66fQY=; b=ej6forM8cPe+j53J3YdgArBSfj0Sp1nCm0jye6MzPnj6TFMaFX6gmQu0KAEKuEQdVH /VkQ0anIk7NynQ+iQJhaRh8Vfwji2t0fUAGcEkzP4KG6lDIeVhpK1h8p62HYdl/cYtLq QNlZpQyJZTHYJPWpKKhRmy9ZxFoT0IqFxd1e3tsYfZOFZSSlQ4EgXrK2hm/unMX9fBvP PiWSialFzB9bxAZtEcBK5MTkW1gfRc/+IstXEPTq/2Ovoo1p7YRsQfyfBWmFmnu4LLV5 KRIUcTN8Y/ircQs7WnFFN2PwQ6QdXtQxdbergVbXgC+ia+sw9dC5sao5bNgE4/fkzFWK 6Maw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si4017899edp.72.2021.02.11.05.19.09; Thu, 11 Feb 2021 05:19:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231383AbhBKNQc (ORCPT + 99 others); Thu, 11 Feb 2021 08:16:32 -0500 Received: from mx2.suse.de ([195.135.220.15]:54404 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbhBKNO2 (ORCPT ); Thu, 11 Feb 2021 08:14:28 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 99560AD29; Thu, 11 Feb 2021 13:13:42 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 3F01D1E14B2; Thu, 11 Feb 2021 14:13:42 +0100 (CET) Date: Thu, 11 Feb 2021 14:13:42 +0100 From: Jan Kara To: Alexander Lochmann Cc: Jan Kara , Horst Schirmeier , Theodore Ts'o , Jan Kara , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] Updated locking documentation for transaction_t Message-ID: <20210211131342.GQ19070@quack2.suse.cz> References: <20210210095740.54881-1-alexander.lochmann@tu-dortmund.de> <20210210095740.54881-2-alexander.lochmann@tu-dortmund.de> <20210211093027.GI19070@quack2.suse.cz> <1803ac43-d6fc-4de8-78a0-7fc807f9c036@tu-dortmund.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1803ac43-d6fc-4de8-78a0-7fc807f9c036@tu-dortmund.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu 11-02-21 10:53:51, Alexander Lochmann wrote: > > > On 11.02.21 10:30, Jan Kara wrote: > > > */ > > > unsigned long t_log_start; > > > - /* Number of buffers on the t_buffers list [j_list_lock] */ > > > + /* Number of buffers on the t_buffers list [j_list_lock, no lock for quick racy checks] */ > > > int t_nr_buffers; > > > > So this case is actually somewhat different now that I audited the uses. > > There are two types of users - commit code (fs/jbd2/commit.c) and others. > > Other users properly use j_list_lock to access t_nr_buffers. Commit code > > does not use any locks because committing transaction is fully in > > ownership of the jbd2 thread and all other users need to check & wait for > > commit to be finished before doing anything with the transaction's buffers. > Mhm I see. > What about '[..., no locks needed for jbd2 thread]'? Sounds good to me. > How do the others wait for the commit to be finished? Well, usually they just don't touch buffers belonging to the committing transation, they just store in b_next_transaction that after commit is done, buffer should be added to the currently running transaction. There are some exceptions though - e.g. jbd2_journal_invalidatepage() (called from truncate code) which returns EBUSY in some rare cases and we use jbd2_log_wait_commit() in ext4_wait_for_tail_page_commit() to wait for commit to be done before we know it is safe to destroy the buffer. Honza -- Jan Kara SUSE Labs, CR