mirror of https://gitee.com/openkylin/linux.git
block, dax: convert bdev_dax_supported() to dax_direct_access()
Kill of the final user of bdev_direct_access() and struct blk_dax_ctl. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
cccbce6715
commit
2093f2e9df
|
@ -788,35 +788,43 @@ EXPORT_SYMBOL(bdev_dax_pgoff);
|
|||
*/
|
||||
int bdev_dax_supported(struct super_block *sb, int blocksize)
|
||||
{
|
||||
struct blk_dax_ctl dax = {
|
||||
.sector = 0,
|
||||
.size = PAGE_SIZE,
|
||||
};
|
||||
int err;
|
||||
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;
|
||||
|
||||
if (blocksize != PAGE_SIZE) {
|
||||
vfs_msg(sb, KERN_ERR, "error: unsupported blocksize for dax");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = bdev_direct_access(sb->s_bdev, &dax);
|
||||
if (err < 0) {
|
||||
switch (err) {
|
||||
case -EOPNOTSUPP:
|
||||
vfs_msg(sb, KERN_ERR,
|
||||
"error: device does not support dax");
|
||||
break;
|
||||
case -EINVAL:
|
||||
vfs_msg(sb, KERN_ERR,
|
||||
"error: unaligned partition for dax");
|
||||
break;
|
||||
default:
|
||||
vfs_msg(sb, KERN_ERR,
|
||||
"error: dax access failed (%d)", err);
|
||||
}
|
||||
err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff);
|
||||
if (err) {
|
||||
vfs_msg(sb, KERN_ERR, "error: unaligned partition for dax");
|
||||
return err;
|
||||
}
|
||||
|
||||
dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
|
||||
if (!dax_dev) {
|
||||
vfs_msg(sb, KERN_ERR, "error: device does not support dax");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
id = dax_read_lock();
|
||||
len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn);
|
||||
dax_read_unlock(id);
|
||||
|
||||
put_dax(dax_dev);
|
||||
|
||||
if (len < 1) {
|
||||
vfs_msg(sb, KERN_ERR,
|
||||
"error: dax access failed (%d)", len);
|
||||
return len < 0 ? len : -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bdev_dax_supported);
|
||||
|
|
Loading…
Reference in New Issue