Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp104657pxv; Thu, 8 Jul 2021 16:17:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQkn2wTxsV8QprXuDSuexsiSoyHRRZvAB2PJ/HH5Z/zom10WNUqhScIWJ4XwpJZJ+kJOao X-Received: by 2002:a05:6638:3819:: with SMTP id i25mr22616868jav.44.1625786276265; Thu, 08 Jul 2021 16:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625786276; cv=none; d=google.com; s=arc-20160816; b=GQR/p9YfGoZhmhYHqQgQnZcmfpeNz6J8w5gwE05Mb1D3TvH7cKHT2Ifzb6j7iS5kM0 KljlM0jT8DH7LzknEVy7cJ83KbM0+LWIzY4BswP2pmU9e25UA+RjImnNkLvgGdSoweph bkvdS/wiRrWn9bsYucBMuf53uplpKIp86aT2vam2KkfAXI32tKcoXgjTWxg0eOWOhiXG 4VybUCJSR7OAMLCYhEhXUF3ZFxpkHa9diNlQ0HWT3Qgj1wWh1icGI6lH/nZpE+2ZWLka 50hCjzPHch6KzH/XFbjo9QYaHbp437WLLvn5IpUsrg+GrPhbjxOm6TAdnDdK3hrb6TmC iadA== 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=V0vUE3oEw87/EJj3soiR/tXm6uWcUzUBbNnP9NwLt7s=; b=VvxAczf3sK79iQF8/wHTh0dbCUuJxWiKqL20LL/d6PUwPupyt86N3OQtkfYPa8xu7J a9RYUBYR0a1vo2DgJm/N/4huUKoyIEislaQsb04K2/oNqR6JdZMPTi/f5KHzc7JK3i8G 7WKk7ROXGiFmgFW2TqOvZ0HPcpiWc74efqQmcZGbwLSCGDxYu1KFdvvYGfYWw+ZR2oaY AF4SVTuuea/v7lnY5NdEtIJtPheWfTu3CPB7zdJQZdFlwPnq1viOtaVGm7VsffuTN9ed By+l1+zYryCd4eTd4Vg9E7VHVE/boT7JgHaiue42yTHJr1JCEnnqwNZKf9gAOPvztSm3 l5eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 j25si3623855jaj.93.2021.07.08.16.17.19; Thu, 08 Jul 2021 16:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230505AbhGHXT3 (ORCPT + 99 others); Thu, 8 Jul 2021 19:19:29 -0400 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:52532 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbhGHXT3 (ORCPT ); Thu, 8 Jul 2021 19:19:29 -0400 Received: from dread.disaster.area (pa49-181-34-10.pa.nsw.optusnet.com.au [49.181.34.10]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 077191044DD7; Fri, 9 Jul 2021 09:16:42 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1m1dG5-004Kod-Un; Fri, 09 Jul 2021 09:16:41 +1000 Date: Fri, 9 Jul 2021 09:16:41 +1000 From: Dave Chinner To: "Darrick J. Wong" Cc: "ruansy.fnst@fujitsu.com" , "dan.j.williams@intel.com" , "hch@lst.de" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "nvdimm@lists.linux.dev" , "linux-xfs@vger.kernel.org" , "rgoldwyn@suse.de" , "viro@zeniv.linux.org.uk" , "willy@infradead.org" Subject: Re: [PATCH v6.1 6/7] fs/xfs: Handle CoW for fsdax write() path Message-ID: <20210708231641.GQ664593@dread.disaster.area> References: <20210615072147.73852-1-ruansy.fnst@fujitsu.com> <20210625221855.GG13784@locust> <20210628050919.GL13784@locust> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210628050919.GL13784@locust> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=Tu+Yewfh c=1 sm=1 tr=0 a=hdaoRb6WoHYrV466vVKEyw==:117 a=hdaoRb6WoHYrV466vVKEyw==:17 a=kj9zAlcOel0A:10 a=e_q4qTt1xDgA:10 a=7-415B0cAAAA:8 a=_EmLEX5E1_FSfXe-uIgA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 27, 2021 at 10:09:19PM -0700, Darrick J. Wong wrote: > > > I had imagined that you'd create a struct dax_iomap_ops to wrap all the extra > > > functionality that you need for dax operations: > > > > > > struct dax_iomap_ops { > > > struct iomap_ops iomap_ops; > > > > > > int (*end_io)(inode, pos, length...); > > > }; > > > > > > And alter the four functions that you need to take the special dax_iomap_ops. > > > I guess the downside is that this makes iomap_truncate_page and > > > iomap_zero_range more complicated, but maybe it's just time to split those into > > > DAX-specific versions. Then we'd be rid of the cross-links betwee > > > fs/iomap/buffered-io.c and fs/dax.c. > > > > This seems to be a better solution. I'll try in this way. Thanks for your guidance. > > I started writing on Friday a patchset to apply this style cleanup both > to the directio and dax paths. The cleanups were pretty straightforward > until I started reading the dax code paths again and realized that file > writes still have the weird behavior of mapping extents into a file, > zeroing them, then issuing the actual write to the extent. IOWs, a > double-write to avoid exposing stale contents if crash. > > Apparently the reason for this was that dax (at least 6 years ago) had > no concept paralleling the page lock, so it was necessary to do that to > avoid page fault handlers racing to map pfns into the file mapping? > That would seem to prevent us from doing the more standard behavior of > allocate unwritten, write data, convert mapping... but is that still the > case? Or can we get rid of this bad quirk? Yeah, so that was the deciding factor in getting rid of unwritten extent allocation in DAX similar to the DIO path. However, we were already considering getting rid of it for another reason: write performance. That is, doing two extent tree manipulation transactions per write is way more expensive than the double memory write for small IOs. IIRC, for small writes (4kB) the double memroy write version we now have was 2-3x faster than the {unwritten allocation, write, convert} algorithm we had originally. I don't think we want to go back to the unwritten allocation behaviour - it sucked when it was first done because all DAX write IO is synchronous, and it will still suck now because DAX writes are still synchronous. What we really want to do here is copy the data into the new extent before we commit the allocation transaction.... Cheers, Dave. -- Dave Chinner david@fromorbit.com