From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85B772C81 for ; Mon, 18 Oct 2021 16:43:53 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 1030561002; Mon, 18 Oct 2021 16:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634575432; bh=ndzn/cgjnN1D+UBSRO9lROqzj4w1+JVpStrCpNeonJE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SgG+zrgJcn47VIYSj3YzilH6qamtpHX2Ydp79Qvx7Wxh6NdjQiLSe39pSdPAG2gBz IyxCQUVQzJ7XUZ4gtcs8WceCSB2NahePCfq66/Layc7hZxqlzYYOLBySW2QWtd7P7M TTv9nwNV9Ot5ruqQa6nxmusgQhVkFVVmpNt1tauFIB7/jvVSfDklt+vkFLgpLGy0lJ +AibGWL+8y7C64Zr6vQ804z2SbwOAX8zyNdWSPM+gu5OGkgGT5cyj6rh8WNlMrRtOc OdYtkuBHsYZZXXsOcYayNw+dnkTsRyfLkUPd1u7mzxEa6negBF89Xl4tfDqAGgWd+h ZeVsLLSKK4Viw== Date: Mon, 18 Oct 2021 09:43:51 -0700 From: "Darrick J. Wong" To: Christoph Hellwig Cc: no To-header on input <;, Dan Williams , 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: Re: [PATCH 06/11] xfs: factor out a xfs_setup_dax helper Message-ID: <20211018164351.GT24307@magnolia> References: <20211018044054.1779424-1-hch@lst.de> <20211018044054.1779424-7-hch@lst.de> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211018044054.1779424-7-hch@lst.de> On Mon, Oct 18, 2021 at 06:40:49AM +0200, Christoph Hellwig wrote: > 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 c4e0cd1c1c8ca..d07020a8eb9e3 100644 > --- a/fs/xfs/xfs_super.c > +++ b/fs/xfs/xfs_super.c > @@ -339,6 +339,32 @@ xfs_buftarg_is_dax( > bdev_nr_sectors(bt->bt_bdev)); > } > > +static int > +xfs_setup_dax( /me wonders if this should be named xfs_setup_dax_always, since this doesn't handle the dax=inode mode? The only reason I bring that up is that Eric reminded me a while ago that we don't actually print any kind of EXPERIMENTAL warning for the auto-detection behavior. That said, I never liked looking at the nested backwards logic of the old code, so: Reviewed-by: Darrick J. Wong --D > + 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, > @@ -1592,26 +1618,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(mp); > + if (error) > goto out_filestream_unmount; > - } > } > > if (xfs_has_discard(mp)) { > -- > 2.30.2 >