* [v4.14-stable 0/5] Fix DM DAX handling
@ 2018-07-05 20:33 Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 1/5] fs: allow per-device dax status checking for filesystems Ross Zwisler
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Ross Zwisler @ 2018-07-05 20:33 UTC (permalink / raw)
To: gregkh; +Cc: Ross Zwisler, dan.j.williams, snitzer, toshi.kani, stable
This is a v4.14-stable backport of my "Fix DM DAX handling" series which
had backport collisions. This series also includes a few patches that
were backport dependencies.
Changes from the v4.17-stable version:
* DAX on raw mode namespace is allowed in this baseline, so we allow it
for DM devices as well. This meant dropping the patch "pmem: only
set QUEUE_FLAG_DAX for fsdax mode".
* Pulled in one additional patch from Mike as a backport dependency.
Darrick J. Wong (1):
fs: allow per-device dax status checking for filesystems
Dave Jiang (1):
dax: change bdev_dax_supported() to support boolean returns
Mike Snitzer (1):
dm: set QUEUE_FLAG_DAX accordingly in dm_table_set_restrictions()
Ross Zwisler (2):
dax: check for QUEUE_FLAG_DAX in bdev_dax_supported()
dm: prevent DAX mounts if not supported
drivers/dax/super.c | 42 +++++++++++++++++++++++++-----------------
drivers/md/dm-table.c | 9 ++++++---
drivers/md/dm.c | 6 +-----
fs/ext2/super.c | 3 +--
fs/ext4/super.c | 3 +--
fs/xfs/xfs_ioctl.c | 3 ++-
fs/xfs/xfs_iops.c | 30 +++++++++++++++++++++++++-----
fs/xfs/xfs_super.c | 10 ++++++++--
include/linux/dax.h | 11 ++++++-----
9 files changed, 75 insertions(+), 42 deletions(-)
--
2.14.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [v4.14-stable 1/5] fs: allow per-device dax status checking for filesystems
2018-07-05 20:33 [v4.14-stable 0/5] Fix DM DAX handling Ross Zwisler
@ 2018-07-05 20:33 ` Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 2/5] dax: change bdev_dax_supported() to support boolean returns Ross Zwisler
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ross Zwisler @ 2018-07-05 20:33 UTC (permalink / raw)
To: gregkh
Cc: Darrick J. Wong, Ross Zwisler, dan.j.williams, snitzer,
toshi.kani, stable
From: "Darrick J. Wong" <darrick.wong@oracle.com>
commit ba23cba9b3bdc967aabdc6ff1e3e9b11ce05bb4f upstream.
Change bdev_dax_supported so it takes a bdev parameter. This enables
multi-device filesystems like xfs to check that a dax device can work for
the particular filesystem. Once that's in place, actually fix all the
parts of XFS where we need to be able to distinguish between datadev and
rtdev.
This patch fixes the problem where we screw up the dax support checking
in xfs if the datadev and rtdev have different dax capabilities.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[rez: Re-added __bdev_dax_supported() for !CONFIG_FS_DAX cases]
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
---
drivers/dax/super.c | 22 +++++++++++-----------
fs/ext2/super.c | 2 +-
fs/ext4/super.c | 2 +-
fs/xfs/xfs_ioctl.c | 3 ++-
fs/xfs/xfs_iops.c | 30 +++++++++++++++++++++++++-----
fs/xfs/xfs_super.c | 10 ++++++++--
include/linux/dax.h | 9 +++++----
7 files changed, 53 insertions(+), 25 deletions(-)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index c4cd034a3820..8d54021cd2f6 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev);
/**
* __bdev_dax_supported() - Check if the device supports dax for filesystem
- * @sb: The superblock of the device
+ * @bdev: block device to check
* @blocksize: The block size of the device
*
* This is a library function for filesystems to check if the block device
@@ -81,33 +81,33 @@ EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev);
*
* Return: negative errno if unsupported, 0 if supported.
*/
-int __bdev_dax_supported(struct super_block *sb, int blocksize)
+int __bdev_dax_supported(struct block_device *bdev, int blocksize)
{
- struct block_device *bdev = sb->s_bdev;
struct dax_device *dax_dev;
pgoff_t pgoff;
int err, id;
void *kaddr;
pfn_t pfn;
long len;
+ char buf[BDEVNAME_SIZE];
if (blocksize != PAGE_SIZE) {
- pr_err("VFS (%s): error: unsupported blocksize for dax\n",
- sb->s_id);
+ pr_debug("%s: error: unsupported blocksize for dax\n",
+ bdevname(bdev, buf));
return -EINVAL;
}
err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff);
if (err) {
- pr_err("VFS (%s): error: unaligned partition for dax\n",
- sb->s_id);
+ pr_debug("%s: error: unaligned partition for dax\n",
+ bdevname(bdev, buf));
return err;
}
dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
if (!dax_dev) {
- pr_err("VFS (%s): error: device does not support dax\n",
- sb->s_id);
+ pr_debug("%s: error: device does not support dax\n",
+ bdevname(bdev, buf));
return -EOPNOTSUPP;
}
@@ -118,8 +118,8 @@ int __bdev_dax_supported(struct super_block *sb, int blocksize)
put_dax(dax_dev);
if (len < 1) {
- pr_err("VFS (%s): error: dax access failed (%ld)",
- sb->s_id, len);
+ pr_debug("%s: error: dax access failed (%ld)\n",
+ bdevname(bdev, buf), len);
return len < 0 ? len : -EIO;
}
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 1458706bd2ec..e85c57eb2734 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -953,7 +953,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
if (sbi->s_mount_opt & EXT2_MOUNT_DAX) {
- err = bdev_dax_supported(sb, blocksize);
+ err = bdev_dax_supported(sb->s_bdev, blocksize);
if (err)
goto failed_mount;
}
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index ec74d06fa24a..1c92711634c9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3729,7 +3729,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
" that may contain inline data");
goto failed_mount;
}
- err = bdev_dax_supported(sb, blocksize);
+ err = bdev_dax_supported(sb->s_bdev, blocksize);
if (err)
goto failed_mount;
}
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index aa75389be8cf..682b6946d06a 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1101,7 +1101,8 @@ xfs_ioctl_setattr_dax_invalidate(
if (fa->fsx_xflags & FS_XFLAG_DAX) {
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
return -EINVAL;
- if (bdev_dax_supported(sb, sb->s_blocksize) < 0)
+ if (bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)),
+ sb->s_blocksize) < 0)
return -EINVAL;
}
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index f24e5b6cfc86..1daa965f1e08 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1184,6 +1184,30 @@ static const struct inode_operations xfs_inline_symlink_inode_operations = {
.update_time = xfs_vn_update_time,
};
+/* Figure out if this file actually supports DAX. */
+static bool
+xfs_inode_supports_dax(
+ struct xfs_inode *ip)
+{
+ struct xfs_mount *mp = ip->i_mount;
+
+ /* Only supported on non-reflinked files. */
+ if (!S_ISREG(VFS_I(ip)->i_mode) || xfs_is_reflink_inode(ip))
+ return false;
+
+ /* DAX mount option or DAX iflag must be set. */
+ if (!(mp->m_flags & XFS_MOUNT_DAX) &&
+ !(ip->i_d.di_flags2 & XFS_DIFLAG2_DAX))
+ return false;
+
+ /* Block size must match page size */
+ if (mp->m_sb.sb_blocksize != PAGE_SIZE)
+ return false;
+
+ /* Device has to support DAX too. */
+ return xfs_find_daxdev_for_inode(VFS_I(ip)) != NULL;
+}
+
STATIC void
xfs_diflags_to_iflags(
struct inode *inode,
@@ -1202,11 +1226,7 @@ xfs_diflags_to_iflags(
inode->i_flags |= S_SYNC;
if (flags & XFS_DIFLAG_NOATIME)
inode->i_flags |= S_NOATIME;
- if (S_ISREG(inode->i_mode) &&
- ip->i_mount->m_sb.sb_blocksize == PAGE_SIZE &&
- !xfs_is_reflink_inode(ip) &&
- (ip->i_mount->m_flags & XFS_MOUNT_DAX ||
- ip->i_d.di_flags2 & XFS_DIFLAG2_DAX))
+ if (xfs_inode_supports_dax(ip))
inode->i_flags |= S_DAX;
}
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f663022353c0..89f3e54e57f5 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1640,11 +1640,17 @@ xfs_fs_fill_super(
sb->s_flags |= SB_I_VERSION;
if (mp->m_flags & XFS_MOUNT_DAX) {
+ int error2 = 0;
+
xfs_warn(mp,
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
- error = bdev_dax_supported(sb, sb->s_blocksize);
- if (error) {
+ error = bdev_dax_supported(mp->m_ddev_targp->bt_bdev,
+ sb->s_blocksize);
+ if (mp->m_rtdev_targp)
+ error2 = bdev_dax_supported(mp->m_rtdev_targp->bt_bdev,
+ sb->s_blocksize);
+ if (error && error2) {
xfs_alert(mp,
"DAX unsupported by block device. Turning off DAX.");
mp->m_flags &= ~XFS_MOUNT_DAX;
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 895e16fcc62d..7b37727ad3ed 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -40,10 +40,10 @@ static inline void put_dax(struct dax_device *dax_dev)
int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff);
#if IS_ENABLED(CONFIG_FS_DAX)
-int __bdev_dax_supported(struct super_block *sb, int blocksize);
-static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
+int __bdev_dax_supported(struct block_device *bdev, int blocksize);
+static inline int bdev_dax_supported(struct block_device *bdev, int blocksize)
{
- return __bdev_dax_supported(sb, blocksize);
+ return __bdev_dax_supported(bdev, blocksize);
}
static inline struct dax_device *fs_dax_get_by_host(const char *host)
@@ -58,7 +58,8 @@ static inline void fs_put_dax(struct dax_device *dax_dev)
struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev);
#else
-static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
+static inline int bdev_dax_supported(struct block_device *bdev,
+ int blocksize)
{
return -EOPNOTSUPP;
}
--
2.14.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [v4.14-stable 2/5] dax: change bdev_dax_supported() to support boolean returns
2018-07-05 20:33 [v4.14-stable 0/5] Fix DM DAX handling Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 1/5] fs: allow per-device dax status checking for filesystems Ross Zwisler
@ 2018-07-05 20:33 ` Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 3/5] dax: check for QUEUE_FLAG_DAX in bdev_dax_supported() Ross Zwisler
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ross Zwisler @ 2018-07-05 20:33 UTC (permalink / raw)
To: gregkh
Cc: Dave Jiang, Ross Zwisler, dan.j.williams, snitzer, toshi.kani,
stable, Darrick J . Wong
From: Dave Jiang <dave.jiang@intel.com>
commit 80660f20252d6f76c9f203874ad7c7a4a8508cf8 upstream.
The function return values are confusing with the way the function is
named. We expect a true or false return value but it actually returns
0/-errno. This makes the code very confusing. Changing the return values
to return a bool where if DAX is supported then return true and no DAX
support returns false.
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
drivers/dax/super.c | 14 +++++++-------
fs/ext2/super.c | 3 +--
fs/ext4/super.c | 3 +--
fs/xfs/xfs_ioctl.c | 4 ++--
fs/xfs/xfs_super.c | 12 ++++++------
include/linux/dax.h | 8 ++++----
6 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 8d54021cd2f6..b9c3e8cd0820 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -79,9 +79,9 @@ EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev);
* This is a library function for filesystems to check if the block device
* can be mounted with dax option.
*
- * Return: negative errno if unsupported, 0 if supported.
+ * Return: true if supported, false if unsupported
*/
-int __bdev_dax_supported(struct block_device *bdev, int blocksize)
+bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
{
struct dax_device *dax_dev;
pgoff_t pgoff;
@@ -94,21 +94,21 @@ int __bdev_dax_supported(struct block_device *bdev, int blocksize)
if (blocksize != PAGE_SIZE) {
pr_debug("%s: error: unsupported blocksize for dax\n",
bdevname(bdev, buf));
- return -EINVAL;
+ return false;
}
err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff);
if (err) {
pr_debug("%s: error: unaligned partition for dax\n",
bdevname(bdev, buf));
- return err;
+ return false;
}
dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
if (!dax_dev) {
pr_debug("%s: error: device does not support dax\n",
bdevname(bdev, buf));
- return -EOPNOTSUPP;
+ return false;
}
id = dax_read_lock();
@@ -120,10 +120,10 @@ int __bdev_dax_supported(struct block_device *bdev, int blocksize)
if (len < 1) {
pr_debug("%s: error: dax access failed (%ld)\n",
bdevname(bdev, buf), len);
- return len < 0 ? len : -EIO;
+ return false;
}
- return 0;
+ return true;
}
EXPORT_SYMBOL_GPL(__bdev_dax_supported);
#endif
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index e85c57eb2734..726e680a3368 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -953,8 +953,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
if (sbi->s_mount_opt & EXT2_MOUNT_DAX) {
- err = bdev_dax_supported(sb->s_bdev, blocksize);
- if (err)
+ if (!bdev_dax_supported(sb->s_bdev, blocksize))
goto failed_mount;
}
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1c92711634c9..2caea6219daf 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3729,8 +3729,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
" that may contain inline data");
goto failed_mount;
}
- err = bdev_dax_supported(sb->s_bdev, blocksize);
- if (err)
+ if (!bdev_dax_supported(sb->s_bdev, blocksize))
goto failed_mount;
}
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 682b6946d06a..79a9a0def7db 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1101,8 +1101,8 @@ xfs_ioctl_setattr_dax_invalidate(
if (fa->fsx_xflags & FS_XFLAG_DAX) {
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
return -EINVAL;
- if (bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)),
- sb->s_blocksize) < 0)
+ if (!bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)),
+ sb->s_blocksize))
return -EINVAL;
}
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 89f3e54e57f5..0b0282d2f011 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1640,17 +1640,17 @@ xfs_fs_fill_super(
sb->s_flags |= SB_I_VERSION;
if (mp->m_flags & XFS_MOUNT_DAX) {
- int error2 = 0;
+ bool rtdev_is_dax = false, datadev_is_dax;
xfs_warn(mp,
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
- error = bdev_dax_supported(mp->m_ddev_targp->bt_bdev,
- sb->s_blocksize);
+ datadev_is_dax = bdev_dax_supported(mp->m_ddev_targp->bt_bdev,
+ sb->s_blocksize);
if (mp->m_rtdev_targp)
- error2 = bdev_dax_supported(mp->m_rtdev_targp->bt_bdev,
- sb->s_blocksize);
- if (error && error2) {
+ rtdev_is_dax = bdev_dax_supported(
+ mp->m_rtdev_targp->bt_bdev, sb->s_blocksize);
+ if (!rtdev_is_dax && !datadev_is_dax) {
xfs_alert(mp,
"DAX unsupported by block device. Turning off DAX.");
mp->m_flags &= ~XFS_MOUNT_DAX;
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 7b37727ad3ed..07d6bc1f90a3 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -40,8 +40,8 @@ static inline void put_dax(struct dax_device *dax_dev)
int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff);
#if IS_ENABLED(CONFIG_FS_DAX)
-int __bdev_dax_supported(struct block_device *bdev, int blocksize);
-static inline int bdev_dax_supported(struct block_device *bdev, int blocksize)
+bool __bdev_dax_supported(struct block_device *bdev, int blocksize);
+static inline bool bdev_dax_supported(struct block_device *bdev, int blocksize)
{
return __bdev_dax_supported(bdev, blocksize);
}
@@ -58,10 +58,10 @@ static inline void fs_put_dax(struct dax_device *dax_dev)
struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev);
#else
-static inline int bdev_dax_supported(struct block_device *bdev,
+static inline bool bdev_dax_supported(struct block_device *bdev,
int blocksize)
{
- return -EOPNOTSUPP;
+ return false;
}
static inline struct dax_device *fs_dax_get_by_host(const char *host)
--
2.14.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [v4.14-stable 3/5] dax: check for QUEUE_FLAG_DAX in bdev_dax_supported()
2018-07-05 20:33 [v4.14-stable 0/5] Fix DM DAX handling Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 1/5] fs: allow per-device dax status checking for filesystems Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 2/5] dax: change bdev_dax_supported() to support boolean returns Ross Zwisler
@ 2018-07-05 20:33 ` Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 4/5] dm: set QUEUE_FLAG_DAX accordingly in dm_table_set_restrictions() Ross Zwisler
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ross Zwisler @ 2018-07-05 20:33 UTC (permalink / raw)
To: gregkh; +Cc: Ross Zwisler, dan.j.williams, snitzer, toshi.kani, stable
commit 15256f6cc4b44f2e70503758150267fd2a53c0d6 upstream.
Add an explicit check for QUEUE_FLAG_DAX to __bdev_dax_supported(). This
is needed for DM configurations where the first element in the dm-linear or
dm-stripe target supports DAX, but other elements do not. Without this
check __bdev_dax_supported() will pass for such devices, letting a
filesystem on that device mount with the DAX option.
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Suggested-by: Mike Snitzer <snitzer@redhat.com>
Fixes: commit 545ed20e6df6 ("dm: add infrastructure for DAX support")
Cc: stable@vger.kernel.org
Acked-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/dax/super.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index b9c3e8cd0820..6c179c2a9ff9 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -84,6 +84,7 @@ EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev);
bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
{
struct dax_device *dax_dev;
+ struct request_queue *q;
pgoff_t pgoff;
int err, id;
void *kaddr;
@@ -97,6 +98,13 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
return false;
}
+ q = bdev_get_queue(bdev);
+ if (!q || !blk_queue_dax(q)) {
+ pr_debug("%s: error: request queue doesn't support dax\n",
+ bdevname(bdev, buf));
+ return false;
+ }
+
err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff);
if (err) {
pr_debug("%s: error: unaligned partition for dax\n",
--
2.14.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [v4.14-stable 4/5] dm: set QUEUE_FLAG_DAX accordingly in dm_table_set_restrictions()
2018-07-05 20:33 [v4.14-stable 0/5] Fix DM DAX handling Ross Zwisler
` (2 preceding siblings ...)
2018-07-05 20:33 ` [v4.14-stable 3/5] dax: check for QUEUE_FLAG_DAX in bdev_dax_supported() Ross Zwisler
@ 2018-07-05 20:33 ` Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 5/5] dm: prevent DAX mounts if not supported Ross Zwisler
2018-07-10 14:40 ` [v4.14-stable 0/5] Fix DM DAX handling Greg KH
5 siblings, 0 replies; 7+ messages in thread
From: Ross Zwisler @ 2018-07-05 20:33 UTC (permalink / raw)
To: gregkh; +Cc: Mike Snitzer, Ross Zwisler, dan.j.williams, toshi.kani, stable
From: Mike Snitzer <snitzer@redhat.com>
commit ad3793fc3945173f64d82d05d3ecde41f6c0435c upstream.
Rather than having DAX support be unique by setting it based on table
type in dm_setup_md_queue().
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
---
drivers/md/dm-table.c | 2 ++
drivers/md/dm.c | 3 ---
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 4287fc9f3527..94849435c487 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1813,6 +1813,8 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
}
blk_queue_write_cache(q, wc, fua);
+ if (dm_table_supports_dax(t))
+ queue_flag_set_unlocked(QUEUE_FLAG_DAX, q);
if (dm_table_supports_dax_write_cache(t))
dax_write_cache(t->md->dax_dev, true);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 1dfc855ac708..b721f0a16711 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2050,9 +2050,6 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t)
*/
bioset_free(md->queue->bio_split);
md->queue->bio_split = NULL;
-
- if (type == DM_TYPE_DAX_BIO_BASED)
- queue_flag_set_unlocked(QUEUE_FLAG_DAX, md->queue);
break;
case DM_TYPE_NONE:
WARN_ON_ONCE(true);
--
2.14.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [v4.14-stable 5/5] dm: prevent DAX mounts if not supported
2018-07-05 20:33 [v4.14-stable 0/5] Fix DM DAX handling Ross Zwisler
` (3 preceding siblings ...)
2018-07-05 20:33 ` [v4.14-stable 4/5] dm: set QUEUE_FLAG_DAX accordingly in dm_table_set_restrictions() Ross Zwisler
@ 2018-07-05 20:33 ` Ross Zwisler
2018-07-10 14:40 ` [v4.14-stable 0/5] Fix DM DAX handling Greg KH
5 siblings, 0 replies; 7+ messages in thread
From: Ross Zwisler @ 2018-07-05 20:33 UTC (permalink / raw)
To: gregkh; +Cc: Ross Zwisler, dan.j.williams, snitzer, toshi.kani, stable
commit dbc626597c39b24cefce09fbd8e9dea85869a801 upstream.
Currently device_supports_dax() just checks to see if the QUEUE_FLAG_DAX
flag is set on the device's request queue to decide whether or not the
device supports filesystem DAX. Really we should be using
bdev_dax_supported() like filesystems do at mount time. This performs
other tests like checking to make sure the dax_direct_access() path works.
We also explicitly clear QUEUE_FLAG_DAX on the DM device's request queue if
any of the underlying devices do not support DAX. This makes the handling
of QUEUE_FLAG_DAX consistent with the setting/clearing of most other flags
in dm_table_set_restrictions().
Now that bdev_dax_supported() explicitly checks for QUEUE_FLAG_DAX, this
will ensure that filesystems built upon DM devices will only be able to
mount with DAX if all underlying devices also support DAX.
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Fixes: commit 545ed20e6df6 ("dm: add infrastructure for DAX support")
Cc: stable@vger.kernel.org
Acked-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-table.c | 7 ++++---
drivers/md/dm.c | 3 +--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 94849435c487..f9cd81375f28 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -883,9 +883,7 @@ EXPORT_SYMBOL_GPL(dm_table_set_type);
static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
- struct request_queue *q = bdev_get_queue(dev->bdev);
-
- return q && blk_queue_dax(q);
+ return bdev_dax_supported(dev->bdev, PAGE_SIZE);
}
static bool dm_table_supports_dax(struct dm_table *t)
@@ -1815,6 +1813,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
if (dm_table_supports_dax(t))
queue_flag_set_unlocked(QUEUE_FLAG_DAX, q);
+ else
+ queue_flag_clear_unlocked(QUEUE_FLAG_DAX, q);
+
if (dm_table_supports_dax_write_cache(t))
dax_write_cache(t->md->dax_dev, true);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index b721f0a16711..24ec6e039448 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -961,8 +961,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,
if (len < 1)
goto out;
nr_pages = min(len, nr_pages);
- if (ti->type->direct_access)
- ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
+ ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
out:
dm_put_live_table(md, srcu_idx);
--
2.14.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [v4.14-stable 0/5] Fix DM DAX handling
2018-07-05 20:33 [v4.14-stable 0/5] Fix DM DAX handling Ross Zwisler
` (4 preceding siblings ...)
2018-07-05 20:33 ` [v4.14-stable 5/5] dm: prevent DAX mounts if not supported Ross Zwisler
@ 2018-07-10 14:40 ` Greg KH
5 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2018-07-10 14:40 UTC (permalink / raw)
To: Ross Zwisler; +Cc: dan.j.williams, snitzer, toshi.kani, stable
On Thu, Jul 05, 2018 at 02:33:01PM -0600, Ross Zwisler wrote:
> This is a v4.14-stable backport of my "Fix DM DAX handling" series which
> had backport collisions. This series also includes a few patches that
> were backport dependencies.
All now applied, thanks.
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-07-10 14:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-05 20:33 [v4.14-stable 0/5] Fix DM DAX handling Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 1/5] fs: allow per-device dax status checking for filesystems Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 2/5] dax: change bdev_dax_supported() to support boolean returns Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 3/5] dax: check for QUEUE_FLAG_DAX in bdev_dax_supported() Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 4/5] dm: set QUEUE_FLAG_DAX accordingly in dm_table_set_restrictions() Ross Zwisler
2018-07-05 20:33 ` [v4.14-stable 5/5] dm: prevent DAX mounts if not supported Ross Zwisler
2018-07-10 14:40 ` [v4.14-stable 0/5] Fix DM DAX handling Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).