Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5528006ybp; Tue, 8 Oct 2019 04:25:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6Y8v1IAA1tJwcbMmHaAW26cNH0OAmozt93bE7FlAZyeVVzu5rKpm2kiYlDJD98hlK45xP X-Received: by 2002:a50:d0d5:: with SMTP id g21mr33691319edf.204.1570533952180; Tue, 08 Oct 2019 04:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570533952; cv=none; d=google.com; s=arc-20160816; b=rg3/wv2Ym7CHI6M7UkPcHtJaPkSqDLogJ83pDkH3USfdr3geQWgyi0dhyfpG1Ige8I jXnNlqDBQPxrxyqWGFFfVb/KWApUyZ9s/fp7xea5z7NrcHFEYzWetn4wWXRuqOjF7MYV 7LOIqdMMOcnhRt62yYNn2EHA06bbU8rFnnNurZBXPc7RxXpWwPg3uPmghLbgeOoGU2o2 Geb1+Naf2qp6C2KAgTf/5uzgBxwBh5SV/ib84/WG9fMtAmxEtVqtc3PYE8cC6mpRajXq gyHQRnGSo8GuXgKkZkV7gKKiFPdzxV2a1laTpW2wHrDbHeuzHWhzstbvarvQJZ4zUtcH DidA== 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=1xe2iHRETCMIlSVVB3fZZq5I/CP4Adq5x/KJeLh1tnM=; b=U40yOTeSTb7Gq66YktedKVPX6ek3Axw84E3WscHULeqjiQbhueqi1HR5CSNKcbMG+i Ie7Tw3SEDrYJAa98sMRFsxE9gceh/jNtF1/SuIbVtL08VLzDsz9cz4Ap8pec1wpJ59oP zM4iegL5roG2PaZuuOnSV84PboBnNHPyQXAuwA7LaySWsCk/yDdV1Sydh5FqfUtBI1rh 1oRNzBKwVD0h+pFkak0/wLce+HuN/8oJRu+y5NKurcVfbspVuqLcHmAcsXqITKqi85Fp nxp3llq7ndP7A5wvVk4YPSlfJy0pcvYgUyULazn6y1v1qlWPn5Q1G3mpR94M4QP9PHm5 heHQ== 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 i3si9548992edq.163.2019.10.08.04.25.20; Tue, 08 Oct 2019 04:25:52 -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 S1730407AbfJHLZO (ORCPT + 99 others); Tue, 8 Oct 2019 07:25:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:36400 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730316AbfJHLZO (ORCPT ); Tue, 8 Oct 2019 07:25:14 -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 A3142B192; Tue, 8 Oct 2019 11:25:12 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 25A111E4827; Tue, 8 Oct 2019 13:25:12 +0200 (CEST) Date: Tue, 8 Oct 2019 13:25:12 +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 v4 5/8] ext4: move inode extension/truncate code out from ->iomap_end() callback Message-ID: <20191008112512.GH5078@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 Thu 03-10-19 21:34:18, Matthew Bobrowski wrote: > In preparation for implementing the iomap direct I/O write path > modifications, the inode extension/truncate code needs to be moved out > from ext4_iomap_end(). For direct I/O, if the current code remained > within ext4_iomap_end() it would behave incorrectly. Updating the > inode size prior to converting unwritten extents to written extents > will potentially allow a racing direct I/O read operation to find > unwritten extents before they've been correctly converted. > > The inode extension/truncate code has been moved out into a new helper > ext4_handle_inode_extension(). This function has been designed so that > it can be used by both DAX and direct I/O paths. > > Signed-off-by: Matthew Bobrowski Looks good to me. Fell free to add: Reviewed-by: Jan Kara Just small nits below: > +static int ext4_handle_inode_extension(struct inode *inode, loff_t offset, > + ssize_t written, size_t count) > +{ > + int ret = 0; I think both the function and callsites may be slightly simpler if you let the function return 'written' or error (not 0 or error). But I'll leave that decision upto you. > + handle_t *handle; > + bool truncate = false; > + u8 blkbits = inode->i_blkbits; > + ext4_lblk_t written_blk, end_blk; > + > + /* > + * Note that EXT4_I(inode)->i_disksize can get extended up to > + * inode->i_size while the IO was running due to writeback of > + * delalloc blocks. But the code in ext4_iomap_alloc() is careful > + * to use zeroed / unwritten extents if this is possible and thus > + * we won't leave uninitialized blocks in a file even if we didn't > + * succeed in writing as much as we planned. > + */ Whitespace damaged here... Honza -- Jan Kara SUSE Labs, CR