diff options
author | Dave Jiang <dave.jiang@intel.com> | 2018-05-30 16:03:46 -0400 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2018-05-31 11:58:34 -0400 |
commit | 80660f20252d6f76c9f203874ad7c7a4a8508cf8 (patch) | |
tree | 6b34e3aff86d4455a595f37d0b2d5edc693a8bb4 | |
parent | ba23cba9b3bdc967aabdc6ff1e3e9b11ce05bb4f (diff) |
dax: change bdev_dax_supported() to support boolean returns
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>
-rw-r--r-- | drivers/dax/super.c | 16 | ||||
-rw-r--r-- | fs/ext2/super.c | 3 | ||||
-rw-r--r-- | fs/ext4/super.c | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_super.c | 12 | ||||
-rw-r--r-- | include/linux/dax.h | 8 |
6 files changed, 22 insertions, 24 deletions
diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 3943feb9a090..1d7bd96511f0 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c | |||
@@ -80,9 +80,9 @@ EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev); | |||
80 | * This is a library function for filesystems to check if the block device | 80 | * This is a library function for filesystems to check if the block device |
81 | * can be mounted with dax option. | 81 | * can be mounted with dax option. |
82 | * | 82 | * |
83 | * Return: negative errno if unsupported, 0 if supported. | 83 | * Return: true if supported, false if unsupported |
84 | */ | 84 | */ |
85 | int __bdev_dax_supported(struct block_device *bdev, int blocksize) | 85 | bool __bdev_dax_supported(struct block_device *bdev, int blocksize) |
86 | { | 86 | { |
87 | struct dax_device *dax_dev; | 87 | struct dax_device *dax_dev; |
88 | pgoff_t pgoff; | 88 | pgoff_t pgoff; |
@@ -95,21 +95,21 @@ int __bdev_dax_supported(struct block_device *bdev, int blocksize) | |||
95 | if (blocksize != PAGE_SIZE) { | 95 | if (blocksize != PAGE_SIZE) { |
96 | pr_debug("%s: error: unsupported blocksize for dax\n", | 96 | pr_debug("%s: error: unsupported blocksize for dax\n", |
97 | bdevname(bdev, buf)); | 97 | bdevname(bdev, buf)); |
98 | return -EINVAL; | 98 | return false; |
99 | } | 99 | } |
100 | 100 | ||
101 | err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff); | 101 | err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff); |
102 | if (err) { | 102 | if (err) { |
103 | pr_debug("%s: error: unaligned partition for dax\n", | 103 | pr_debug("%s: error: unaligned partition for dax\n", |
104 | bdevname(bdev, buf)); | 104 | bdevname(bdev, buf)); |
105 | return err; | 105 | return false; |
106 | } | 106 | } |
107 | 107 | ||
108 | dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); | 108 | dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); |
109 | if (!dax_dev) { | 109 | if (!dax_dev) { |
110 | pr_debug("%s: error: device does not support dax\n", | 110 | pr_debug("%s: error: device does not support dax\n", |
111 | bdevname(bdev, buf)); | 111 | bdevname(bdev, buf)); |
112 | return -EOPNOTSUPP; | 112 | return false; |
113 | } | 113 | } |
114 | 114 | ||
115 | id = dax_read_lock(); | 115 | id = dax_read_lock(); |
@@ -121,7 +121,7 @@ int __bdev_dax_supported(struct block_device *bdev, int blocksize) | |||
121 | if (len < 1) { | 121 | if (len < 1) { |
122 | pr_debug("%s: error: dax access failed (%ld)\n", | 122 | pr_debug("%s: error: dax access failed (%ld)\n", |
123 | bdevname(bdev, buf), len); | 123 | bdevname(bdev, buf), len); |
124 | return len < 0 ? len : -EIO; | 124 | return false; |
125 | } | 125 | } |
126 | 126 | ||
127 | if (IS_ENABLED(CONFIG_FS_DAX_LIMITED) && pfn_t_special(pfn)) { | 127 | if (IS_ENABLED(CONFIG_FS_DAX_LIMITED) && pfn_t_special(pfn)) { |
@@ -139,10 +139,10 @@ int __bdev_dax_supported(struct block_device *bdev, int blocksize) | |||
139 | } else { | 139 | } else { |
140 | pr_debug("%s: error: dax support not enabled\n", | 140 | pr_debug("%s: error: dax support not enabled\n", |
141 | bdevname(bdev, buf)); | 141 | bdevname(bdev, buf)); |
142 | return -EOPNOTSUPP; | 142 | return false; |
143 | } | 143 | } |
144 | 144 | ||
145 | return 0; | 145 | return true; |
146 | } | 146 | } |
147 | EXPORT_SYMBOL_GPL(__bdev_dax_supported); | 147 | EXPORT_SYMBOL_GPL(__bdev_dax_supported); |
148 | #endif | 148 | #endif |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 9627c3054b5c..c09289a42dc5 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -961,8 +961,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
961 | blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); | 961 | blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); |
962 | 962 | ||
963 | if (sbi->s_mount_opt & EXT2_MOUNT_DAX) { | 963 | if (sbi->s_mount_opt & EXT2_MOUNT_DAX) { |
964 | err = bdev_dax_supported(sb->s_bdev, blocksize); | 964 | if (!bdev_dax_supported(sb->s_bdev, blocksize)) { |
965 | if (err) { | ||
966 | ext2_msg(sb, KERN_ERR, | 965 | ext2_msg(sb, KERN_ERR, |
967 | "DAX unsupported by block device. Turning off DAX."); | 966 | "DAX unsupported by block device. Turning off DAX."); |
968 | sbi->s_mount_opt &= ~EXT2_MOUNT_DAX; | 967 | sbi->s_mount_opt &= ~EXT2_MOUNT_DAX; |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 089170e99895..2e1622907f4a 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -3732,8 +3732,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3732 | " that may contain inline data"); | 3732 | " that may contain inline data"); |
3733 | sbi->s_mount_opt &= ~EXT4_MOUNT_DAX; | 3733 | sbi->s_mount_opt &= ~EXT4_MOUNT_DAX; |
3734 | } | 3734 | } |
3735 | err = bdev_dax_supported(sb->s_bdev, blocksize); | 3735 | if (!bdev_dax_supported(sb->s_bdev, blocksize)) { |
3736 | if (err) { | ||
3737 | ext4_msg(sb, KERN_ERR, | 3736 | ext4_msg(sb, KERN_ERR, |
3738 | "DAX unsupported by block device. Turning off DAX."); | 3737 | "DAX unsupported by block device. Turning off DAX."); |
3739 | sbi->s_mount_opt &= ~EXT4_MOUNT_DAX; | 3738 | sbi->s_mount_opt &= ~EXT4_MOUNT_DAX; |
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index c9a5b75a73a8..5dd9e22b4a4c 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c | |||
@@ -1103,8 +1103,8 @@ xfs_ioctl_setattr_dax_invalidate( | |||
1103 | if (fa->fsx_xflags & FS_XFLAG_DAX) { | 1103 | if (fa->fsx_xflags & FS_XFLAG_DAX) { |
1104 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) | 1104 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) |
1105 | return -EINVAL; | 1105 | return -EINVAL; |
1106 | if (bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)), | 1106 | if (!bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)), |
1107 | sb->s_blocksize) < 0) | 1107 | sb->s_blocksize)) |
1108 | return -EINVAL; | 1108 | return -EINVAL; |
1109 | } | 1109 | } |
1110 | 1110 | ||
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index fed63e0b8f4d..4e66e61865fb 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -1701,17 +1701,17 @@ xfs_fs_fill_super( | |||
1701 | sb->s_flags |= SB_I_VERSION; | 1701 | sb->s_flags |= SB_I_VERSION; |
1702 | 1702 | ||
1703 | if (mp->m_flags & XFS_MOUNT_DAX) { | 1703 | if (mp->m_flags & XFS_MOUNT_DAX) { |
1704 | int error2 = 0; | 1704 | bool rtdev_is_dax = false, datadev_is_dax; |
1705 | 1705 | ||
1706 | xfs_warn(mp, | 1706 | xfs_warn(mp, |
1707 | "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); | 1707 | "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); |
1708 | 1708 | ||
1709 | error = bdev_dax_supported(mp->m_ddev_targp->bt_bdev, | 1709 | datadev_is_dax = bdev_dax_supported(mp->m_ddev_targp->bt_bdev, |
1710 | sb->s_blocksize); | 1710 | sb->s_blocksize); |
1711 | if (mp->m_rtdev_targp) | 1711 | if (mp->m_rtdev_targp) |
1712 | error2 = bdev_dax_supported(mp->m_rtdev_targp->bt_bdev, | 1712 | rtdev_is_dax = bdev_dax_supported( |
1713 | sb->s_blocksize); | 1713 | mp->m_rtdev_targp->bt_bdev, sb->s_blocksize); |
1714 | if (error && error2) { | 1714 | if (!rtdev_is_dax && !datadev_is_dax) { |
1715 | xfs_alert(mp, | 1715 | xfs_alert(mp, |
1716 | "DAX unsupported by block device. Turning off DAX."); | 1716 | "DAX unsupported by block device. Turning off DAX."); |
1717 | mp->m_flags &= ~XFS_MOUNT_DAX; | 1717 | mp->m_flags &= ~XFS_MOUNT_DAX; |
diff --git a/include/linux/dax.h b/include/linux/dax.h index 2a4f7295c12b..c99692ddd4b5 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h | |||
@@ -64,8 +64,8 @@ static inline bool dax_write_cache_enabled(struct dax_device *dax_dev) | |||
64 | struct writeback_control; | 64 | struct writeback_control; |
65 | int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); | 65 | int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); |
66 | #if IS_ENABLED(CONFIG_FS_DAX) | 66 | #if IS_ENABLED(CONFIG_FS_DAX) |
67 | int __bdev_dax_supported(struct block_device *bdev, int blocksize); | 67 | bool __bdev_dax_supported(struct block_device *bdev, int blocksize); |
68 | static inline int bdev_dax_supported(struct block_device *bdev, int blocksize) | 68 | static inline bool bdev_dax_supported(struct block_device *bdev, int blocksize) |
69 | { | 69 | { |
70 | return __bdev_dax_supported(bdev, blocksize); | 70 | return __bdev_dax_supported(bdev, blocksize); |
71 | } | 71 | } |
@@ -84,10 +84,10 @@ struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev); | |||
84 | int dax_writeback_mapping_range(struct address_space *mapping, | 84 | int dax_writeback_mapping_range(struct address_space *mapping, |
85 | struct block_device *bdev, struct writeback_control *wbc); | 85 | struct block_device *bdev, struct writeback_control *wbc); |
86 | #else | 86 | #else |
87 | static inline int bdev_dax_supported(struct block_device *bdev, | 87 | static inline bool bdev_dax_supported(struct block_device *bdev, |
88 | int blocksize) | 88 | int blocksize) |
89 | { | 89 | { |
90 | return -EOPNOTSUPP; | 90 | return false; |
91 | } | 91 | } |
92 | 92 | ||
93 | static inline struct dax_device *fs_dax_get_by_host(const char *host) | 93 | static inline struct dax_device *fs_dax_get_by_host(const char *host) |