Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2006512pxb; Thu, 11 Feb 2021 01:37:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaFbh/4d8gshj7DMYs1FTzFkcnQIGT24+YxX/DSKYRSQ5aWlCCMdXYLnKylZJUQaacCDez X-Received: by 2002:a17:906:6943:: with SMTP id c3mr7449332ejs.133.1613036244128; Thu, 11 Feb 2021 01:37:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613036244; cv=none; d=google.com; s=arc-20160816; b=LntA8g/JQMAGHLj7hHBwYPiUJssWpye6PNTgQv4PUiSHDyHU0DLaRIshV4kSm1jaEP CbhecMYZELSNyOkmYNj7B+SohYJMWA+BlZ7kQ1WBEkH4B0UB22w6fW21AiQE5g1cD86B 3yI7wSRrWJMIEpGjdMX0XlnmFCzR1TrwD6dwCHHXS9/3a08+3gDL5wYMxAIC45iuOdh7 D38gH0BdBCpKlFWkS2KOqtNcA/HrOutwakynQ/GkRhMytc7h9OKmPuTKUAZNg5Z38ZtV HwrOXduT53M+WGtiUhAmJKSbQDdww+K0AdRzYTmjrj61MUEgGTzC6tST4D8sQRv72T+M K8Xg== 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=VgwyoTvWf/cKeC9oXjgNYQPg0M/UGmtJzRdXbRmFIAQ=; b=epB+PGxhyxq7ppjsQL952HG5U00HOwJf4SGTG2df28L9VLP4fi2Db3fDxoAV0dpLUs h1cu9G+3Li3Ay3V9jFusl8RH36Ot3vd+dwS7nekuogHTLB2krsyCkm+mH/hI867/e3e8 3SbvSXPbjoj2dIPgLPOngIvf9RZv+NFrBtnlI+EXtOCvHKkAM/PSDYIPsJ+Rx1Bq+Ic4 K0kdGBlRPug+D4LWTaLD6xdPqz2YGbWf//Ya20jVhlmc+AZevSqZnnVUMjY8oeJDXdDE V8Odz1s7Wz3OrPiGodty/Tani+qELLOnS4ws2UedkmNnN9TnRR6H4Fpz/9N9KI2jpBns kZ+Q== 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 f7si3992477edd.574.2021.02.11.01.36.53; Thu, 11 Feb 2021 01:37:24 -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 S230080AbhBKJeb (ORCPT + 99 others); Thu, 11 Feb 2021 04:34:31 -0500 Received: from mx2.suse.de ([195.135.220.15]:44932 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbhBKJbf (ORCPT ); Thu, 11 Feb 2021 04:31:35 -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 0CEDBAC6E; Thu, 11 Feb 2021 09:30:28 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 64D131E14B2; Thu, 11 Feb 2021 10:30:27 +0100 (CET) Date: Thu, 11 Feb 2021 10:30:27 +0100 From: Jan Kara To: Alexander Lochmann Cc: 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: <20210211093027.GI19070@quack2.suse.cz> References: <20210210095740.54881-1-alexander.lochmann@tu-dortmund.de> <20210210095740.54881-2-alexander.lochmann@tu-dortmund.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210210095740.54881-2-alexander.lochmann@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 Wed 10-02-21 10:57:39, Alexander Lochmann wrote: > Some members of transaction_t are allowed to be read without > any lock being held if consistency doesn't matter. > Based on LockDoc's findings, we extended the locking > documentation of those members. > Each one of them is marked with a short comment: > "no lock for quick racy checks". > > Signed-off-by: Alexander Lochmann > Signed-off-by: Horst Schirmeier Thanks for the patch! Some comments below... > --- > include/linux/jbd2.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h > index 99d3cd051ac3..18f77d9b1745 100644 > --- a/include/linux/jbd2.h > +++ b/include/linux/jbd2.h > @@ -594,18 +594,18 @@ struct transaction_s > */ > 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. > /* > * Doubly-linked circular list of all buffers reserved but not yet > - * modified by this transaction [j_list_lock] > + * modified by this transaction [j_list_lock, no lock for quick racy checks] > */ > struct journal_head *t_reserved_list; > > /* > * Doubly-linked circular list of all metadata buffers owned by this > - * transaction [j_list_lock] > + * transaction [j_list_lock, no lock for quick racy checks] > */ > struct journal_head *t_buffers; > > @@ -631,7 +631,7 @@ struct transaction_s > /* > * Doubly-linked circular list of metadata buffers being shadowed by log > * IO. The IO buffers on the iobuf list and the shadow buffers on this > - * list match each other one for one at all times. [j_list_lock] > + * list match each other one for one at all times. [j_list_lock, no lock for quick racy checks] > */ > struct journal_head *t_shadow_list; The above three cases are the same as t_reserved_list. Honza -- Jan Kara SUSE Labs, CR