Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1100617ybk; Wed, 13 May 2020 23:54:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9uNRmHjgK+EI283BqYZcIWjOFPru5N3HscPJOXiw7IDFuculfuUWyXPZiIubtmgIm+UgL X-Received: by 2002:a17:906:34c4:: with SMTP id h4mr2504837ejb.167.1589439280465; Wed, 13 May 2020 23:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589439280; cv=none; d=google.com; s=arc-20160816; b=XW8A8A7ZrblrLMAuF4K7IpTZz2dwByK1kaNsw4c9qFSd8sWpJP5yu2p41ICbj8n3ZY mZdyvl1HvbUQELd9hp9M7dWgIXCKv3YwTPXnzw6XDrMoAoqu7GBiLEQ+B04LMHE4B/6C M/WbR7cg4LzLOjd9M445DpR59Ko8JNxUbxE+9qJRyIqOcoKpoXapA4r2PxzrcaueUSDC 6joGGu3vfJY7+dQTwUjEfL3+ITa5b8kFaolRS7zIVGVkiT7OfjFSESS5lnVJD9Q+DDyo 2iY5lDo9xhvQB/gok4EzjMkML2Yo432Ss9PpA6EFpo8i4PQhKqBOYhdox1lkJSmBuNfP /OiQ== 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=OO/IxsmdlS+YKuhweKujjFByH0sDPlYo4d2Rfm7mcUMWqaBSgdFGUc48dzXJXAGTTa fm9iKBB34geTcKLEEeErn175TEeMc+K+v7auvf6vTcSZEf2ZNI502UgqrntLkQV14JU2 fhLxJE41HfGRPdagCc+w4l5A9uQ3hsoNmfmQveg4AkFjQkQgGooyMaFVGzZahOcerbDE C/odiupPib6tbTDpwhEDuG87jTY80T1tykLvx5kU3OXz5X2PHBgpk4yI7z4/XjW+AyDi hh2STIF9pEGDKzygYyUERC3p27/xGlmydn/S3rhwgPwTCOrioeBEFgnjT3yG3hqpVJ/M OHpA== 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 bs2si1154276edb.569.2020.05.13.23.54.17; Wed, 13 May 2020 23:54:40 -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 S1726146AbgENGx0 (ORCPT + 99 others); Thu, 14 May 2020 02:53:26 -0400 Received: from mga04.intel.com ([192.55.52.120]:24927 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbgENGxY (ORCPT ); Thu, 14 May 2020 02:53:24 -0400 IronPort-SDR: r1pG0UOOCtC4N5cn55x3it4Hh5JOhr7uA6dSooHY5pu7oArGCc7bmu+Y8Oc1KXcTSdh4ZKqRh9 18YLzFfau0hQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2020 23:53:22 -0700 IronPort-SDR: hxsPCGPd1MPyROVeAXV7Md/4aufOJQAh21r/UAIa5vJuSEACN9jtGykVEFbZPr91bXj6rPIVWO Hsu3CzdHxEKQ== X-IronPort-AV: E=Sophos;i="5.73,390,1583222400"; d="scan'208";a="253405991" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2020 23:53:22 -0700 From: ira.weiny@intel.com To: linux-ext4@vger.kernel.org, Andreas Dilger , "Theodore Y. Ts'o" , Jan Kara 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 V1 5/9] fs/ext4: Update ext4_should_use_dax() Date: Wed, 13 May 2020 23:53:11 -0700 Message-Id: <20200514065316.2500078-6-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200514065316.2500078-1-ira.weiny@intel.com> References: <20200514065316.2500078-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