Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4463484ybg; Mon, 21 Oct 2019 09:22:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5dZOay3tltERiLjaJ8QJxa7j2obuMJUp/IrhO+XvoM/o+WsZXv1uuRY87D707anOGMx7E X-Received: by 2002:a50:f701:: with SMTP id g1mr25769078edn.62.1571674943618; Mon, 21 Oct 2019 09:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571674943; cv=none; d=google.com; s=arc-20160816; b=HIoxKHlridSBiX7L72K+XE1NuGJ6R0VxPC+CfeDfDM+xBr99JsckmuDwH40BB+unOl B7QZd+LAl3xMxTDBJ02508C8dJn6efnrHZ26eoN4pM/IfyTxuZtv0ukQSpyrSYGTp2FP 7/Nv+/3F1k0yUlD/vs+TdfekXTqShV6MUKyq8YL4P6gO4F1BdadE1AZdWM76tMeb80Tw 4bIehwelIW29KLDa4AQ+ueMcMlq1jKJgcYN5iVqko4vE+1sK8E+gDc8yfjKF2Zj72YM/ vC8sib1J+NIYVMcGWcljr2KXZBmZDltN1kbCmpVnWKB+ERtru7TW9K7Al+GCsV3B3qHo ihUw== 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; bh=aLC+dkeaSoXOJAX4rf+NCipsOU4GrS1baG8h+JjqQkM=; b=gPyFsztVUQnftPqaUS082CDbfZ23ASrVjdDlvZwsExiCP/BzcIwQHSr5m8LdfjBaQ6 TJeCaFbSaqoSD9ABf2+Zl+jRADoyJ7aupl4kUGU7kX/BogkyyPFuv7AhT+lWnc56RafH fKnWE5KCf7nj9Gj1Yx+P/nuY4mqXMt2QiikHChSoTkBSKx+AAPY/6TXOkEFGP6/84CCp vpHQyfLIwAfPxqNjxdwiy9m0yfjmI7K/VIhu7WY3yiyg2SLeOqcFkQ/pNLl5pKEdhLZM Zdxbwao7zcqSIJDGa/Xnx3sQHuq3tdcRtXMSPJtRaOD/LCwb7jrO6BEOkPt9+PhxFSXp wAkg== ARC-Authentication-Results: i=1; mx.google.com; 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 ni5si8655950ejb.184.2019.10.21.09.21.58; Mon, 21 Oct 2019 09:22:23 -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; 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 S1728589AbfJUQSw (ORCPT + 99 others); Mon, 21 Oct 2019 12:18:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:39986 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728521AbfJUQSw (ORCPT ); Mon, 21 Oct 2019 12:18:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 65BC2AC48; Mon, 21 Oct 2019 16:18:49 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 93DD61E4AA2; Mon, 21 Oct 2019 18:18:48 +0200 (CEST) Date: Mon, 21 Oct 2019 18:18:48 +0200 From: Jan Kara To: Matthew Bobrowski Cc: tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@infradead.org, david@fromorbit.com, darrick.wong@oracle.com Subject: Re: [PATCH v5 12/12] ext4: introduce direct I/O write using iomap infrastructure Message-ID: <20191021161848.GI25184@quack2.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon 21-10-19 20:20:20, Matthew Bobrowski wrote: > This patch introduces a new direct I/O write path which makes use of > the iomap infrastructure. > > All direct I/O writes are now passed from the ->write_iter() callback > through to the new direct I/O handler ext4_dio_write_iter(). This > function is responsible for calling into the iomap infrastructure via > iomap_dio_rw(). > > Code snippets from the existing direct I/O write code within > ext4_file_write_iter() such as, checking whether the I/O request is > unaligned asynchronous I/O, or whether the write will result in an > overwrite have effectively been moved out and into the new direct I/O > ->write_iter() handler. > > The block mapping flags that are eventually passed down to > ext4_map_blocks() from the *_get_block_*() suite of routines have been > taken out and introduced within ext4_iomap_alloc(). > > For inode extension cases, ext4_handle_inode_extension() is > effectively the function responsible for performing such metadata > updates. This is called after iomap_dio_rw() has returned so that we > can safely determine whether we need to potentially truncate any > allocated blocks that may have been prepared for this direct I/O > write. We don't perform the inode extension, or truncate operations > from the ->end_io() handler as we don't have the original I/O 'length' > available there. The ->end_io() however is responsible fo converting > allocated unwritten extents to written extents. > > In the instance of a short write, we fallback and complete the > remainder of the I/O using buffered I/O via > ext4_buffered_write_iter(). > > The existing buffer_head direct I/O implementation has been removed as > it's now redundant. > > Signed-off-by: Matthew Bobrowski > --- > fs/ext4/ext4.h | 3 - > fs/ext4/extents.c | 4 +- > fs/ext4/file.c | 236 ++++++++++++++++++-------- > fs/ext4/inode.c | 411 +++++----------------------------------------- > 4 files changed, 207 insertions(+), 447 deletions(-) The patch looks good to me! You can add: Reviewed-by: Jan Kara One nitpick below: > + if (extend) { > + ret = ext4_handle_inode_extension(inode, ret, offset, count); > + > + /* > + * We may have failed to remove the inode from the orphan list > + * in the case that the i_disksize got update due to delalloc > + * writeback while the direct I/O was running. We need to make > + * sure we remove it from the orphan list as if we've > + * prematurely popped it onto the list. > + */ > + if (!list_empty(&EXT4_I(inode)->i_orphan)) { > + handle = ext4_journal_start(inode, EXT4_HT_INODE, 2); > + if (IS_ERR(handle)) { > + ret = PTR_ERR(handle); > + if (inode->i_nlink) > + ext4_orphan_del(NULL, inode); > + goto out; > + } > + > + if (inode->i_nlink) This check can be joined with the list_empty() check above to save us from unnecessarily starting a transaction. Also I was wondering whether it would not make more sense have this orphan handling bit also in ext4_handle_inode_extension(). ext4_dax_write_iter() doesn't strictly need it (as for DAX i_disksize cannot currently change while ext4_dax_write_iter() is running) but it would look more robust to me for the future users and it certainly doesn't hurt ext4_dax_write_iter() case. > + ext4_orphan_del(handle, inode); > + ext4_journal_stop(handle); > + } > + } Honza -- Jan Kara SUSE Labs, CR