Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp928646ybb; Wed, 8 Apr 2020 12:43:38 -0700 (PDT) X-Google-Smtp-Source: APiQypJwHkztg4+hbVdixWKOK/z6fmVXSkqzXyHgxSgAGmtpb/2M39JPhByRmc6ZHQjFxyOk9Ejx X-Received: by 2002:a9d:7282:: with SMTP id t2mr6881590otj.302.1586375018376; Wed, 08 Apr 2020 12:43:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586375018; cv=none; d=google.com; s=arc-20160816; b=UCdsd7rWSkUv1V1mWbOksFT9yuLNWvgmY1PRnjaEhNnodow2rHAoy4s5smdT9dBLY0 Ox5pRh8JMZt/GTEwMANppkDuchgthxyfJZTqNzGxTKDG3qa3pVXW51HlbFJ86Bx5ux87 JAsa4uzEZe2lzwJPsbW4ymyfT30QOtnjy05pARpNU5C3+QJsqHXGyRoB+EcM39rdt2hj H02h5dsYMH5n3U+TPJzHfbA34m/MbSSL/CHZ0Yza758dKM8W6zqJe/+75riDiKrO/xoH /tuBDsmyxf/HFw35gatHMKGIiAaoVSHycL8Yj9EpnsVaBkTLzKrvezm8PrhU8m8zxWFA MVmg== 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:ironport-sdr:ironport-sdr; bh=k6zwRxQ2NUFCaGy2Zi9qzuXuUr3+WK8G2FBFv3ina7U=; b=TycUnGp8MQ80eUytdQEBWZX8StpZOInA8L+nP2nXvOi5i3+6DfYM2gEEuB9xLA/UbZ rTNFe5tU49LLO3JdDjsNSaHpREZkDtjBX99v5YhgmXCT3MevrAPxddL9O3kSqPrvRT7y NidL0voIkil3lMZ/zknKaVGYqxiTl9exPGoKdDGKtAz8+RjFaE7LbbTrlsdSd8BE4HRo OXohVkFf4f/ql4tdLSzNkE/KqhFgQn7rp7box+24HFaLTv9bv23eMwV7fMBYkKCdLpbX VFdoyiC4XTWOBNaFteczMinsQrXDOWxUnLsyEHZ9pbYX2rsPYfxLO7rPZVPZP8IweMhC RbdQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16si3121402oth.230.2020.04.08.12.43.26; Wed, 08 Apr 2020 12:43: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727800AbgDHRJY (ORCPT + 99 others); Wed, 8 Apr 2020 13:09:24 -0400 Received: from mga17.intel.com ([192.55.52.151]:50387 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbgDHRJY (ORCPT ); Wed, 8 Apr 2020 13:09:24 -0400 IronPort-SDR: U5mznCRFcfPbM/uKWSi0ZLOzktDhS9K8jNQyxmSk1o3q9eQJDMdC5CdPUGr29bA5GbLcrhXt1z /Vr+yMkNxuNw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2020 10:09:24 -0700 IronPort-SDR: YzStcBYNyg4rM2NCqyMoWrdbPIx41Hz7AvtD2FHxf/oLSnxNIkoE7Lh+X2uMhDlywMDPL9gAGi LVNM72pCv2xw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,359,1580803200"; d="scan'208";a="297289595" Received: from iweiny-desk2.sc.intel.com ([10.3.52.147]) by FMSMGA003.fm.intel.com with ESMTP; 08 Apr 2020 10:09:24 -0700 Date: Wed, 8 Apr 2020 10:09:23 -0700 From: Ira Weiny To: Dave Chinner Cc: linux-kernel@vger.kernel.org, "Darrick J. Wong" , Dan Williams , Christoph Hellwig , "Theodore Y. Ts'o" , Jan Kara , Jeff Moyer , linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH V6 6/8] fs/xfs: Combine xfs_diflags_to_linux() and xfs_diflags_to_iflags() Message-ID: <20200408170923.GC569068@iweiny-DESK2.sc.intel.com> References: <20200407182958.568475-1-ira.weiny@intel.com> <20200407182958.568475-7-ira.weiny@intel.com> <20200408020827.GI24067@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200408020827.GI24067@dread.disaster.area> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Apr 08, 2020 at 12:08:27PM +1000, Dave Chinner wrote: > On Tue, Apr 07, 2020 at 11:29:56AM -0700, ira.weiny@intel.com wrote: > > From: Ira Weiny [snip] > > > > -STATIC void > > -xfs_diflags_to_linux( > > - struct xfs_inode *ip) > > -{ > > - struct inode *inode = VFS_I(ip); > > - unsigned int xflags = xfs_ip2xflags(ip); > > - > > - if (xflags & FS_XFLAG_IMMUTABLE) > > - inode->i_flags |= S_IMMUTABLE; > > - else > > - inode->i_flags &= ~S_IMMUTABLE; > > - if (xflags & FS_XFLAG_APPEND) > > - inode->i_flags |= S_APPEND; > > - else > > - inode->i_flags &= ~S_APPEND; > > - if (xflags & FS_XFLAG_SYNC) > > - inode->i_flags |= S_SYNC; > > - else > > - inode->i_flags &= ~S_SYNC; > > - if (xflags & FS_XFLAG_NOATIME) > > - inode->i_flags |= S_NOATIME; > > - else > > - inode->i_flags &= ~S_NOATIME; > > -#if 0 /* disabled until the flag switching races are sorted out */ > > - if (xflags & FS_XFLAG_DAX) > > - inode->i_flags |= S_DAX; > > - else > > - inode->i_flags &= ~S_DAX; > > -#endif > > So this variant will set the flag in the inode if the disk inode > flag is set, otherwise it will clear it. It does it with if/else > branches. > > > > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c > > index e07f7b641226..a4ac8568c8c7 100644 > > --- a/fs/xfs/xfs_iops.c > > +++ b/fs/xfs/xfs_iops.c > > @@ -1259,7 +1259,7 @@ xfs_inode_supports_dax( > > return xfs_inode_buftarg(ip)->bt_daxdev != NULL; > > } > > > > -STATIC bool > > +static bool > > xfs_inode_enable_dax( > > struct xfs_inode *ip) > > { > > This belongs in the previous patch. Ah yea... Sorry. Fixed in V7 > > > @@ -1272,26 +1272,38 @@ xfs_inode_enable_dax( > > return false; > > } > > > > -STATIC void > > +void > > xfs_diflags_to_iflags( > > - struct inode *inode, > > - struct xfs_inode *ip) > > + struct xfs_inode *ip, > > + bool init) > > { > > - uint16_t flags = ip->i_d.di_flags; > > - > > - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND | S_SYNC | > > - S_NOATIME | S_DAX); > > And this code cleared all the flags in the inode first, then > set them if the disk inode flag is set. This does not require > branches, resulting in more readable code and better code > generation. > > > + struct inode *inode = VFS_I(ip); > > + uint diflags = xfs_ip2xflags(ip); > > > > - if (flags & XFS_DIFLAG_IMMUTABLE) > > + if (diflags & FS_XFLAG_IMMUTABLE) > > inode->i_flags |= S_IMMUTABLE; > > - if (flags & XFS_DIFLAG_APPEND) > > + else > > + inode->i_flags &= ~S_IMMUTABLE; > > > + if (diflags & FS_XFLAG_APPEND) > > inode->i_flags |= S_APPEND; > > - if (flags & XFS_DIFLAG_SYNC) > > + else > > + inode->i_flags &= ~S_APPEND; > > + if (diflags & FS_XFLAG_SYNC) > > inode->i_flags |= S_SYNC; > > - if (flags & XFS_DIFLAG_NOATIME) > > + else > > + inode->i_flags &= ~S_SYNC; > > + if (diflags & FS_XFLAG_NOATIME) > > inode->i_flags |= S_NOATIME; > > - if (xfs_inode_enable_dax(ip)) > > - inode->i_flags |= S_DAX; > > + else > > + inode->i_flags &= ~S_NOATIME; > > + > > + /* Only toggle the dax flag when initializing */ > > + if (init) { > > + if (xfs_inode_enable_dax(ip)) > > + inode->i_flags |= S_DAX; > > + else > > + inode->i_flags &= ~S_DAX; > > + } > > } > > IOWs, this: > > struct inode *inode = VFS_I(ip); > unsigned int xflags = xfs_ip2xflags(ip); > unsigned int flags = 0; > > if (xflags & FS_XFLAG_IMMUTABLE) > flags |= S_IMMUTABLE; > if (xflags & FS_XFLAG_APPEND) > flags |= S_APPEND; > if (xflags & FS_XFLAG_SYNC) > flags |= S_SYNC; > if (xflags & FS_XFLAG_NOATIME) > flags |= S_NOATIME; > if ((xflags & FS_XFLAG_DAX) && init) > flags |= S_DAX; > > inode->i_flags &= ~(S_IMMUTABLE | S_APPEND | S_SYNC | S_NOATIME); > inode->i_flags |= flags; > > ends up being much easier to read and results in better code > generation. And we don't need to clear the S_DAX flag when "init" is > set, because we are starting from an inode that has no flags set > (because init!)... This sounds good but I think we need a slight modification to make the function equivalent in functionality. void xfs_diflags_to_iflags( struct xfs_inode *ip, bool init) { struct inode *inode = VFS_I(ip); unsigned int xflags = xfs_ip2xflags(ip); unsigned int flags = 0; inode->i_flags &= ~(S_IMMUTABLE | S_APPEND | S_SYNC | S_NOATIME | S_DAX); if (xflags & FS_XFLAG_IMMUTABLE) flags |= S_IMMUTABLE; if (xflags & FS_XFLAG_APPEND) flags |= S_APPEND; if (xflags & FS_XFLAG_SYNC) flags |= S_SYNC; if (xflags & FS_XFLAG_NOATIME) flags |= S_NOATIME; if (init && xfs_inode_enable_dax(ip)) flags |= S_DAX; inode->i_flags |= flags; } I've queued this for v7. Thanks, Ira > > Cheers, > > Dave. > -- > Dave Chinner > david@fromorbit.com