dax: remove bdev_dax_supported
authorChristoph Hellwig <hch@lst.de>
Thu, 26 Aug 2021 13:55:10 +0000 (15:55 +0200)
committerDan Williams <dan.j.williams@intel.com>
Thu, 26 Aug 2021 23:52:03 +0000 (16:52 -0700)
All callers already have a dax_device obtained from fs_dax_get_by_bdev
at hand, so just pass that to dax_supported() insted of doing another
lookup.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/20210826135510.6293-10-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/dax/super.c
fs/ext2/super.c
fs/ext4/super.c
fs/xfs/xfs_super.c
include/linux/dax.h

index eed0272..fc89e91 100644 (file)
@@ -220,47 +220,7 @@ bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
 }
 EXPORT_SYMBOL_GPL(dax_supported);
 #endif /* CONFIG_FS_DAX */
-
-/**
- * __bdev_dax_supported() - Check if the device supports dax for filesystem
- * @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
- * can be mounted with dax option.
- *
- * Return: true if supported, false if unsupported
- */
-bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
-{
-       struct dax_device *dax_dev;
-       struct request_queue *q;
-       char buf[BDEVNAME_SIZE];
-       bool ret;
-
-       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;
-       }
-
-       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 false;
-       }
-
-       ret = dax_supported(dax_dev, bdev, blocksize, 0,
-                       i_size_read(bdev->bd_inode) / 512);
-
-       put_dax(dax_dev);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(__bdev_dax_supported);
-#endif
+#endif /* CONFIG_BLOCK */
 
 enum dax_device_flags {
        /* !alive + rcu grace period == no new operations / mappings */
index 21e09fb..26e69e4 100644 (file)
@@ -949,7 +949,8 @@ 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 (test_opt(sb, DAX)) {
-               if (!bdev_dax_supported(sb->s_bdev, blocksize)) {
+               if (!dax_supported(dax_dev, sb->s_bdev, blocksize, 0,
+                               bdev_nr_sectors(sb->s_bdev))) {
                        ext2_msg(sb, KERN_ERR,
                                "DAX unsupported by block device. Turning off DAX.");
                        clear_opt(sbi->s_mount_opt, DAX);
index dfa09a2..a1726a8 100644 (file)
@@ -4435,7 +4435,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
                goto failed_mount;
        }
 
-       if (bdev_dax_supported(sb->s_bdev, blocksize))
+       if (dax_supported(dax_dev, sb->s_bdev, blocksize, 0,
+                       bdev_nr_sectors(sb->s_bdev)))
                set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags);
 
        if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) {
index 5a89bf6..f438497 100644 (file)
@@ -319,7 +319,8 @@ xfs_buftarg_is_dax(
        struct super_block      *sb,
        struct xfs_buftarg      *bt)
 {
-       return bdev_dax_supported(bt->bt_bdev, sb->s_blocksize);
+       return dax_supported(bt->bt_daxdev, bt->bt_bdev, sb->s_blocksize, 0,
+                       bdev_nr_sectors(bt->bt_bdev));
 }
 
 STATIC int
index 32dce57..2619d94 100644 (file)
@@ -109,12 +109,6 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
 struct writeback_control;
 int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff);
 #if IS_ENABLED(CONFIG_FS_DAX)
-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);
-}
-
 bool generic_fsdax_supported(struct dax_device *dax_dev,
                struct block_device *bdev, int blocksize, sector_t start,
                sector_t sectors);
@@ -136,12 +130,6 @@ struct page *dax_layout_busy_page_range(struct address_space *mapping, loff_t st
 dax_entry_t dax_lock_page(struct page *page);
 void dax_unlock_page(struct page *page, dax_entry_t cookie);
 #else
-static inline bool bdev_dax_supported(struct block_device *bdev,
-               int blocksize)
-{
-       return false;
-}
-
 #define generic_fsdax_supported                NULL
 
 static inline bool dax_supported(struct dax_device *dax_dev,