Skip to content

Commit 679a994

Browse files
Christoph Hellwigdjbw
authored andcommitted
xfs: factor out a xfs_setup_dax_always helper
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 <[email protected]> Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 0c44587 commit 679a994

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

fs/xfs/xfs_super.c

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,32 @@ xfs_buftarg_is_dax(
340340
bdev_nr_sectors(bt->bt_bdev));
341341
}
342342

343+
static int
344+
xfs_setup_dax_always(
345+
struct xfs_mount *mp)
346+
{
347+
struct super_block *sb = mp->m_super;
348+
349+
if (!xfs_buftarg_is_dax(sb, mp->m_ddev_targp) &&
350+
(!mp->m_rtdev_targp || !xfs_buftarg_is_dax(sb, mp->m_rtdev_targp))) {
351+
xfs_alert(mp,
352+
"DAX unsupported by block device. Turning off DAX.");
353+
goto disable_dax;
354+
}
355+
356+
if (xfs_has_reflink(mp)) {
357+
xfs_alert(mp, "DAX and reflink cannot be used together!");
358+
return -EINVAL;
359+
}
360+
361+
xfs_warn(mp, "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
362+
return 0;
363+
364+
disable_dax:
365+
xfs_mount_set_dax_mode(mp, XFS_DAX_NEVER);
366+
return 0;
367+
}
368+
343369
STATIC int
344370
xfs_blkdev_get(
345371
xfs_mount_t *mp,
@@ -1593,26 +1619,9 @@ xfs_fs_fill_super(
15931619
sb->s_flags |= SB_I_VERSION;
15941620

15951621
if (xfs_has_dax_always(mp)) {
1596-
bool rtdev_is_dax = false, datadev_is_dax;
1597-
1598-
xfs_warn(mp,
1599-
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
1600-
1601-
datadev_is_dax = xfs_buftarg_is_dax(sb, mp->m_ddev_targp);
1602-
if (mp->m_rtdev_targp)
1603-
rtdev_is_dax = xfs_buftarg_is_dax(sb,
1604-
mp->m_rtdev_targp);
1605-
if (!rtdev_is_dax && !datadev_is_dax) {
1606-
xfs_alert(mp,
1607-
"DAX unsupported by block device. Turning off DAX.");
1608-
xfs_mount_set_dax_mode(mp, XFS_DAX_NEVER);
1609-
}
1610-
if (xfs_has_reflink(mp)) {
1611-
xfs_alert(mp,
1612-
"DAX and reflink cannot be used together!");
1613-
error = -EINVAL;
1622+
error = xfs_setup_dax_always(mp);
1623+
if (error)
16141624
goto out_filestream_unmount;
1615-
}
16161625
}
16171626

16181627
if (xfs_has_discard(mp)) {

0 commit comments

Comments
 (0)