Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp288479ybk; Tue, 19 May 2020 22:59:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZdWG5ga7QoObRIkN8gow0LQWXJ0vM8L1PGaYGuxjOZ3+ZNsnX3il9JTNNA+OdPzDTc0b7 X-Received: by 2002:a50:eb84:: with SMTP id y4mr1851539edr.374.1589954368792; Tue, 19 May 2020 22:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589954368; cv=none; d=google.com; s=arc-20160816; b=Psgpy1oxsFvofA0b6YPN21mdqmQmD0XCbyG8byJF69JXgqRTPpJIYQII3XecWDL/5/ 4L5lM9I9xUXpmYxgXpi5BmEHSqRMkfLRShqV5DI/87AOh/auJK4drsqTTIm7Jwj8k1LB UHm4ktLrXwgT6m71XDINxVdDyTEbHlBhEm8hYD3ET5zPaL9DrOV8Z5O/0E703fg+sS8Y wShCwNq96AiFSgqrtrT+pesi2mlp/OX/9KeY/1rP+iqw/7NxnxvSJ+lTLFopybkjFcn1 F/c2ESq+gmDMZNANyPqh/PrjSsjHHHAxXtgCp22eWOtbKFHQIr52ZcA8P8AwebZ83XUJ gi4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=+d0cf+RtJxjgt5FzagjYFRyM7Ep/4HRLih+Z2kN3dWw=; b=RWP1wLzJrnWQF28MHW0tJc2GDVGPmPSeSlVH7UEAPFiDE+FKWJzFI9ReKxP4wEbiM/ jMhd6worVXCN92ykHIEDaTcYEbPyxJr/GsUXHo+8IRetDYibT/8s7z+LuVmnLDoFSbOA CCWSxHhXrBbgXrCfvvVnSkR0/Ib1m7IEG2cH4ZxQjVdgCBLQBt7so/Nsum2Pw0cvbF8u yrgc7qI/mfC+jNLYOgtyRfgFLXeIpVpUFoUq24I9s5dNG0TetL/C0Z4HOUbV6SrYNXR5 UddcfyijIslO5zzOVikl7HclIT2Ff8MzR5eeCgXPoVBaFz7ry6+fHR8T2G3DDO0kypgi /+bw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si882005edm.150.2020.05.19.22.59.06; Tue, 19 May 2020 22:59:28 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726686AbgETF6Y (ORCPT + 99 others); Wed, 20 May 2020 01:58:24 -0400 Received: from mga12.intel.com ([192.55.52.136]:45474 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbgETF56 (ORCPT ); Wed, 20 May 2020 01:57:58 -0400 IronPort-SDR: Dn9h9oEhqvhDabgPxTk8lf+CHPLnHmtPC/d0mVIbaEQQvd2pWU+UyAO1wt+6RHQrdM9B3CbMbS IqjxJhZNpHPA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2020 22:57:58 -0700 IronPort-SDR: KgbEhjUgj8kw7MVvj69BzgV2Mw0aoLrQGRqkBwhmd5CDjt+VJHg/2uSoNOm2lyQz5IdgLGibGE oyQ4IYirqBaw== X-IronPort-AV: E=Sophos;i="5.73,412,1583222400"; d="scan'208";a="343387852" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2020 22:57:57 -0700 From: ira.weiny@intel.com To: linux-ext4@vger.kernel.org, Andreas Dilger , "Theodore Y. Ts'o" , Jan Kara , Eric Biggers Cc: Ira Weiny , Al Viro , Dan Williams , Dave Chinner , Christoph Hellwig , Jeff Moyer , "Darrick J. Wong" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 4/8] fs/ext4: Update ext4_should_use_dax() Date: Tue, 19 May 2020 22:57:49 -0700 Message-Id: <20200520055753.3733520-5-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200520055753.3733520-1-ira.weiny@intel.com> References: <20200520055753.3733520-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- Changes from RFC Change function name to 'should enable' Clean up bool conversion Reorder this for better bisect-ability --- fs/ext4/inode.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index a10ff12194db..d3a4c2ed7a1c 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4398,10 +4398,8 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc) !ext4_test_inode_state(inode, EXT4_STATE_XATTR)); } -static bool ext4_should_use_dax(struct inode *inode) +static bool ext4_should_enable_dax(struct inode *inode) { - if (!test_opt(inode->i_sb, DAX_ALWAYS)) - return false; if (!S_ISREG(inode->i_mode)) return false; if (ext4_should_journal_data(inode)) @@ -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; } void ext4_set_inode_flags(struct inode *inode) @@ -4430,7 +4434,7 @@ void ext4_set_inode_flags(struct inode *inode) new_fl |= S_NOATIME; if (flags & EXT4_DIRSYNC_FL) new_fl |= S_DIRSYNC; - if (ext4_should_use_dax(inode)) + if (ext4_should_enable_dax(inode)) new_fl |= S_DAX; if (flags & EXT4_ENCRYPT_FL) new_fl |= S_ENCRYPTED; -- 2.25.1