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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84693C433E0 for ; Thu, 11 Feb 2021 13:37:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 483ED64DA8 for ; Thu, 11 Feb 2021 13:37:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230239AbhBKNhR (ORCPT ); Thu, 11 Feb 2021 08:37:17 -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-kernel@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