Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7257564ybp; Wed, 16 Oct 2019 06:13:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGVtH6xBvf/fo9OiV706mMyz7UXGzdB599EPjXm3I+1dAxebH+l8+5RD0+NC/D2/aDBVd7 X-Received: by 2002:a05:6402:2028:: with SMTP id ay8mr38960586edb.273.1571231616771; Wed, 16 Oct 2019 06:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571231616; cv=none; d=google.com; s=arc-20160816; b=sRPX6D3ohuT5sv8dHHYI94pFq8C9g0VDhJb5kMZwkqX9TTHuk1v/ojPcHTTwxS5AVn Jc9ZX5RjX7GShtDqIOs4VxJ49g5v/5o1AJ85Jg2QCDM2Sn3I+X5uVydqOlMNcUKi6di3 z3FT1DhXi1n9tf2fnKcXSmdgeaoCG0Kv/lbfHqmdhCCBEJadMdxL3ne892gw3vR/WR6Q pzLkNDSOZXglTfnr93IWadulmjC53UIjbxUK3dFtUOxlkzginmtljtPCLzdPWnk/ZBaZ bD9YXNrdPZ9GDDWcLGy2kqGNVAxW0hWW0pBK2/xIlFxnwyY1rD5LmryajDeJhQV+1x6U MMeg== 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=IS0WqbjbwpqnftFjsLUgyEPWP2A9y5rAel7UJVR4tUw=; b=lHn15n+w2C4l6EYrtYpg1diWEdvs6IgdjFSoB0JM928IxHsCumG6JbLAitDxTvPCWk MWHEuWVRHYpNVtyalBr1RYUMd/OLQf402PA0mvNa8/Pa05HyjwAl0Ii1FMOGas/2w99N tEuyMNNa782z+LQUtBMdyjrClG759sKjL7qrPD4WXGJnQ9vIt+VaTLbeWIFWKZrIVm3N 5v8B1DfUfhVMS8ZlKFZUy54zCZY3nniD7H/7RThaTqM4YvRGhEeBulHA2uUp+rzcZiyY eaKg0FRZN1aGz+vo57tOxp5EuFN+APnthHHBI6+GqzxlHee5K8gfUz9DsFuIpHA/ExrX HsDg== 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 v13si15568246edy.441.2019.10.16.06.13.07; Wed, 16 Oct 2019 06:13:36 -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 S1727496AbfJPIqN (ORCPT + 99 others); Wed, 16 Oct 2019 04:46:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:50028 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726640AbfJPIqN (ORCPT ); Wed, 16 Oct 2019 04:46:13 -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 7E765B165; Wed, 16 Oct 2019 08:46:11 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 36B371E3BDE; Wed, 16 Oct 2019 10:46:11 +0200 (CEST) Date: Wed, 16 Oct 2019 10:46:11 +0200 From: Jan Kara To: Ritesh Harjani Cc: linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca, jack@suse.cz, tytso@mit.edu, mbobrowski@mbobrowski.org, linux-fsdevel@vger.kernel.org Subject: Re: [RFC 2/2] ext4: Move ext4_fiemap to iomap infrastructure Message-ID: <20191016084611.GB30337@quack2.suse.cz> References: <20190820130634.25954-1-riteshh@linux.ibm.com> <20190820130634.25954-3-riteshh@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190820130634.25954-3-riteshh@linux.ibm.com> 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 20-08-19 18:36:34, Ritesh Harjani wrote: > This moves ext4_fiemap to use iomap infrastructure. > > Signed-off-by: Ritesh Harjani Thanks for the patch. I like how it removes lots of code :) The patch looks good to me, just two small comments below. Feel free to add: Reviewed-by: Jan Kara > +static int ext4_xattr_iomap_fiemap(struct inode *inode, struct iomap *iomap) > { > - __u64 physical = 0; > - __u64 length; > - __u32 flags = FIEMAP_EXTENT_LAST; > + u64 physical = 0; > + u64 length; > int blockbits = inode->i_sb->s_blocksize_bits; > - int error = 0; > + int ret = 0; > > /* in-inode? */ > if (ext4_test_inode_state(inode, EXT4_STATE_XATTR)) { > struct ext4_iloc iloc; > - int offset; /* offset of xattr in inode */ > + int offset; /* offset of xattr in inode */ > > - error = ext4_get_inode_loc(inode, &iloc); > - if (error) > - return error; > + ret = ext4_get_inode_loc(inode, &iloc); > + if (ret) > + goto out; > physical = (__u64)iloc.bh->b_blocknr << blockbits; > offset = EXT4_GOOD_OLD_INODE_SIZE + > EXT4_I(inode)->i_extra_isize; Hum, I see you've just copied this from the old code but this actually won't give full information for FIEMAP of inode with extended attribute inodes. Not something you need to fix for your patch but I wanted to mention this so that it doesn't get lost. > physical += offset; > length = EXT4_SB(inode->i_sb)->s_inode_size - offset; > - flags |= FIEMAP_EXTENT_DATA_INLINE; > brelse(iloc.bh); > } else { /* external block */ > physical = (__u64)EXT4_I(inode)->i_file_acl << blockbits; > length = inode->i_sb->s_blocksize; > } > > - if (physical) > - error = fiemap_fill_next_extent(fieinfo, 0, physical, > - length, flags); > - return (error < 0 ? error : 0); > + iomap->addr = physical; > + iomap->offset = 0; > + iomap->length = length; > + iomap->type = IOMAP_INLINE; > + iomap->flags = 0; > +out: > + return ret; > } ... > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index d6a34214e9df..92705e99e07c 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -3581,15 +3581,24 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length, > iomap->type = delalloc ? IOMAP_DELALLOC : IOMAP_HOLE; > iomap->addr = IOMAP_NULL_ADDR; > } else { > - if (map.m_flags & EXT4_MAP_MAPPED) { > - iomap->type = IOMAP_MAPPED; > - } else if (map.m_flags & EXT4_MAP_UNWRITTEN) { > + /* > + * There can be a case where map.m_flags may > + * have both EXT4_MAP_UNWRITTEN & EXT4_MAP_MERGED > + * set. This is when we do fallocate first and > + * then try to write to that area, then it may have > + * both flags set. So check for unwritten first. > + */ > + if (map.m_flags & EXT4_MAP_UNWRITTEN) { > iomap->type = IOMAP_UNWRITTEN; > + } else if (map.m_flags & EXT4_MAP_MAPPED) { > + iomap->type = IOMAP_MAPPED; This should be already part of Matthew's series so once you rebase on top of it, you can just drop this hunk. Honza -- Jan Kara SUSE Labs, CR