Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1903837ybp; Wed, 9 Oct 2019 22:40:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7R43p1JRqXpdFGEXlXA6wHo13IJ+qdhNRroSH8jWifsgk+AvMGIvqH853tgGjme5vC+Ht X-Received: by 2002:a17:906:2c5b:: with SMTP id f27mr6235500ejh.239.1570686009560; Wed, 09 Oct 2019 22:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570686009; cv=none; d=google.com; s=arc-20160816; b=brkp/cBL0QMaquAStUqGabFqCwCm0csJoHI/Uq1ch98XUS+d+Yfsmp2VWcFjl2MBw3 Kvr5l/tmhC4shYdqt7T0dsFJu2qArjz9oXNQ3xpU+ZdtkO0KaDS+vRQrTmKBcZy+tLXN WwOCLddvvtliQCtgBLp5yD0uNFNjYAiVyCzuU7/t5DVlogMimBmFC+auKFH/DvMGkh70 yWMTKrRZ/dPj1loXcddabOK/Euz/3jKlanEzlpzl0cZ0aZF/2o/g4YqkMC41P6Fgc9yM 5YBIBnv6KjsvMtdPP9NF2RjpvL/8XuRHixjzImjoycaDiFNcuFg2t9mPSK3wNnIvXi3L mTKA== 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=CQ8qLkYxE3s0aj/7O2LxSmHAT6SGLjMyMlog3ylNc2I=; b=gO33A/kdHPWHjbAdhS6HXLsKGjvFmabkO3jYXYHt5FCa8LfmMXg/yWwY/3QGMjjFjY SJhxQvBuuAKgXQkXi+mU4KrGpD/nWM2UQRXBWpTBVzx2bhn3S+Wx6useJZ1biglgkjkD viwdMD84Ym0v6wAGKkvw5c9DX4MIvd73cOyuuWJE0Zk9pXQq/b+8Dj3Leh8xGbnq5feU EUmw1iZiKvGsZJOIalXazVtHWy2wrDDupA/lm0okgmrtrjWeoFegcgvAwawAIc8hXZ7G 3OmtSz9lFRFPCR5PxUm/dA7lNB1bUFpK3oWJBLlEi2ImfZBVtddKcQwS6J6/qwHQtH7u Z9pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=nf3VoIsh; 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 re18si2596408ejb.96.2019.10.09.22.39.36; Wed, 09 Oct 2019 22:40:09 -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=nf3VoIsh; 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 S1728822AbfJJFjd (ORCPT + 99 others); Thu, 10 Oct 2019 01:39:33 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46921 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728649AbfJJFjc (ORCPT ); Thu, 10 Oct 2019 01:39:32 -0400 Received: by mail-pf1-f195.google.com with SMTP id q5so3123038pfg.13 for ; Wed, 09 Oct 2019 22:39:32 -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=CQ8qLkYxE3s0aj/7O2LxSmHAT6SGLjMyMlog3ylNc2I=; b=nf3VoIshCTmDpZ0oex/t5ARoB3VgkbQuNWiDByqqqC//+0GDmW/7qKTuiv9Py8F8oO 6+pdWDVOp1zrT9x99x1szhVN2H3SbfQMqRYIQBtK1XzYSy+z/znzKPP7edXgzcDSRNSO AO8CchB7kaot693N5W81/j3mqPT/bR4eqCV1McMLmWdvNsF4tkZ41xmMcWF5xiZkT7Y1 KtTodBivEBrK2f7pehC8jAWkd/+jFVI9H7VF3YbLhrIsLj9pjUXNaWDNMfmgObVJ5W9D BA8yLQUR0AaflJVIpjTHybWJ4XC6bZX6lfVzcsvm+Y4z23r74p5/LzCsnAimeNKhXMAq ruUw== 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=CQ8qLkYxE3s0aj/7O2LxSmHAT6SGLjMyMlog3ylNc2I=; b=sif7Htppf6usxZho3eZm3u7rM3gwN8n9zM4EpXL50vtZ9i0cOoMh3oJeMmbCdsRqdX jvoBEAUnLbwzTWt+x5717j7QCgga7wWj18xHJmD7p9btX9G7BA/TDGF6WkPTIjJLJKOk F3ud4BeZZeXO1m9QPUVZ8gDQE+xrKwPxmBbtSGz52jqSd2pYzZ5bWpQ6qdxNXqSR1Zzp 6t01QraY+DLdNE02aHNAh3FvPHBam97b46su4XRxQasemOKHIjeffh5I3p0bNIfShKTD euqqIFCAV6qcinxOIl6SkgE52S02oY7b/ZGpVlSb5vqKke1Z3TamdHbEk1tep0oxcThg SbpQ== X-Gm-Message-State: APjAAAUX/SNPbCOBhDO+RU5FIb29Pmb1n8sw5zlVwwXfLV+ZrkBVSrpl bCbaew2vKNKQnkSEce8X/vTn X-Received: by 2002:a65:67c8:: with SMTP id b8mr8956182pgs.121.1570685971380; Wed, 09 Oct 2019 22:39:31 -0700 (PDT) Received: from bobrowski ([110.232.114.101]) by smtp.gmail.com with ESMTPSA id u65sm5030390pfu.104.2019.10.09.22.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 22:39:30 -0700 (PDT) Date: Thu, 10 Oct 2019 16:39:24 +1100 From: Matthew Bobrowski To: Jan Kara Cc: tytso@mit.edu, 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 1/8] ext4: move out iomap field population into separate helper Message-ID: <20191010053924.GC19064@bobrowski> References: <8b4499e47bea3841194850e1b3eeb924d87e69a5.1570100361.git.mbobrowski@mbobrowski.org> <20191008102709.GD5078@quack2.suse.cz> <20191009085721.GA1534@poseidon.bobrowski.net> <20191009130609.GD5050@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191009130609.GD5050@quack2.suse.cz> 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 Wed, Oct 09, 2019 at 03:06:09PM +0200, Jan Kara wrote: > On Wed 09-10-19 19:57:23, Matthew Bobrowski wrote: > > On Tue, Oct 08, 2019 at 12:27:09PM +0200, Jan Kara wrote: > > > On Thu 03-10-19 21:33:09, Matthew Bobrowski wrote: > > > > +static int ext4_set_iomap(struct inode *inode, struct iomap *iomap, u16 type, > > > > + unsigned long first_block, struct ext4_map_blocks *map) > > > > +{ > > > > + u8 blkbits = inode->i_blkbits; > > > > + > > > > + iomap->flags = 0; > > > > + if (ext4_inode_datasync_dirty(inode)) > > > > + iomap->flags |= IOMAP_F_DIRTY; > > > > + iomap->bdev = inode->i_sb->s_bdev; > > > > + iomap->dax_dev = EXT4_SB(inode->i_sb)->s_daxdev; > > > > + iomap->offset = (u64) first_block << blkbits; > > > > + iomap->length = (u64) map->m_len << blkbits; > > > > + > > > > + if (type) { > > > > + iomap->type = type; > > > > + 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) { > > > > + iomap->type = IOMAP_UNWRITTEN; > > > > + } else { > > > > + WARN_ON_ONCE(1); > > > > + return -EIO; > > > > + } > > > > + iomap->addr = (u64) map->m_pblk << blkbits; > > > > + } > > > > > > Looking at this function now, the 'type' argument looks a bit weird. Can we > > > perhaps just remove the 'type' argument and change the above to: > > > > We can, but refer to the point below. > > > > > if (map->m_flags & (EXT4_MAP_MAPPED | EXT4_MAP_UNWRITTEN)) { > > > if (map->m_flags & EXT4_MAP_MAPPED) > > > iomap->type = IOMAP_MAPPED; > > > else if (map->m_flags & EXT4_MAP_UNWRITTEN) > > > iomap->type = IOMAP_UNWRITTEN; > > > iomap->addr = (u64) map->m_pblk << blkbits; > > > } else { > > > iomap->type = IOMAP_HOLE; > > > iomap->addr = IOMAP_NULL_ADDR; > > > } > > > > > > And then in ext4_iomap_begin() we overwrite the type to: > > > > > > if (delalloc && iomap->type == IOMAP_HOLE) > > > iomap->type = IOMAP_DELALLOC; > > > > > > That would IMO make ext4_set_iomap() arguments harder to get wrong. > > > > I was thinking about this while doing a bunch of other things at work > > today. I'm kind of aligned with what Christoph mentioned around > > possibly duplicating some of the post 'iomap->type' setting from both > > current and any future ext4_set_iomap() callers. In addition to this, > > my thought was that if we're populating the iomap structure with > > values respectively, then it would make most sense to encapsulate > > those routines, if possible, within the ext4_set_iomap() as that's the > > sole purpose of the function. > > Well, what I dislike about 'type' argument is the inconsistency in it's > handling. It is useful only for HOLE/DELALLOC, anything else will just give > you invalid iomap and you have to be careful to pass 0 in that case. > > I understand the concern about possible duplication but since only > IOMAP_REPORT cares about IOMAP_DELALLOC, I'm not much concerned about it. > But another sensible API would be to optionally pass 'struct extent_status > *es' argument to ext4_set_iomap() and if this argument is non-NULL, > ext4_set_iomap() will handle the intersection of ext4_map_blocks and > extent_status and deduce appropriate resulting type from that. I see and thank you for sharing your view point. Let's go with what you originally proposed, which is dropping the 'type' argument and then handling IOMAP_DELALLOC within ext4_set_iomap(). No real hard objections. :) ----