Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5205673ybe; Tue, 17 Sep 2019 04:32:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCMDWb8JU2tZ7MlWBjrlyxbHce2MSZ0gpS8rHmLnSfhTyVhHMKKxXbf+vvE7e8nVc3I3/N X-Received: by 2002:a50:d808:: with SMTP id o8mr4106761edj.74.1568719923994; Tue, 17 Sep 2019 04:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568719923; cv=none; d=google.com; s=arc-20160816; b=Zl7OBlLpi2D8eviAt+fVxzhiGnxju5A8vj/ANS1DerpLbA8o1faIuSsf6u7643+L5S LyCn7IEVd4+xjSNDcj67VMt34D7KQw5faXheW3wK2SOjOap7K2LhZIaQZ5UUH6D3YD/2 8vy+o0x3xp7uPKKSpRi0KrD8QgIESE9ne4nXYOAVPHs85OooEbQgdIZ8BR85zyrY7pQd dHGbJ4ZduJs0fkkxMY8scbPWVwYKf/i9kUUH3kj6PJ6Bdai/sVr/l3b9QUpkXxRD3AK9 9SjqgKWdFyTRNFF5vc216XOqcSIjBTQ+hyxpofpDgPm4fRshGU1NKAbshupLBEs3Bhl9 orXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=haHTGffRW5vANHA+WJrpU6ZKkWIFsJTyKM4HQ48Fqjw=; b=WWIHVTk2K4dje1dd2qHUpN2ioS0QRzs4aYFCJrWAQZyG5LT1gxy2Oy19rICEnaXWEh QFwlVVi0EyqDN37elsqID7BBmEOYE3rf07DUXguHFPrGmEA4ob5W8le6UTxKR7w/Nruy m0VN0OXLIX++WGplCzu8pplYXfUjwEUZfUzNkDpCNHKHPTZKXlMIsLX6kjY84KALy7qa tOJQIpYVYvczsHd8WwiiTaY5PsQ8I0005Ey9LLrFf/3Ch+33FR7z/NDjs37s5wmmbMhk tWaGOo+KlBy1m4rb9bl4RCiLblEHwm4/b9CDM10ew4mJItDxq1d6z6S9QDd3lRaKmKhW AsXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=PDWr0cB7; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb1si864561ejb.112.2019.09.17.04.31.30; Tue, 17 Sep 2019 04:32:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=PDWr0cB7; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726207AbfIQLbP (ORCPT + 99 others); Tue, 17 Sep 2019 07:31:15 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:39965 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726553AbfIQLbO (ORCPT ); Tue, 17 Sep 2019 07:31:14 -0400 Received: by mail-pg1-f194.google.com with SMTP id w10so1865797pgj.7 for ; Tue, 17 Sep 2019 04:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mbobrowski-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=haHTGffRW5vANHA+WJrpU6ZKkWIFsJTyKM4HQ48Fqjw=; b=PDWr0cB7F7xLSAU12jIL5a86NRbxRJxAmhopvAfaaybXfe7oaJkct5DXzdg1AiQpOI fHfpc6PK5Fw2/YAndeXRsbP5t66Ip2pWV6tnCcI0amJRBKmLdTYqOUyLYw0mcFV2A883 zIqpOFWf9yek6jEOCb0EU/B2oVLLnFVUV60OjAie7OFYqKz2PZHS/oXXYAxSxSKpReCI 5dnC8h/cu9wLrTJaSapbYy5KwCsHZBJuiliu8yTkjZCnW7ipuiTEQXJM7wzKpspYXEc6 IrsTuhg1nB0zwQ1Px1p+RCsK9RWPv181MvYf/c1BNUyVAEN5cplWQdOF2IDRmZMgHL1u Cwaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=haHTGffRW5vANHA+WJrpU6ZKkWIFsJTyKM4HQ48Fqjw=; b=SZKQ9h0tyjD0PkpjkI7Ryl43AhsecULngur7n5Z6fNRQqrmeeLLI6eNDVTDuQuNfU3 TalPzQMOZfvpAjTzTvA++JyqzxDD7GpWKstvvgnRpsLqHbD8iRH16o0nWJ+zTzuNBaOb zR39tOBAFjeog37/JeXXfipVaARvPh2CM8PkGGWLg5hGtyQ2uV+cNGslOokLJRTIqYWH 9/X7fDwOYjzJbrwsbQ2E8A5xCZ/A3sUgyNlSuouZARu2gIJCBjCsbm/wUInJU2VdjReY VmsDaVA5069XkFPsxfnFS+udQ5VXsjSFkDwEKE6m3qdc6cb5bkSkYNCP2K2OzVj8H2LF vDwA== X-Gm-Message-State: APjAAAWh/7hpiaFC4bKEqmKeVuS6h00PthftgN8nQfWtSer5W95Ss+qU 5EteYidJbMrrUnte2XpWectY X-Received: by 2002:a17:90a:37d1:: with SMTP id v75mr4472866pjb.33.1568719868394; Tue, 17 Sep 2019 04:31:08 -0700 (PDT) Received: from bobrowski ([110.232.114.101]) by smtp.gmail.com with ESMTPSA id d20sm4411809pfq.88.2019.09.17.04.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2019 04:31:07 -0700 (PDT) Date: Tue, 17 Sep 2019 21:31:01 +1000 From: Matthew Bobrowski To: Christoph Hellwig Cc: tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, david@fromorbit.com, darrick.wong@oracle.com Subject: Re: [PATCH v3 5/6] ext4: introduce direct IO write path using iomap infrastructure Message-ID: <20190917113101.GA17286@bobrowski> References: <20190916121248.GD4005@infradead.org> <20190916223741.GA5936@bobrowski> <20190917090613.GC29487@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190917090613.GC29487@infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Sep 17, 2019 at 02:06:13AM -0700, Christoph Hellwig wrote: > On Tue, Sep 17, 2019 at 08:37:41AM +1000, Matthew Bobrowski wrote: > > > Independent of the error return issue you probably want to split > > > modifying ext4_write_checks into a separate preparation patch. > > > > Providing that there's no objections to introducing a possible performance > > change with this separate preparation patch (overhead of calling > > file_remove_privs/file_update_time twice), then I have no issues in doing so. > > Well, we should avoid calling it twice. But what caught my eye is that > the buffered I/O path also called this function, so we are changing it as > well here. If that actually is safe (I didn't review these bits carefully > and don't know ext4 that well) the overall refactoring of the write > flow might belong into a separate prep patch (that is not relying > on ->direct_IO, the checks changes, etc). Yeah, I see what you're saying. From memory, in order to get this right, there was a whole bunch of additional changes that needed to be done that would effectively be removed in a subsequent patch. But, let me revisit this again and see what I can do. > > > > + if (!inode_trylock(inode)) { > > > > + if (iocb->ki_flags & IOCB_NOWAIT) > > > > + return -EAGAIN; > > > > + inode_lock(inode); > > > > + } > > > > + > > > > + if (!ext4_dio_checks(inode)) { > > > > + inode_unlock(inode); > > > > + /* > > > > + * Fallback to buffered IO if the operation on the > > > > + * inode is not supported by direct IO. > > > > + */ > > > > + return ext4_buffered_write_iter(iocb, from); > > > > > > I think you want to lift the locking into the caller of this function > > > so that you don't have to unlock and relock for the buffered write > > > fallback. > > > > I don't exactly know what you really mean by "lift the locking into the caller > > of this function". I'm interpreting that as moving the inode_unlock() > > operation into ext4_buffered_write_iter(), but I can't see how that would be > > any different from doing it directly here? Wouldn't this also run the risk of > > the locks becoming unbalanced as we'd need to add checks around whether the > > resource is being contended? Maybe I'm misunderstanding something here... > > With that I mean to acquire the inode lock in ext4_file_write_iter > instead of the low-level buffered I/O or direct I/O routines. Oh, I didn't think of that! But yes, that would in fact be nice and I cannot see why we shouldn't be doing that at this point. It also helps with reducing all the code duplication going on in the low-level buffered, direct, dax I/O routines. ----