History

block, dax: convert bdev_dax_supported() to dax_direct_access()

Kill of the final user of bdev_direct_access() and struct blk_dax_ctl.

Dan Williams committed 9 years ago

Commit 2093f2e1 parent cccbce61 file · +28 −20Browse files

Unified · Split

fs/block_dev.c+28−20
@@ -788,35 +788,43 @@ EXPORT_SYMBOL(bdev_dax_pgoff); · 787 unmodified lines
788788 */
789789 int bdev_dax_supported(struct super_block *sb, int blocksize)
790790 {
791− struct blk_dax_ctl dax = {
792− .sector = 0,
793− .size = PAGE_SIZE,
794− };
795− int err;
791+ struct block_device *bdev = sb->s_bdev;
792+ struct dax_device *dax_dev;
793+ pgoff_t pgoff;
794+ int err, id;
795+ void *kaddr;
796+ pfn_t pfn;
797+ long len;
796798
797799 if (blocksize != PAGE_SIZE) {
798800 vfs_msg(sb, KERN_ERR, "error: unsupported blocksize for dax");
799801 return -EINVAL;
800802 }
801803
802− err = bdev_direct_access(sb->s_bdev, &dax);
803− if (err < 0) {
804− switch (err) {
805− case -EOPNOTSUPP:
806− vfs_msg(sb, KERN_ERR,
807− "error: device does not support dax");
808− break;
809− case -EINVAL:
810− vfs_msg(sb, KERN_ERR,
811− "error: unaligned partition for dax");
812− break;
813− default:
814− vfs_msg(sb, KERN_ERR,
815− "error: dax access failed (%d)", err);
816− }
804+ err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff);
805+ if (err) {
806+ vfs_msg(sb, KERN_ERR, "error: unaligned partition for dax");
817807 return err;
818808 }
819809
810+ dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
811+ if (!dax_dev) {
812+ vfs_msg(sb, KERN_ERR, "error: device does not support dax");
813+ return -EOPNOTSUPP;
814+ }
815+
816+ id = dax_read_lock();
817+ len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn);
818+ dax_read_unlock(id);
819+
820+ put_dax(dax_dev);
821+
822+ if (len < 1) {
823+ vfs_msg(sb, KERN_ERR,
824+ "error: dax access failed (%d)", len);
825+ return len < 0 ? len : -EIO;
826+ }
827+
820828 return 0;
821829 }
822830 EXPORT_SYMBOL_GPL(bdev_dax_supported);