Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp264680ybk; Tue, 12 May 2020 22:45:29 -0700 (PDT) X-Google-Smtp-Source: APiQypJ90dxR3or24VNQpFBQWbPh+wm2UW9rSIFw10pDk2gqx3zRwI7deLXhyWkPUQgCIfeTJeX0 X-Received: by 2002:a50:c016:: with SMTP id r22mr19930510edb.388.1589348729247; Tue, 12 May 2020 22:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589348729; cv=none; d=google.com; s=arc-20160816; b=ytb2V6k1ATM8jUoF6pHmd5eyep7kYxPc7ymLZblAkK15tKjnVgIA/u5fb/Va0TKfRY J12L/ZrX6FziNuUxCUiZ3cRDdUu8eu+lNJFMGOZXK1RyLNAqRDp3rf/N5HXIpIWE/2Fv bbktd8kLkicS1+hAnVg7aaGqf+058iyKz8wIy5l7x+R2p+vrrUb6T3rIEJUTGNzpdiuJ YntealxhKF4Qb+46QW+wNMU/PSXjP8/gF2s4LnsR2TGsB5g0qBPwvYsn0EcEEInodZ/O S9qGWGYkYIwRaIvYGUT2s/g4rKfoyw7wu9R2j4AoAZfgaFB/LyZJN44VT5XGpYfgGFhN spRg== 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=hg2ZzCqjSA6f2R7UT0cOv/e6RZC1LofQTTb4Iyc12ho=; b=rjf9FpZCf3khsAGxDT+g3lDks3gpl5SAattkEqBqrzXDpjeU3jnTE0ZhrGMiQQJ4yt 3RegN6v6vmcPBRPwslkOBNuIu9f7tkfr146Ij8pTF8199mLo/UGdU2elKp8+2yRim/GC GNda/uHP1hrvDTv142+Wyv09gs+5yE9DFLLvXT3OozWngwifS3TZryT6Dmyi9jElfSCI nEVv4YyXDXp0ZoR4LoaIX2RdS8sE7rdIfZ/+xnPuhdFPiMKKqWNWPwyUDUF+NzNcoljC JzWvunSaOMehpslxaRHLzjBVUCj4deKvFcBPO9aV42mu5Z/furAiIlkxfuTvDd7HtcQy 0Umw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 z15si7932588ede.558.2020.05.12.22.45.06; Tue, 12 May 2020 22:45:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1729199AbgEMFni (ORCPT + 99 others); Wed, 13 May 2020 01:43:38 -0400 Received: from mga06.intel.com ([134.134.136.31]:12649 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729110AbgEMFnc (ORCPT ); Wed, 13 May 2020 01:43:32 -0400 IronPort-SDR: 9DzJvz15vmmGQ1y2ZW6dPqLy63XHc9Acc2c2SlzHBHcHHTodhPetilDdYsLULvpCBxvKKancEn 4tcWc/RGwr2g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2020 22:43:32 -0700 IronPort-SDR: QfxkYo4zwnuMogo2fCMzvUmopRKFineXUbiWeReeij6rUJuy8UhOkp2D+8ZIjVbdEhHqXBrR3A sKoeVD9gmiGQ== X-IronPort-AV: E=Sophos;i="5.73,386,1583222400"; d="scan'208";a="280386428" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2020 22:43:31 -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 5/9] fs/ext4: Update ext4_should_use_dax() Date: Tue, 12 May 2020 22:43:20 -0700 Message-Id: <20200513054324.2138483-6-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200513054324.2138483-1-ira.weiny@intel.com> References: <20200513054324.2138483-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. 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