mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
dax: introduce a fs_dax_get_by_bdev() helper
Add a helper that can replace the following common pattern: if (blk_queue_dax(bdev->bd_queue)) fs_dax_get_by_host(bdev->bd_disk->disk_name); This will be used to move dax_device lookup from iomap-operation time to fs-mount time. Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
14ccee78fc
commit
78f3547350
2 changed files with 16 additions and 0 deletions
|
@ -46,6 +46,8 @@ void dax_read_unlock(int id)
|
||||||
EXPORT_SYMBOL_GPL(dax_read_unlock);
|
EXPORT_SYMBOL_GPL(dax_read_unlock);
|
||||||
|
|
||||||
#ifdef CONFIG_BLOCK
|
#ifdef CONFIG_BLOCK
|
||||||
|
#include <linux/blkdev.h>
|
||||||
|
|
||||||
int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size,
|
int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size,
|
||||||
pgoff_t *pgoff)
|
pgoff_t *pgoff)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +61,14 @@ int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(bdev_dax_pgoff);
|
EXPORT_SYMBOL(bdev_dax_pgoff);
|
||||||
|
|
||||||
|
struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev)
|
||||||
|
{
|
||||||
|
if (!blk_queue_dax(bdev->bd_queue))
|
||||||
|
return NULL;
|
||||||
|
return fs_dax_get_by_host(bdev->bd_disk->disk_name);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __bdev_dax_supported() - Check if the device supports dax for filesystem
|
* __bdev_dax_supported() - Check if the device supports dax for filesystem
|
||||||
* @sb: The superblock of the device
|
* @sb: The superblock of the device
|
||||||
|
|
|
@ -57,6 +57,7 @@ static inline void fs_put_dax(struct dax_device *dax_dev)
|
||||||
put_dax(dax_dev);
|
put_dax(dax_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev);
|
||||||
#else
|
#else
|
||||||
static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
|
static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
|
||||||
{
|
{
|
||||||
|
@ -71,6 +72,11 @@ static inline struct dax_device *fs_dax_get_by_host(const char *host)
|
||||||
static inline void fs_put_dax(struct dax_device *dax_dev)
|
static inline void fs_put_dax(struct dax_device *dax_dev)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int dax_read_lock(void);
|
int dax_read_lock(void);
|
||||||
|
|
Loading…
Reference in a new issue