Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5530268ybp; Tue, 8 Oct 2019 04:28:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvNSQSbVpxVOvMMvExiUo+2VhpUXYAXrK9hE16IAYuT/M1NFe3H3raaZ3AOMhbrzMOZ8Pk X-Received: by 2002:a50:baab:: with SMTP id x40mr33624277ede.60.1570534118977; Tue, 08 Oct 2019 04:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570534118; cv=none; d=google.com; s=arc-20160816; b=Tg23Rvaf1oUs7oePFVpNZLe4bNvB+yhXXMnzhszpYvx1FFSZaFAjSHyn0HM5g27kEy ID7DkmmYnr6veTwcNpGxbqugCnBr2i1GjTZqrda6ecIRIEDIm6yaP6/oULfmhcObo0J8 tZIJ8cm/i/kAmQYxr3On5onKyQC1jYfo8zyLMOWqxA69ltXybmTP0RLaxQl928r/GlAW FAgTHDXKM5uzpU5nr0HsHEZ5AyBGsGHTdokL4CS2b6jXHcNUszlTE+TxJbSrZCdZ4/Pf vJ0gl4waKuBJsVxJcIK1hBr8AE4DD9ECIZZD+zNOHbvi5pMHhBqJaHogQL05zyT/1CmZ dK3g== 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=cMH9xSblsLT7qf0pEKwPUBJURbe8rVMMrY5wBsAtM1c=; b=WpHcfRlVMFCbbIbwagmS1YYL4v/JnEES1BFc+rtd4C2bArcSNazRp3Kn49jsdsm1rd MGN6OmSDI8vag/CK7sm27sYeyDnWQ/0UX1Nai+WktXFa49rWqyuM0SKVfcm4Jd0hk/4S zQWEdVYxadV70my30rcXOODNAe4CUtaXhEbo4fvtGoF1HautbhDyv6pSaNkRhfI/f9Ed 0tc8RGyNyKgYV7hLdo5tNiRKZBQoJOWpvpoBKQnLqL8MqEnU8g8OHwR2/LAv/R8LLlrW nNezIOGV2D+AHiqFqJZb/tthbjjz/eKKtts/YIKxVZLACHl8lnIwyFHgVa5AFTEJ8ynG kc2g== 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 j35si12014728eda.144.2019.10.08.04.28.14; Tue, 08 Oct 2019 04:28:38 -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 S1730649AbfJHL1J (ORCPT + 99 others); Tue, 8 Oct 2019 07:27:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:38226 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730648AbfJHL1J (ORCPT ); Tue, 8 Oct 2019 07:27:09 -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 30797AE35; Tue, 8 Oct 2019 11:27:07 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id E2D341E4827; Tue, 8 Oct 2019 13:27:06 +0200 (CEST) Date: Tue, 8 Oct 2019 13:27:06 +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 6/8] ext4: move inode extension checks out from ext4_iomap_alloc() Message-ID: <20191008112706.GI5078@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:36, Matthew Bobrowski wrote: > We lift the inode extension/orphan list handling logic out from > ext4_iomap_alloc() and place it within the caller > ext4_dax_write_iter(). > > Signed-off-by: Matthew Bobrowski The patch looks good to me. You can add: Reviewed-by: Jan Kara Honza > --- > fs/ext4/file.c | 17 +++++++++++++++++ > fs/ext4/inode.c | 22 ---------------------- > 2 files changed, 17 insertions(+), 22 deletions(-) > > diff --git a/fs/ext4/file.c b/fs/ext4/file.c > index 2883711e8a33..f64da0c590b2 100644 > --- a/fs/ext4/file.c > +++ b/fs/ext4/file.c > @@ -309,6 +309,7 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) > ssize_t ret; > size_t count; > loff_t offset; > + handle_t *handle; > struct inode *inode = file_inode(iocb->ki_filp); > > if (!inode_trylock(inode)) { > @@ -328,6 +329,22 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) > > offset = iocb->ki_pos; > count = iov_iter_count(from); > + > + if (offset + count > EXT4_I(inode)->i_disksize) { > + handle = ext4_journal_start(inode, EXT4_HT_INODE, 2); > + if (IS_ERR(handle)) { > + ret = PTR_ERR(handle); > + goto out; > + } > + > + ret = ext4_orphan_add(handle, inode); > + if (ret) { > + ext4_journal_stop(handle); > + goto out; > + } > + ext4_journal_stop(handle); > + } > + > ret = dax_iomap_rw(iocb, from, &ext4_iomap_ops); > > error = ext4_handle_inode_extension(inode, offset, ret, count); > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index d616062b603e..e133dda55063 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -3508,7 +3508,6 @@ static int ext4_iomap_alloc(struct inode *inode, > struct ext4_map_blocks *map) > { > handle_t *handle; > - u8 blkbits = inode->i_blkbits; > int ret, dio_credits, retries = 0; > > /* > @@ -3530,28 +3529,7 @@ static int ext4_iomap_alloc(struct inode *inode, > return PTR_ERR(handle); > > ret = ext4_map_blocks(handle, inode, map, EXT4_GET_BLOCKS_CREATE_ZERO); > - if (ret < 0) > - goto journal_stop; > > - /* > - * If we have allocated blocks beyond the EOF, we need to make > - * sure that they get truncate if we crash before updating the > - * inode size metadata in ext4_iomap_end(). For faults, we > - * don't need to do that (and cannot due to the orphan list > - * operations needing an inode_lock()). If we happen to > - * instantiate blocks beyond EOF, it is because we race with a > - * truncate operation, which already has added the inode onto > - * the orphan list. > - */ > - if (!(flags & IOMAP_FAULT) && first_block + map->m_len > > - (i_size_read(inode) + (1 << blkbits) - 1) >> blkbits) { > - int err; > - > - err = ext4_orphan_add(handle, inode); > - if (err < 0) > - ret = err; > - } > -journal_stop: > ext4_journal_stop(handle); > if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) > goto retry; > -- > 2.20.1 > -- Jan Kara SUSE Labs, CR