Blame view

include/linux/dax.h 3.55 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
c94c2acf8   Matthew Wilcox   dax: move DAX-rel...
2
3
4
5
6
  #ifndef _LINUX_DAX_H
  #define _LINUX_DAX_H
  
  #include <linux/fs.h>
  #include <linux/mm.h>
4f622938a   Jan Kara   dax: Allow DAX co...
7
  #include <linux/radix-tree.h>
c94c2acf8   Matthew Wilcox   dax: move DAX-rel...
8
  #include <asm/pgtable.h>
a254e5681   Christoph Hellwig   dax: provide an i...
9
  struct iomap_ops;
6568b08b7   Dan Williams   dax: introduce da...
10
11
12
13
14
15
16
17
18
  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 *);
5d61e43b3   Dan Williams   dax: remove defau...
19
  	/* copy_from_iter: required operation for fs-dax direct-i/o */
0aed55af8   Dan Williams   x86, uaccess: int...
20
21
  	size_t (*copy_from_iter)(struct dax_device *, pgoff_t, void *, size_t,
  			struct iov_iter *);
6568b08b7   Dan Williams   dax: introduce da...
22
  };
a254e5681   Christoph Hellwig   dax: provide an i...
23

6e0c90d69   Dan Williams   libnvdimm, pmem, ...
24
  extern struct attribute_group dax_attribute_group;
f5705aa8c   Dan Williams   dax, xfs, ext4: c...
25
26
27
28
29
30
31
32
33
34
35
36
37
  #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
ef5104247   Dan Williams   block, dax: move ...
38
39
  int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff);
  #if IS_ENABLED(CONFIG_FS_DAX)
8214347c2   Dave Jiang   dax: change bdev_...
40
41
  bool __bdev_dax_supported(struct block_device *bdev, int blocksize);
  static inline bool bdev_dax_supported(struct block_device *bdev, int blocksize)
ef5104247   Dan Williams   block, dax: move ...
42
  {
a19385766   Darrick J. Wong   fs: allow per-dev...
43
  	return __bdev_dax_supported(bdev, blocksize);
ef5104247   Dan Williams   block, dax: move ...
44
  }
f5705aa8c   Dan Williams   dax, xfs, ext4: c...
45
46
47
48
49
50
51
52
53
54
  
  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);
  }
78f354735   Dan Williams   dax: introduce a ...
55
  struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev);
ef5104247   Dan Williams   block, dax: move ...
56
  #else
8214347c2   Dave Jiang   dax: change bdev_...
57
  static inline bool bdev_dax_supported(struct block_device *bdev,
a19385766   Darrick J. Wong   fs: allow per-dev...
58
  		int blocksize)
ef5104247   Dan Williams   block, dax: move ...
59
  {
8214347c2   Dave Jiang   dax: change bdev_...
60
  	return false;
ef5104247   Dan Williams   block, dax: move ...
61
  }
ef5104247   Dan Williams   block, dax: move ...
62

f5705aa8c   Dan Williams   dax, xfs, ext4: c...
63
  static inline struct dax_device *fs_dax_get_by_host(const char *host)
ef5104247   Dan Williams   block, dax: move ...
64
65
66
  {
  	return NULL;
  }
f5705aa8c   Dan Williams   dax, xfs, ext4: c...
67
  static inline void fs_put_dax(struct dax_device *dax_dev)
ef5104247   Dan Williams   block, dax: move ...
68
69
  {
  }
78f354735   Dan Williams   dax: introduce a ...
70
71
72
73
74
  
  static inline struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev)
  {
  	return NULL;
  }
ef5104247   Dan Williams   block, dax: move ...
75
  #endif
7b6be8444   Dan Williams   dax: refactor dax...
76
77
  int dax_read_lock(void);
  void dax_read_unlock(int id);
c1d6e828a   Dan Williams   pmem: add dax_ope...
78
79
  struct dax_device *alloc_dax(void *private, const char *host,
  		const struct dax_operations *ops);
c1d6e828a   Dan Williams   pmem: add dax_ope...
80
81
82
  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);
b0686260f   Dan Williams   dax: introduce da...
83
84
  long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
  		void **kaddr, pfn_t *pfn);
7e026c8c0   Dan Williams   dm: add ->copy_fr...
85
86
  size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
  		size_t bytes, struct iov_iter *i);
c3ca015fa   Mikulas Patocka   dax: remove the p...
87
  void dax_flush(struct dax_device *dax_dev, void *addr, size_t size);
6e0c90d69   Dan Williams   libnvdimm, pmem, ...
88
  void dax_write_cache(struct dax_device *dax_dev, bool wc);
273752c9f   Vivek Goyal   dm, dax: Make sur...
89
  bool dax_write_cache_enabled(struct dax_device *dax_dev);
7b6be8444   Dan Williams   dax: refactor dax...
90

11c59c92f   Ross Zwisler   dax: correct dax ...
91
  ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
8ff6daa17   Christoph Hellwig   iomap: constify s...
92
  		const struct iomap_ops *ops);
c791ace1e   Dave Jiang   mm: replace FAULT...
93
94
  int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size,
  		    const struct iomap_ops *ops);
ac401cc78   Jan Kara   dax: New fault lo...
95
  int dax_delete_mapping_entry(struct address_space *mapping, pgoff_t index);
c6dcf52c2   Jan Kara   mm: Invalidate DA...
96
97
  int dax_invalidate_mapping_entry_sync(struct address_space *mapping,
  				      pgoff_t index);
d1a5f2b4d   Dan Williams   block: use DAX fo...
98
99
  
  #ifdef CONFIG_FS_DAX
cccbce671   Dan Williams   filesystem-dax: c...
100
101
  int __dax_zero_page_range(struct block_device *bdev,
  		struct dax_device *dax_dev, sector_t sector,
679c8bd3b   Christoph Hellwig   dax: export a low...
102
  		unsigned int offset, unsigned int length);
d1a5f2b4d   Dan Williams   block: use DAX fo...
103
  #else
679c8bd3b   Christoph Hellwig   dax: export a low...
104
  static inline int __dax_zero_page_range(struct block_device *bdev,
cccbce671   Dan Williams   filesystem-dax: c...
105
106
  		struct dax_device *dax_dev, sector_t sector,
  		unsigned int offset, unsigned int length)
679c8bd3b   Christoph Hellwig   dax: export a low...
107
108
109
  {
  	return -ENXIO;
  }
d1a5f2b4d   Dan Williams   block: use DAX fo...
110
  #endif
f9fe48bec   Ross Zwisler   dax: support dirt...
111
112
113
114
  static inline bool dax_mapping(struct address_space *mapping)
  {
  	return mapping->host && IS_DAX(mapping->host);
  }
7f6d5b529   Ross Zwisler   dax: move writeba...
115
116
117
118
  
  struct writeback_control;
  int dax_writeback_mapping_range(struct address_space *mapping,
  		struct block_device *bdev, struct writeback_control *wbc);
c94c2acf8   Matthew Wilcox   dax: move DAX-rel...
119
  #endif