Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4861235pxb; Tue, 2 Nov 2021 17:37:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+luPmpdcbQWmlg6BWUyBcOA+C4Une5aOXK+h/klervlXpUACMIHHXPD9b6jFLykmHXja1 X-Received: by 2002:a17:906:1601:: with SMTP id m1mr50446561ejd.117.1635899879133; Tue, 02 Nov 2021 17:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635899879; cv=none; d=google.com; s=arc-20160816; b=AJf9pW8dXe68yQGQFHaDG86DHP3Rx7rA6ZBtEEpLGrp34+iYjj+8v8wCanJfdVCaTN fPsbZp8QaUYiR1Dafn9QeKBErH6nZKUmxrftsQkYId4pJMlR7jUs4nE2ZO1ne4MGTkv+ BpKRL9ZNn1jgYBmZtpVFWA2o+ZRRV8og7hj5TT7Rg3YDRiQ6kYVmSD7FDh2BXyfHDn2a PPvFOd5erj/MgF7TBlAOtqnXn+Cro3gKZnQnF2Dhi9Iv8/5tVPzkNqDMxlTPo/TqNlX5 8JHT+DYTzDsvGtS+b6qRYKjUQ6SkLtCFi8278qsdHCIr5xpU2d8FkuU1vnIDHqKlbNgl zbrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=cMnkuaPUCOYNqGdFxlhmpkyZwYLGnDFmCy/yeJT+/Hg=; b=Mw9GjTGEtncntKQoneUz+08vl7vNbOz0B9QrF6As67b/STSbKFP1R3ViY68UtHbJH9 Ks3jXLEYWrvHzHK3fuDguhHKOAnIpwu1+j1JCYEn2zTYvo0ycA9mB1AJV6YJA1oagCyW hxX21GO1vxfQiOgjNCbfu7LLN6mPILOO2gHesvqiVy5X9ahg9LiOVso10w2ANl599kJc vN+AH5iE0y6e2EGUU4jWqio63rrwLk9799lXu3QNCcEGCfBGDSODL/gtVk6fYxJW+fE7 PPCPrUr+f2bdAOtWE5THcDA9ZdbQWdmd1pNeyTCyTac5r/IDGDNRLwizDQHS9qYWDzcc LyGA== 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 mj23si843944ejb.591.2021.11.02.17.37.23; Tue, 02 Nov 2021 17:37:59 -0700 (PDT) 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 S231931AbhKCAbY (ORCPT + 99 others); Tue, 2 Nov 2021 20:31:24 -0400 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:34014 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbhKCAbX (ORCPT ); Tue, 2 Nov 2021 20:31:23 -0400 Received: from dread.disaster.area (pa49-180-20-157.pa.nsw.optusnet.com.au [49.180.20.157]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 6494E105AF48; Wed, 3 Nov 2021 11:28:45 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1mi48x-004Bdt-U8; Wed, 03 Nov 2021 11:28:43 +1100 Date: Wed, 3 Nov 2021 11:28:43 +1100 From: Dave Chinner To: Zhongwei Cai Cc: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, mingkaidong@gmail.com Subject: Re: [PATCH] ext4: remove unnecessary ext4_inode_datasync_dirty in read path Message-ID: <20211103002843.GC418105@dread.disaster.area> References: <20211102024258.210439-1-sunrise_l@sjtu.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211102024258.210439-1-sunrise_l@sjtu.edu.cn> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=epq8cqlX c=1 sm=1 tr=0 ts=6181d7be a=t5ERiztT/VoIE8AqcczM6g==:117 a=t5ERiztT/VoIE8AqcczM6g==:17 a=kj9zAlcOel0A:10 a=vIxV3rELxO4A:10 a=7-415B0cAAAA:8 a=YA9poQYvTuHJZr3_SNYA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Nov 02, 2021 at 10:42:58AM +0800, Zhongwei Cai wrote: > ext4_inode_datasync_dirty will call read_lock(&journal->j_state_lock) in > journal mode, which is unnecessary in read path (As far as I know, the > IOMAP_F_DIRTY flag set in the if branch is only used in write path, > making it unnecessary in read path. Please correct me if I'm wrong). IOMAP_F_DIRTY isn't conditional on the type of lookup being done. If the inode is dirty in a way that O_DSYNC would require it to be flushed to make the data stable, iomap should be told that it is dirty, even on read lookups... e.g. iomap_swapfile_activate() uses IOMAP_REPORT as the flags for extent mapping iteration passed to iomap_swapfile_iter(). THis then checks: /* No uncommitted metadata or shared blocks. */ if (iomap->flags & IOMAP_F_DIRTY) return iomap_swapfile_fail(isi, "is not committed"); IOWs, we expect the IOMAP_F_DIRTY flag to be set on all types of iomap mapping calls if the inode is dirty, not just IOMAP_WRITE calls. Cheers, Dave. -- Dave Chinner david@fromorbit.com