Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1293532ybk; Thu, 21 May 2020 03:25:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/nbMw3ElEDMS2CYfHI5K/M9ithOYf+cbo5q/k3iyBIyBnipgCGXoue0dPRCTXV8XGZ2oU X-Received: by 2002:a05:6402:1a23:: with SMTP id be3mr7410181edb.202.1590056731938; Thu, 21 May 2020 03:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590056731; cv=none; d=google.com; s=arc-20160816; b=ri0cZbJcNzQ8l1NurxibDoJpS8apWAUO2BGHIRubJ45EzXMnLd65B5zyjpPc6QIIy6 +0SKN5IQ1i54RPLTBTxWrpIfVlxvkVFO3B4S7QcdlYvmGVCynXkQ8Excm/9VIeGwHSSi AzN3wqukm4yXAOAj29nk5ZGLA3DC+DWbIXq3pRuOXiU4+/9H8bvVyT7XVbUdETkVKEvM vfmtpp8Exalnsg0kobtZFvFtigUIqZ+3tLlMQTsGSA7ZogQkiueGzESG5EwPOZAY0BE2 iwo85fjmNs6rUQU0NtqglVnUSDPqZ71CUTHO16CNSZfMHpbzfJmILCQXsSG9Xr00yeEm Teuw== 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=0Soya7EwJTU2HP93/d4dOAPVcmC5VPTJnkRs5aPjtuo=; b=ge0m1piTlBGSPTP/uZDciMs5/2vMuV7LGRJGmffltNzh+a8bFcSfWACSKCil/p75dB UlIAIx/Hs6MJG4f5lhUViqCD7DHygJou6SXFknuhA8DrJ6YsEz6BHllr12ZAzOVLUS2d gm4/likDYM+VkZOyZSe1rBUiEGv9GLXHiOJ4jwkMZZ7Bm/VPBYI3YRRh4QGqSDb1ROcu GtREYv8ZA4frlyl+VOxeZoohw5WGMxDRitmEc71H4X0kEi6DW5qTlnYRmo7hzHyoMe+l dNMsifRs5bRgLNzm0emxs5hh0rFMDt8CS+VvQaeno4NQEatHlSOS6Ax0UdH/HroIRUyH Luvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si2623627edr.172.2020.05.21.03.24.56; Thu, 21 May 2020 03:25:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728349AbgEUKYh (ORCPT + 99 others); Thu, 21 May 2020 06:24:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:55580 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727009AbgEUKYg (ORCPT ); Thu, 21 May 2020 06:24:36 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D6B51ACC3; Thu, 21 May 2020 10:24:37 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 4AC971E126F; Thu, 21 May 2020 12:24:34 +0200 (CEST) Date: Thu, 21 May 2020 12:24:34 +0200 From: Jan Kara To: Ira Weiny Cc: Jan Kara , linux-ext4@vger.kernel.org, Andreas Dilger , "Theodore Y. Ts'o" , Eric Biggers , Al Viro , Dan Williams , Dave Chinner , Christoph Hellwig , Jeff Moyer , "Darrick J. Wong" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3 4/8] fs/ext4: Update ext4_should_use_dax() Message-ID: <20200521102434.GA17431@quack2.suse.cz> References: <20200520055753.3733520-1-ira.weiny@intel.com> <20200520055753.3733520-5-ira.weiny@intel.com> <20200520133728.GD30597@quack2.suse.cz> <20200520194050.GF3660833@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200520194050.GF3660833@iweiny-DESK2.sc.intel.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 Wed 20-05-20 12:40:50, Ira Weiny wrote: > On Wed, May 20, 2020 at 03:37:28PM +0200, Jan Kara wrote: > > On Tue 19-05-20 22:57:49, ira.weiny@intel.com wrote: > > > From: Ira Weiny > > > > > > S_DAX should only be enabled when the underlying block device supports > > > dax. > > > > > > Change ext4_should_use_dax() to check for device support prior to the > > > over riding mount option. > > > > > > While we are at it change the function to ext4_should_enable_dax() as > > > this better reflects the ask as well as matches xfs. > > > > > > Reviewed-by: Jan Kara > > > Signed-off-by: Ira Weiny > > > > ... > > > > > @@ -4412,7 +4410,13 @@ static bool ext4_should_use_dax(struct inode *inode) > > > return false; > > > if (ext4_test_inode_flag(inode, EXT4_INODE_VERITY)) > > > return false; > > > - return true; > > > + if (!bdev_dax_supported(inode->i_sb->s_bdev, > > > + inode->i_sb->s_blocksize)) > > > + return false; > > > + if (test_opt(inode->i_sb, DAX_ALWAYS)) > > > + return true; > > > + > > > + return false; > > > } > > > > Now that I think about it - shouldn't we rather cache the result of > > bdev_dax_supported() in sb on mount and then just check the flag here? > > Because bdev_dax_supported() isn't exactly cheap (it does a lot of checks > > and mappings, tries to read from the pmem, ...). > > Sounds reasonable. > > Not sure which flags are appropriate. So add it here? Yes, sounds good. Thanks! Honza > > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h > index 1a3daf2d18ef..0b4db9ce7756 100644 > --- a/fs/ext4/ext4.h > +++ b/fs/ext4/ext4.h > @@ -1979,6 +1979,7 @@ static inline bool ext4_has_incompat_features(struct super_block *sb) > */ > #define EXT4_FLAGS_RESIZING 0 > #define EXT4_FLAGS_SHUTDOWN 1 > +#define EXT4_FLAGS_BDEV_IS_DAX 2 > > static inline int ext4_forced_shutdown(struct ext4_sb_info *sbi) > { > -- Jan Kara SUSE Labs, CR