@@ -63,6 +63,24 @@ static int dax_host_hash(const char *host)
63
63
return hashlen_hash (hashlen_string ("DAX" , host )) % DAX_HASH_SIZE ;
64
64
}
65
65
66
+ #ifdef CONFIG_BLOCK
67
+ #include <linux/blkdev.h>
68
+
69
+ int bdev_dax_pgoff (struct block_device * bdev , sector_t sector , size_t size ,
70
+ pgoff_t * pgoff )
71
+ {
72
+ sector_t start_sect = bdev ? get_start_sect (bdev ) : 0 ;
73
+ phys_addr_t phys_off = (start_sect + sector ) * 512 ;
74
+
75
+ if (pgoff )
76
+ * pgoff = PHYS_PFN (phys_off );
77
+ if (phys_off % PAGE_SIZE || size % PAGE_SIZE )
78
+ return - EINVAL ;
79
+ return 0 ;
80
+ }
81
+ EXPORT_SYMBOL (bdev_dax_pgoff );
82
+
83
+ #if IS_ENABLED (CONFIG_FS_DAX )
66
84
/**
67
85
* dax_get_by_host() - temporary lookup mechanism for filesystem-dax
68
86
* @host: alternate name for the device registered by a dax driver
@@ -94,24 +112,6 @@ static struct dax_device *dax_get_by_host(const char *host)
94
112
return found ;
95
113
}
96
114
97
- #ifdef CONFIG_BLOCK
98
- #include <linux/blkdev.h>
99
-
100
- int bdev_dax_pgoff (struct block_device * bdev , sector_t sector , size_t size ,
101
- pgoff_t * pgoff )
102
- {
103
- sector_t start_sect = bdev ? get_start_sect (bdev ) : 0 ;
104
- phys_addr_t phys_off = (start_sect + sector ) * 512 ;
105
-
106
- if (pgoff )
107
- * pgoff = PHYS_PFN (phys_off );
108
- if (phys_off % PAGE_SIZE || size % PAGE_SIZE )
109
- return - EINVAL ;
110
- return 0 ;
111
- }
112
- EXPORT_SYMBOL (bdev_dax_pgoff );
113
-
114
- #if IS_ENABLED (CONFIG_FS_DAX )
115
115
struct dax_device * fs_dax_get_by_bdev (struct block_device * bdev )
116
116
{
117
117
if (!blk_queue_dax (bdev -> bd_disk -> queue ))
@@ -231,70 +231,6 @@ enum dax_device_flags {
231
231
DAXDEV_SYNC ,
232
232
};
233
233
234
- static ssize_t write_cache_show (struct device * dev ,
235
- struct device_attribute * attr , char * buf )
236
- {
237
- struct dax_device * dax_dev = dax_get_by_host (dev_name (dev ));
238
- ssize_t rc ;
239
-
240
- WARN_ON_ONCE (!dax_dev );
241
- if (!dax_dev )
242
- return - ENXIO ;
243
-
244
- rc = sprintf (buf , "%d\n" , !!dax_write_cache_enabled (dax_dev ));
245
- put_dax (dax_dev );
246
- return rc ;
247
- }
248
-
249
- static ssize_t write_cache_store (struct device * dev ,
250
- struct device_attribute * attr , const char * buf , size_t len )
251
- {
252
- bool write_cache ;
253
- int rc = strtobool (buf , & write_cache );
254
- struct dax_device * dax_dev = dax_get_by_host (dev_name (dev ));
255
-
256
- WARN_ON_ONCE (!dax_dev );
257
- if (!dax_dev )
258
- return - ENXIO ;
259
-
260
- if (rc )
261
- len = rc ;
262
- else
263
- dax_write_cache (dax_dev , write_cache );
264
-
265
- put_dax (dax_dev );
266
- return len ;
267
- }
268
- static DEVICE_ATTR_RW (write_cache );
269
-
270
- static umode_t dax_visible (struct kobject * kobj , struct attribute * a , int n )
271
- {
272
- struct device * dev = container_of (kobj , typeof (* dev ), kobj );
273
- struct dax_device * dax_dev = dax_get_by_host (dev_name (dev ));
274
-
275
- WARN_ON_ONCE (!dax_dev );
276
- if (!dax_dev )
277
- return 0 ;
278
-
279
- #ifndef CONFIG_ARCH_HAS_PMEM_API
280
- if (a == & dev_attr_write_cache .attr )
281
- return 0 ;
282
- #endif
283
- return a -> mode ;
284
- }
285
-
286
- static struct attribute * dax_attributes [] = {
287
- & dev_attr_write_cache .attr ,
288
- NULL ,
289
- };
290
-
291
- struct attribute_group dax_attribute_group = {
292
- .name = "dax" ,
293
- .attrs = dax_attributes ,
294
- .is_visible = dax_visible ,
295
- };
296
- EXPORT_SYMBOL_GPL (dax_attribute_group );
297
-
298
234
/**
299
235
* dax_direct_access() - translate a device pgoff to an absolute pfn
300
236
* @dax_dev: a dax_device instance representing the logical memory range
0 commit comments