Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp86425pxh; Tue, 9 Nov 2021 07:42:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIYLyNqrEj3wG805spi2GDe2ySaMYAked16HnKgFH3r1zFdkIX1sgHRoDLvF3RX4dsnTQA X-Received: by 2002:a17:907:97c3:: with SMTP id js3mr10916524ejc.240.1636472544731; Tue, 09 Nov 2021 07:42:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636472544; cv=none; d=google.com; s=arc-20160816; b=mpzOyf/Fpf0Dsz3I/v6nflfVs1rB08A2NdZF9/gzrEQQtVHFQ7qKtqGLmwX4OIxnhc 3udluo8/05z0gyB7y344W/XJnbT+Aj4GP7u/CJc5Zg2xlke3zwnhNHKqocPTJM3TCf8e WhU3Cz9nz1+zHEg3QdtXl0IKy1e1ghPKLZAgBAkICBpjez3dNr7VYG42yMFmyuCw/uNX iH8dotG2qqYYWAgQLiT9/3/iOF/n7Sqqb4ZQFgJk/OiB7b9XSXc1J3sRKT0A7uRiRl7u jmTe6up+i3iLx0T6E66bht62F0oNazhuTjldqdgFj0QWKijruv7ksuGwcg4jc8d7x54U LVJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9DfHXjXpwPV16JwxKDzlwLsQrCaf21dbRLJzYHAhNZM=; b=cDMKX/f0ENzDtLROFU7IfGeKLr11lTzRtN9FpjYGexa3wIthRMJ/Rzmj4xhFhT5oGz cySXceD6qE+gM5cnyH1EmMINJ4PYuNbv67BO6VO675JVMMIn2S39UwfhtxHTER/byV5y bowzj77a94l1CY2mbQ3mtEm07oE9UdGfNDiyzIR415MNcpo6TuHYR3Jar3z5Wo2RDaSR ysRzlTtdCXfzgoX9WNUzaMVNNPZchWVMaQlCmUggq/BplxZUaRPui9TzLFU74lUdwEha p0G8o5vaAbLmpnQQRbYxl2yAULwyjl1myYN3j3x3G2q1cyQSLjAqT+kSQVjYS6sc/OYk mMtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=k+J4p1sx; 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 a3si26551748ejd.290.2021.11.09.07.41.59; Tue, 09 Nov 2021 07:42:24 -0800 (PST) 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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=k+J4p1sx; 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 S244168AbhKIIgY (ORCPT + 99 others); Tue, 9 Nov 2021 03:36:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244161AbhKIIgU (ORCPT ); Tue, 9 Nov 2021 03:36:20 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 328FAC061767; Tue, 9 Nov 2021 00:33:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9DfHXjXpwPV16JwxKDzlwLsQrCaf21dbRLJzYHAhNZM=; b=k+J4p1sxv4GIaf/pZry1mADwB+ Ar1HiQrfR69z+VUk+LXPZwyTUodROP6Ve2JzAJaLMLYKGRK2OL7DDKMIHeGPn3jFxKNlLvXYsyelf TOkCDzO0pNwMWvfo4xkbl6QMwmB+MsxPivzTRf3Y41pDkQ+OnrH5ig+xpkzEFpmu8x16htqod2pJy /G/Yvb1ksftU66dUi9xDWAuBfQYqIfgnrrTnDC1t60iM2U8YX9P9wjw1hVd9b8Nwa/CIq2Yf1kEUT WAiAtLf9ZLb3DGoYBWz/exnngImMfLdkhciTOz/OKeKkkIWbM0lVNy3hRWeXtiPMoMqgcdTTivSmi q/cr92yQ==; Received: from [2001:4bb8:19a:7ee7:fb46:2fe1:8652:d9d4] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkMZK-000s09-9X; Tue, 09 Nov 2021 08:33:27 +0000 From: Christoph Hellwig To: Dan Williams Cc: Mike Snitzer , Ira Weiny , dm-devel@redhat.com, linux-xfs@vger.kernel.org, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH 07/29] xfs: factor out a xfs_setup_dax_always helper Date: Tue, 9 Nov 2021 09:32:47 +0100 Message-Id: <20211109083309.584081-8-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211109083309.584081-1-hch@lst.de> References: <20211109083309.584081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Factor out another DAX setup helper to simplify future changes. Also move the experimental warning after the checks to not clutter the log too much if the setup failed. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_super.c | 47 +++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index e21459f9923a8..875fd3151d6c9 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -340,6 +340,32 @@ xfs_buftarg_is_dax( bdev_nr_sectors(bt->bt_bdev)); } +static int +xfs_setup_dax_always( + struct xfs_mount *mp) +{ + struct super_block *sb = mp->m_super; + + if (!xfs_buftarg_is_dax(sb, mp->m_ddev_targp) && + (!mp->m_rtdev_targp || !xfs_buftarg_is_dax(sb, mp->m_rtdev_targp))) { + xfs_alert(mp, + "DAX unsupported by block device. Turning off DAX."); + goto disable_dax; + } + + if (xfs_has_reflink(mp)) { + xfs_alert(mp, "DAX and reflink cannot be used together!"); + return -EINVAL; + } + + xfs_warn(mp, "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); + return 0; + +disable_dax: + xfs_mount_set_dax_mode(mp, XFS_DAX_NEVER); + return 0; +} + STATIC int xfs_blkdev_get( xfs_mount_t *mp, @@ -1593,26 +1619,9 @@ xfs_fs_fill_super( sb->s_flags |= SB_I_VERSION; if (xfs_has_dax_always(mp)) { - bool rtdev_is_dax = false, datadev_is_dax; - - xfs_warn(mp, - "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); - - datadev_is_dax = xfs_buftarg_is_dax(sb, mp->m_ddev_targp); - if (mp->m_rtdev_targp) - rtdev_is_dax = xfs_buftarg_is_dax(sb, - mp->m_rtdev_targp); - if (!rtdev_is_dax && !datadev_is_dax) { - xfs_alert(mp, - "DAX unsupported by block device. Turning off DAX."); - xfs_mount_set_dax_mode(mp, XFS_DAX_NEVER); - } - if (xfs_has_reflink(mp)) { - xfs_alert(mp, - "DAX and reflink cannot be used together!"); - error = -EINVAL; + error = xfs_setup_dax_always(mp); + if (error) goto out_filestream_unmount; - } } if (xfs_has_discard(mp)) { -- 2.30.2