Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1451188pxb; Thu, 4 Nov 2021 02:30:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNo/MsspNMTSCaI0j2/9cS9+ohaRxFB14QKGcLwuo8ylBXnEftXKI92qMkkMnI5EpERM0v X-Received: by 2002:a05:6402:2920:: with SMTP id ee32mr43210691edb.136.1636018250358; Thu, 04 Nov 2021 02:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636018250; cv=none; d=google.com; s=arc-20160816; b=CX62IlKfZs++hqZKRg0JkdDfPFzWJ2SqMfivGnQILd2oDHnNYjt0Uvw65oYD3hlUHm H4os9Wj6nbxWNeK0jRXmmCMH6x+1E5vWCdqlX+ebEVwFowcok25PqHlK5lvGYJ+tLrHq BGzvBn58dNcOWvBJyZyVU7LhwzpIu2DIHwBlzj0aWkCfZA//iRHHOx1js1/E3zIg2Bjt e8I3SDum0p3UWAPcFtdHyQdBFb5NZ3cmjIXihx7QPsFdHqIoGpaE/HQC6EnlzS/d+67P 6ZySmbnlP+wq5SmrmIB8+9vAd6lqLaOTdOOqB3C9qmvce7NpqeKDu6fH6B1xR+0wYlOz 0B4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=qhi1I/K7j+FkcF4fWiWbrz0brNXmvdnSDfiBhol8T4g=; b=wIyIVfCIwRhs667lQF+EuNfEPtlCX2WimEw+iXqUGqzMaw8SJWi95MUdN864Whm31K 7FpYHX4oHfxrSGn88tAp/T5v9J1tWyGdLxGs2Ps1U6L+zLZIrUG2iRxfvTcADEmSQF8z 2c8iw1IWki9mi3aw9AmCV7zMtALw+ktrguEc+oIY+t2xGoTWjqEYC+nqjtNoYbtk75SA wEs3bPCuWYP8PQFgoBaVgdjCnw+ez3zY9stoVW5cpiQUjJBbpE8p2EXVg/RtbzVLWMVh +IeWqy9E4Tmgx+5pOvQBaoNMZud2Kfhxhr/gIaAdioz+szy7gf8PYVpKG8KKiNdRvNuA M7ew== 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 q10si1651627edd.577.2021.11.04.02.30.22; Thu, 04 Nov 2021 02:30:50 -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 S230450AbhKDJcw (ORCPT + 99 others); Thu, 4 Nov 2021 05:32:52 -0400 Received: from smtp181.sjtu.edu.cn ([202.120.2.181]:52342 "EHLO smtp181.sjtu.edu.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230363AbhKDJcv (ORCPT ); Thu, 4 Nov 2021 05:32:51 -0400 Received: from proxy02.sjtu.edu.cn (smtp188.sjtu.edu.cn [202.120.2.188]) by smtp181.sjtu.edu.cn (Postfix) with ESMTPS id 577391008CBC0; Thu, 4 Nov 2021 17:30:12 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by proxy02.sjtu.edu.cn (Postfix) with ESMTP id 2FAB42007EC6E; Thu, 4 Nov 2021 17:30:09 +0800 (CST) X-Virus-Scanned: amavisd-new at Received: from proxy02.sjtu.edu.cn ([127.0.0.1]) by localhost (proxy02.sjtu.edu.cn [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 8E93ccPlxdbj; Thu, 4 Nov 2021 17:30:06 +0800 (CST) Received: from [192.168.11.167] (unknown [202.120.40.82]) (Authenticated sender: sunrise_l@sjtu.edu.cn) by proxy02.sjtu.edu.cn (Postfix) with ESMTPSA id ADE4D200B8923; Thu, 4 Nov 2021 17:29:59 +0800 (CST) Subject: Re: [PATCH] ext4: remove unnecessary ext4_inode_datasync_dirty in read path To: Dave Chinner Cc: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, mingkaidong@gmail.com References: <20211102024258.210439-1-sunrise_l@sjtu.edu.cn> <20211103002843.GC418105@dread.disaster.area> From: Zhongwei Cai Message-ID: Date: Thu, 4 Nov 2021 17:29:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211103002843.GC418105@dread.disaster.area> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 11/3/21 8:28 AM, Dave Chinner wrote: > 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. Thanks for correction! > /* > * Flags reported by the file system from iomap_begin: > * > * IOMAP_F_NEW indicates that the blocks have been newly allocated > * and need zeroing for areas that no data is copied to. > * > * IOMAP_F_DIRTY indicates the inode has uncommitted metadata needed > * to access written data and requires fdatasync to commit them to > * persistent storage. This needs to take into account metadata > * changes that *may* be made at IO completion, such as file size > * updates from direct IO. > * > * IOMAP_F_SHARED indicates that the blocks are shared, and will > * need to be unshared as part a write. > * > * IOMAP_F_MERGED indicates that the iomap contains the merge of > * multiple block mappings. > * > * IOMAP_F_BUFFER_HEAD indicates that the file system requires the > * use of buffer heads for this mapping. > */ According to the comments in include/linux/iomap.h, it seems other flags in the iomap indicates the iomap-related status, but the IOMAP_F_DIRTY flag only indicates the status of the inode. So can I_DIRTY_INODE or I_DIRTY_PAGES flags in the inode replace it? And for ext4 at least we can do /* * Writes that span EOF might trigger an I/O size update on completion, * so consider them to be dirty for the purpose of O_DSYNC, even if * there is no other metadata changes being made or are pending. */ if (ext4_inode_datasync_dirty(inode) || - offset + length > i_size_read(inode)) + ((flags & IOMAP_WRITE) && offset + length > i_size_read(inode))) iomap->flags |= IOMAP_F_DIRTY; , since only writes that span EOF might trigger an update. How do you feel about it? Best, Zhongwei.