17
17
#include <linux/fs.h>
18
18
#include "dax-private.h"
19
19
20
+ /**
21
+ * struct dax_device - anchor object for dax services
22
+ * @inode: core vfs
23
+ * @cdev: optional character interface for "device dax"
24
+ * @host: optional name for lookups where the device path is not available
25
+ * @private: dax driver private data
26
+ * @flags: state and boolean properties
27
+ */
28
+ struct dax_device {
29
+ struct hlist_node list ;
30
+ struct inode inode ;
31
+ struct cdev cdev ;
32
+ const char * host ;
33
+ void * private ;
34
+ unsigned long flags ;
35
+ const struct dax_operations * ops ;
36
+ };
37
+
20
38
static dev_t dax_devt ;
21
39
DEFINE_STATIC_SRCU (dax_srcu );
22
40
static struct vfsmount * dax_mnt ;
@@ -40,6 +58,42 @@ void dax_read_unlock(int id)
40
58
}
41
59
EXPORT_SYMBOL_GPL (dax_read_unlock );
42
60
61
+ static int dax_host_hash (const char * host )
62
+ {
63
+ return hashlen_hash (hashlen_string ("DAX" , host )) % DAX_HASH_SIZE ;
64
+ }
65
+
66
+ /**
67
+ * dax_get_by_host() - temporary lookup mechanism for filesystem-dax
68
+ * @host: alternate name for the device registered by a dax driver
69
+ */
70
+ static struct dax_device * dax_get_by_host (const char * host )
71
+ {
72
+ struct dax_device * dax_dev , * found = NULL ;
73
+ int hash , id ;
74
+
75
+ if (!host )
76
+ return NULL ;
77
+
78
+ hash = dax_host_hash (host );
79
+
80
+ id = dax_read_lock ();
81
+ spin_lock (& dax_host_lock );
82
+ hlist_for_each_entry (dax_dev , & dax_host_list [hash ], list ) {
83
+ if (!dax_alive (dax_dev )
84
+ || strcmp (host , dax_dev -> host ) != 0 )
85
+ continue ;
86
+
87
+ if (igrab (& dax_dev -> inode ))
88
+ found = dax_dev ;
89
+ break ;
90
+ }
91
+ spin_unlock (& dax_host_lock );
92
+ dax_read_unlock (id );
93
+
94
+ return found ;
95
+ }
96
+
43
97
#ifdef CONFIG_BLOCK
44
98
#include <linux/blkdev.h>
45
99
@@ -202,24 +256,6 @@ enum dax_device_flags {
202
256
DAXDEV_SYNC ,
203
257
};
204
258
205
- /**
206
- * struct dax_device - anchor object for dax services
207
- * @inode: core vfs
208
- * @cdev: optional character interface for "device dax"
209
- * @host: optional name for lookups where the device path is not available
210
- * @private: dax driver private data
211
- * @flags: state and boolean properties
212
- */
213
- struct dax_device {
214
- struct hlist_node list ;
215
- struct inode inode ;
216
- struct cdev cdev ;
217
- const char * host ;
218
- void * private ;
219
- unsigned long flags ;
220
- const struct dax_operations * ops ;
221
- };
222
-
223
259
static ssize_t write_cache_show (struct device * dev ,
224
260
struct device_attribute * attr , char * buf )
225
261
{
@@ -417,11 +453,6 @@ bool dax_alive(struct dax_device *dax_dev)
417
453
}
418
454
EXPORT_SYMBOL_GPL (dax_alive );
419
455
420
- static int dax_host_hash (const char * host )
421
- {
422
- return hashlen_hash (hashlen_string ("DAX" , host )) % DAX_HASH_SIZE ;
423
- }
424
-
425
456
/*
426
457
* Note, rcu is not protecting the liveness of dax_dev, rcu is ensuring
427
458
* that any fault handlers or operations that might have seen
@@ -618,38 +649,6 @@ void put_dax(struct dax_device *dax_dev)
618
649
}
619
650
EXPORT_SYMBOL_GPL (put_dax );
620
651
621
- /**
622
- * dax_get_by_host() - temporary lookup mechanism for filesystem-dax
623
- * @host: alternate name for the device registered by a dax driver
624
- */
625
- struct dax_device * dax_get_by_host (const char * host )
626
- {
627
- struct dax_device * dax_dev , * found = NULL ;
628
- int hash , id ;
629
-
630
- if (!host )
631
- return NULL ;
632
-
633
- hash = dax_host_hash (host );
634
-
635
- id = dax_read_lock ();
636
- spin_lock (& dax_host_lock );
637
- hlist_for_each_entry (dax_dev , & dax_host_list [hash ], list ) {
638
- if (!dax_alive (dax_dev )
639
- || strcmp (host , dax_dev -> host ) != 0 )
640
- continue ;
641
-
642
- if (igrab (& dax_dev -> inode ))
643
- found = dax_dev ;
644
- break ;
645
- }
646
- spin_unlock (& dax_host_lock );
647
- dax_read_unlock (id );
648
-
649
- return found ;
650
- }
651
- EXPORT_SYMBOL_GPL (dax_get_by_host );
652
-
653
652
/**
654
653
* inode_dax: convert a public inode into its dax_dev
655
654
* @inode: An inode with i_cdev pointing to a dax_dev
0 commit comments