2015-09-09 00:58:40 +03:00
|
|
|
#ifndef _LINUX_DAX_H
|
|
|
|
#define _LINUX_DAX_H
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/mm.h>
|
2016-05-12 19:29:17 +03:00
|
|
|
#include <linux/radix-tree.h>
|
2015-09-09 00:58:40 +03:00
|
|
|
#include <asm/pgtable.h>
|
|
|
|
|
2016-09-19 04:24:49 +03:00
|
|
|
struct iomap_ops;
|
2017-01-25 05:44:18 +03:00
|
|
|
struct dax_device;
|
|
|
|
struct dax_operations {
|
|
|
|
/*
|
|
|
|
* direct_access: translate a device-relative
|
|
|
|
* logical-page-offset into an absolute physical pfn. Return the
|
|
|
|
* number of pages available for DAX at that pfn.
|
|
|
|
*/
|
|
|
|
long (*direct_access)(struct dax_device *, pgoff_t, long,
|
|
|
|
void **, pfn_t *);
|
2017-06-27 23:06:22 +03:00
|
|
|
/* copy_from_iter: required operation for fs-dax direct-i/o */
|
2017-05-29 22:22:50 +03:00
|
|
|
size_t (*copy_from_iter)(struct dax_device *, pgoff_t, void *, size_t,
|
|
|
|
struct iov_iter *);
|
2017-01-25 05:44:18 +03:00
|
|
|
};
|
2016-09-19 04:24:49 +03:00
|
|
|
|
2017-06-27 07:28:41 +03:00
|
|
|
extern struct attribute_group dax_attribute_group;
|
|
|
|
|
2017-05-14 02:31:05 +03:00
|
|
|
#if IS_ENABLED(CONFIG_DAX)
|
|
|
|
struct dax_device *dax_get_by_host(const char *host);
|
|
|
|
void put_dax(struct dax_device *dax_dev);
|
|
|
|
#else
|
|
|
|
static inline struct dax_device *dax_get_by_host(const char *host)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void put_dax(struct dax_device *dax_dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-08 20:55:27 +03:00
|
|
|
int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff);
|
|
|
|
#if IS_ENABLED(CONFIG_FS_DAX)
|
|
|
|
int __bdev_dax_supported(struct super_block *sb, int blocksize);
|
|
|
|
static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
|
|
|
|
{
|
|
|
|
return __bdev_dax_supported(sb, blocksize);
|
|
|
|
}
|
2017-05-14 02:31:05 +03:00
|
|
|
|
|
|
|
static inline struct dax_device *fs_dax_get_by_host(const char *host)
|
|
|
|
{
|
|
|
|
return dax_get_by_host(host);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void fs_put_dax(struct dax_device *dax_dev)
|
|
|
|
{
|
|
|
|
put_dax(dax_dev);
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:16:38 +03:00
|
|
|
struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev);
|
2017-05-08 20:55:27 +03:00
|
|
|
#else
|
|
|
|
static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2017-05-14 02:31:05 +03:00
|
|
|
static inline struct dax_device *fs_dax_get_by_host(const char *host)
|
2017-05-08 20:55:27 +03:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-05-14 02:31:05 +03:00
|
|
|
static inline void fs_put_dax(struct dax_device *dax_dev)
|
2017-05-08 20:55:27 +03:00
|
|
|
{
|
|
|
|
}
|
2017-08-30 19:16:38 +03:00
|
|
|
|
|
|
|
static inline struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-05-08 20:55:27 +03:00
|
|
|
#endif
|
|
|
|
|
2017-04-11 19:49:49 +03:00
|
|
|
int dax_read_lock(void);
|
|
|
|
void dax_read_unlock(int id);
|
2017-01-25 10:02:09 +03:00
|
|
|
struct dax_device *alloc_dax(void *private, const char *host,
|
|
|
|
const struct dax_operations *ops);
|
|
|
|
bool dax_alive(struct dax_device *dax_dev);
|
|
|
|
void kill_dax(struct dax_device *dax_dev);
|
|
|
|
void *dax_get_private(struct dax_device *dax_dev);
|
2017-01-27 07:37:35 +03:00
|
|
|
long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
|
|
|
|
void **kaddr, pfn_t *pfn);
|
2017-05-29 22:57:56 +03:00
|
|
|
size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
|
|
|
|
size_t bytes, struct iov_iter *i);
|
2017-09-01 04:47:43 +03:00
|
|
|
void dax_flush(struct dax_device *dax_dev, void *addr, size_t size);
|
2017-06-27 07:28:41 +03:00
|
|
|
void dax_write_cache(struct dax_device *dax_dev, bool wc);
|
2017-07-26 16:35:09 +03:00
|
|
|
bool dax_write_cache_enabled(struct dax_device *dax_dev);
|
2017-04-11 19:49:49 +03:00
|
|
|
|
2016-11-08 03:32:46 +03:00
|
|
|
ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
|
2017-01-28 10:20:26 +03:00
|
|
|
const struct iomap_ops *ops);
|
2017-02-25 01:57:08 +03:00
|
|
|
int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size,
|
|
|
|
const struct iomap_ops *ops);
|
2016-05-12 19:29:18 +03:00
|
|
|
int dax_delete_mapping_entry(struct address_space *mapping, pgoff_t index);
|
2016-08-10 18:22:44 +03:00
|
|
|
int dax_invalidate_mapping_entry_sync(struct address_space *mapping,
|
|
|
|
pgoff_t index);
|
2016-01-29 07:25:31 +03:00
|
|
|
|
|
|
|
#ifdef CONFIG_FS_DAX
|
2017-01-28 00:31:42 +03:00
|
|
|
int __dax_zero_page_range(struct block_device *bdev,
|
|
|
|
struct dax_device *dax_dev, sector_t sector,
|
2016-05-09 11:47:04 +03:00
|
|
|
unsigned int offset, unsigned int length);
|
2016-01-29 07:25:31 +03:00
|
|
|
#else
|
2016-05-09 11:47:04 +03:00
|
|
|
static inline int __dax_zero_page_range(struct block_device *bdev,
|
2017-01-28 00:31:42 +03:00
|
|
|
struct dax_device *dax_dev, sector_t sector,
|
|
|
|
unsigned int offset, unsigned int length)
|
2016-05-09 11:47:04 +03:00
|
|
|
{
|
|
|
|
return -ENXIO;
|
|
|
|
}
|
2016-01-29 07:25:31 +03:00
|
|
|
#endif
|
|
|
|
|
2016-01-23 02:10:40 +03:00
|
|
|
static inline bool dax_mapping(struct address_space *mapping)
|
|
|
|
{
|
|
|
|
return mapping->host && IS_DAX(mapping->host);
|
|
|
|
}
|
2016-02-27 02:19:55 +03:00
|
|
|
|
|
|
|
struct writeback_control;
|
|
|
|
int dax_writeback_mapping_range(struct address_space *mapping,
|
|
|
|
struct block_device *bdev, struct writeback_control *wbc);
|
2015-09-09 00:58:40 +03:00
|
|
|
#endif
|