Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2317002lqo; Mon, 20 May 2024 01:49:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3Mdc0gfu4vwT42eNbFxzxnO8vI4zPAGRZJ/9gOO3MnSEX6QLEZckIaM9fBiC+A5K4LgZQ41jWtMjz9V4n5bpxLs7b8EZ8RcnBh3cJHw== X-Google-Smtp-Source: AGHT+IFL3HbD5h+jfsC2z6kDB0Dy+4me9FQ2qmeUzo/6bgIMYyjS69bTHlf/HtePt3INXDYGB8rv X-Received: by 2002:a19:f50b:0:b0:51c:6c59:627e with SMTP id 2adb3069b0e04-52210074a34mr16963673e87.42.1716194960468; Mon, 20 May 2024 01:49:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716194960; cv=pass; d=google.com; s=arc-20160816; b=SfmiS8eBMS58xcZvAEJiZ0yDB8+vazBX3QxYYPj+fKke+1pe6p7KA6vqjrqpm4dp7u TtB6m2OjTra8eXNUdgDp0+Cz8F4tYnECVUMm95Q5zWwr1EcL1+QfNx4p2UKLE2q1bqb3 uICHpP54Hi76QQioxm2tuQk8gF2yIgHa1qzP83oSc8vAK44d+kqrFW0H4auiaLFHw5R8 P3bzhHY+wEM1fZ/pf6dD0WQDIuld9vqKvOschEyryT0hjXdAYpbcSO2W6YGBQS+mfE3E 31WvvtjIx7ySA4ayAKQmpJd9MIydCL2CEGUmOUiUOo5+an0MI77OASrnsA9hd/hrio4T m94g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=xmN+qMxf6btR4ij7xXK5Fa3M1JEpt2XRh4mZOWfFXOw=; fh=zUk7pmhdHPBfC0TeTIu+ny7oGQ5K5Ams8gZPRx8OEOA=; b=QpTL2d9ioUANZEPCXWNbzFgc6wuHmDitiCKBMqJ6cW0JkD5W1EHnnaatzap+JamlmI n32Ug4SRIhePoWIP2eWPLoyhwJUKl0PtvQkPV9azencAkiynSjRD2hyqHtS7YgmFQpOa 7GYigh+UQ8Kw1e1w19pOd6Aer6JHc9+hN+omCF6GkSRDFJIiCpvP4VVYxLnex5Ycck/H oi3Q+yIERwUQz/k4kUftmVRsz7huNMyblhHwkNZTcGCxmjZ1e72EF5RTfL4TmEC3jPYH ymDhTZ4OBDRxQCCxfhZZQm9GwKFoG/yDBDY2c8zFNZi9D4sGce76yX1cw/xDIVuWjQjx iXdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="Ebsu/ASE"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="Ebsu/ASE"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-ext4+bounces-2596-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2596-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-574e13c701fsi2508797a12.378.2024.05.20.01.49.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 01:49:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2596-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="Ebsu/ASE"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="Ebsu/ASE"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-ext4+bounces-2596-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2596-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E04001F21A63 for ; Mon, 20 May 2024 08:49:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5D5E1C6A3; Mon, 20 May 2024 08:49:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Ebsu/ASE"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="CxenKFac"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Ebsu/ASE"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="CxenKFac" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69FBFA2D; Mon, 20 May 2024 08:49:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716194950; cv=none; b=TJkCguxq1+20v6HpOurytyuu9w60KiWDc3q5cht+We8f4ZsUbUtQFcVubEJ9768nIi62/NFDO5QwENcKy9zsnMS610PiOtivzur6F8Bl3yYWfmAsDbEPodmgZHEG7fvNuD8arVJ1VWXWow7T0jLgK/vm19Xcve73jo0UvJL2kmk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716194950; c=relaxed/simple; bh=2m8/0Wpgypww/qVvVssQsZJ3ugL36NGsxAEznLE8o6g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RwnQehlH1wtcas6v3XPYmsgoEU3tTDWFpoQ37L2KzKv2uzxz+iGiwRE3XGzQDMkypOKBg0lVnAABuK0LwSw8fTXpFGG56KK13ZjMC4YVhCBPYMvo6S83MGxShum6gE11iaTC9hDM5mK4RqllH/S2YijcbUZd8FhQGcUP7pl8AyM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Ebsu/ASE; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=CxenKFac; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Ebsu/ASE; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=CxenKFac; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 88F4620396; Mon, 20 May 2024 08:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1716194946; h=from:from:reply-to: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=xmN+qMxf6btR4ij7xXK5Fa3M1JEpt2XRh4mZOWfFXOw=; b=Ebsu/ASE8JIhICjFkD6q9253i4A2t9ZNhIyWW3JuWbBKKKSlgL8EmmJ/3vzafglqe30eAZ PWbLVQW8MKA/P8xyG2Nu47PMOIUfI1Ej2SYpdbtusDu4HnXNZtw0c/mn/tvKYzBfqGn4L4 j61C72ELZcQSVvvx+kZ82TO6XrAVMcw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1716194946; h=from:from:reply-to: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=xmN+qMxf6btR4ij7xXK5Fa3M1JEpt2XRh4mZOWfFXOw=; b=CxenKFacN8a9bLYZBO4ZhrYcBIc+iqsWZWwix31LIvZr75XMK+MC0SeLMBpCYMX/ZIjDYD vHTuqv1XKif4EaBQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1716194946; h=from:from:reply-to: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=xmN+qMxf6btR4ij7xXK5Fa3M1JEpt2XRh4mZOWfFXOw=; b=Ebsu/ASE8JIhICjFkD6q9253i4A2t9ZNhIyWW3JuWbBKKKSlgL8EmmJ/3vzafglqe30eAZ PWbLVQW8MKA/P8xyG2Nu47PMOIUfI1Ej2SYpdbtusDu4HnXNZtw0c/mn/tvKYzBfqGn4L4 j61C72ELZcQSVvvx+kZ82TO6XrAVMcw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1716194946; h=from:from:reply-to: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=xmN+qMxf6btR4ij7xXK5Fa3M1JEpt2XRh4mZOWfFXOw=; b=CxenKFacN8a9bLYZBO4ZhrYcBIc+iqsWZWwix31LIvZr75XMK+MC0SeLMBpCYMX/ZIjDYD vHTuqv1XKif4EaBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7AF1E13A21; Mon, 20 May 2024 08:49:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id P4P2HYIOS2Y+AQAAD6G6ig (envelope-from ); Mon, 20 May 2024 08:49:06 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 251A2A0888; Mon, 20 May 2024 10:49:06 +0200 (CEST) Date: Mon, 20 May 2024 10:49:06 +0200 From: Jan Kara To: Zhang Yi Cc: Jan Kara , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, ritesh.list@gmail.com, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: Re: [PATCH] ext4/jbd2: drop jbd2_transaction_committed() Message-ID: <20240520084906.ejykv3xwn7l36jbg@quack3> References: <20240513072119.2335346-1-yi.zhang@huaweicloud.com> <20240515002513.yaglghza4i4ldmr5@quack3> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Level: X-Spamd-Result: default: False [-2.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; RCPT_COUNT_SEVEN(0.00)[11]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[suse.cz,vger.kernel.org,mit.edu,dilger.ca,gmail.com,huawei.com]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email] X-Spam-Score: -2.30 X-Spam-Flag: NO On Thu 16-05-24 16:27:25, Zhang Yi wrote: > On 2024/5/15 8:25, Jan Kara wrote: > > On Mon 13-05-24 15:21:19, Zhang Yi wrote: > > Also accessing j_commit_sequence without any > > lock is theoretically problematic wrt compiler optimization. You should have > > READ_ONCE() there and the places modifying j_commit_sequence need to use > > WRITE_ONCE(). > > > > Thanks for pointing this out, but I'm not sure if we have to need READ_ONCE() > here. IIUC, if we add READ_ONCE(), we could make sure to get the latest > j_commit_sequence, if not, there is a window (it might becomes larger) that > we could get the old value and jbd2_transaction_committed() could return false > even if the given transaction was just committed, but I think the window is > always there, so it looks like it is not a big problem, is that right? Well, all accesses to any memory should use READ_ONCE(), be protected by a lock, or use types that handle atomicity on assembly level (like atomic_t, or atomic bit operations and similar). Otherwise the compiler is free to assume the underlying memory cannot change and generate potentionally invalid code. In this case, I don't think realistically any compiler will do it but still it is a good practice and also it saves us from KCSAN warnings. If you want to know more details about possible problems, see tools/memory-model/Documentation/explanation.txt chapter "PLAIN ACCESSES AND DATA RACES". Honza -- Jan Kara SUSE Labs, CR