Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1076676pxb; Tue, 9 Nov 2021 04:52:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJys8wtNLxspf1Bl5hIhQ0QVtkbObSelpE4uF8zPtUNfKtx4U+vGVoBrrQ3t3eQUOzAjFLMF X-Received: by 2002:a17:906:4fcc:: with SMTP id i12mr9194248ejw.309.1636462366380; Tue, 09 Nov 2021 04:52:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636462366; cv=none; d=google.com; s=arc-20160816; b=SzgS1TDCx7IDZGmyMCf8lsPGjaJAS4QI7o/gTYPjoIQ+ArFBHMzYnhIohhURHGAF6q UNa2BuZwMOy6gmKVKrJNeojr71jHmykG91vC4R6QkciKUTnQNwkP1MUsqnWcVz0lszJa SbO46tYs6x1uimmLIqDjz6ktXjifMm2WriatlfFJtkFT1DgR5mgBbdqXdMEHBwzvupJ7 nyWaml+Wp5unKQw1JIjAIbPbbjZQQBYXE8kPwZ5IYrzOA17WD3TXkcWURNlzszeV8oUO +IFrrsCSoJpl8jh44mwnJtVKnIJuDE5QvdHbo5C3sPvRbL2BiO/Se0h+NMvhf0gkA09G CfWQ== 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=TjMwA3sj6kmxntItjWZc7nhE9GMNGbJB51PaGp7puEY=; b=lb/vPH9mj1O0bJgWPIJQd6uBY37L8TLY95EyleuDs89hutLQkfECBl45wuxT4OYiUM jNaDsIEbrQoeX080rJVnePOuMh18wmSzrE5Vhs9Q8NPZd96STeX2BNHfbHi+mz7WRVSt ikBFZ3Wn+JfH3bhRO5F3FvuMVN3YK6+6NGxh9bqpef/noyyUdofanaRGa+KPWCy+oTGd kbiEpfpbloipyPmehD4OygZRuVDpY4DeDnUcVyqUESiUQwz5VVVdRi8yf5MNu4XAAboK H3wCd10N9d2QdqK498h0sCf4zDjp60J88eBrU5fWen1FaULn98QBhkk3ZiJ4R8BgVmuT 1Wiw== 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 b7si3729139ejv.400.2021.11.09.04.52.11; Tue, 09 Nov 2021 04:52:46 -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 S242859AbhKIEw7 (ORCPT + 99 others); Mon, 8 Nov 2021 23:52:59 -0500 Received: from mail109.syd.optusnet.com.au ([211.29.132.80]:49766 "EHLO mail109.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbhKIEw6 (ORCPT ); Mon, 8 Nov 2021 23:52:58 -0500 Received: from dread.disaster.area (pa49-195-103-97.pa.nsw.optusnet.com.au [49.195.103.97]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 9E3CCA0C45; Tue, 9 Nov 2021 15:50:11 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1mkJ5G-006ce5-GH; Tue, 09 Nov 2021 15:50:10 +1100 Date: Tue, 9 Nov 2021 15:50:10 +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: <20211109045010.GG418105@dread.disaster.area> References: <20211102024258.210439-1-sunrise_l@sjtu.edu.cn> <20211103002843.GC418105@dread.disaster.area> <20211104232226.GD418105@dread.disaster.area> <01e6abf4-3ae5-ecab-3b7f-876c8a3fcbb4@sjtu.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01e6abf4-3ae5-ecab-3b7f-876c8a3fcbb4@sjtu.edu.cn> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=epq8cqlX c=1 sm=1 tr=0 ts=6189fe04 a=fP9RlOTWD4uZJjPSFnn6Ew==:117 a=fP9RlOTWD4uZJjPSFnn6Ew==:17 a=kj9zAlcOel0A:10 a=vIxV3rELxO4A:10 a=7-415B0cAAAA:8 a=6VncYBqVuDewgahjr6AA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Nov 05, 2021 at 01:28:10PM +0800, Zhongwei Cai wrote: > > > On 11/5/21 7:22 AM, Dave Chinner wrote: > > > > No. Some filesystems don't track inode metadata dirty status using > > the VFS inode; instead they track it more efficiently in internal > > inode and/or journal based structures. Hence the only way to get > > "inode needs journal flush for data stability" information to > > generic IO code is to have a specific per-IO mapping flag for it. > > > > Could we add IOMAP_REPORT_DIRTY flag in the flags field of > struct iomap_iter to indicate whether the IOMAP_F_DIRTY flag > needs to be set or not? You can try. It might turn out OK, but you're also going to have to modify all the iomap code that current needs IOMAP_F_DIRTY to first set that flag, then change all the code that currently sets IOMAP_F_DIRTY to look at IOMAP_REPORT_DIRTY. i.e you now have to change iomap, ext4 and XFS to do this. > Currently the IOMAP_F_DIRTY flag is only checked in > iomap_swapfile_activate(), dax_iomap_fault() and iomap_dio_rw() > (To be more specific, only the write path in dax_iomap_fault() and > iomap_dio_rw()). So it would be unnecessary to set the IOMAP_F_DIRTY > flag in dax_iomap_rw() called in the previous tests. I think you're trying to optimise the wrong thing - the API is not the problem, the problem is that the journal->j_state_lock is contended and the ext4 dirty inode check needs to take it. Fix the dirty check not to need the journal state lock and the ext4 problem goes away and there is no need to change the iomap infrastructure. > Other file systems that set the IOMAP_F_DIRTY flag efficiently > could ignore the IOMAP_REPORT_DIRTY flag. No, that's just bad API design. If we are adding IOMAP_REPORT_DIRTY then the iomap infrastructure should only use that control flag when it needs to know if the inode is dirty. At this point, it really becomes mandatory for all filesystems using iomap to support it because the absence of IOMAP_F_DIRTY because a filesystem doesn't support it is not the same as "filesystem didn't set it because the inode is clean". Cheers, Dave. -- Dave Chinner david@fromorbit.com