Skip to content

Commit 1b76460

Browse files
Christoph Hellwigdjbw
authored andcommitted
dax: mark dax_get_by_host static
And move the code around a bit to avoid a forward declaration. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Dan Williams <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent dfa584f commit 1b76460

File tree

2 files changed

+54
-60
lines changed

2 files changed

+54
-60
lines changed

drivers/dax/super.c

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@
1717
#include <linux/fs.h>
1818
#include "dax-private.h"
1919

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+
2038
static dev_t dax_devt;
2139
DEFINE_STATIC_SRCU(dax_srcu);
2240
static struct vfsmount *dax_mnt;
@@ -40,6 +58,42 @@ void dax_read_unlock(int id)
4058
}
4159
EXPORT_SYMBOL_GPL(dax_read_unlock);
4260

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+
4397
#ifdef CONFIG_BLOCK
4498
#include <linux/blkdev.h>
4599

@@ -202,24 +256,6 @@ enum dax_device_flags {
202256
DAXDEV_SYNC,
203257
};
204258

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-
223259
static ssize_t write_cache_show(struct device *dev,
224260
struct device_attribute *attr, char *buf)
225261
{
@@ -417,11 +453,6 @@ bool dax_alive(struct dax_device *dax_dev)
417453
}
418454
EXPORT_SYMBOL_GPL(dax_alive);
419455

420-
static int dax_host_hash(const char *host)
421-
{
422-
return hashlen_hash(hashlen_string("DAX", host)) % DAX_HASH_SIZE;
423-
}
424-
425456
/*
426457
* Note, rcu is not protecting the liveness of dax_dev, rcu is ensuring
427458
* that any fault handlers or operations that might have seen
@@ -618,38 +649,6 @@ void put_dax(struct dax_device *dax_dev)
618649
}
619650
EXPORT_SYMBOL_GPL(put_dax);
620651

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-
653652
/**
654653
* inode_dax: convert a public inode into its dax_dev
655654
* @inode: An inode with i_cdev pointing to a dax_dev

include/linux/dax.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ struct dax_operations {
4141
extern struct attribute_group dax_attribute_group;
4242

4343
#if IS_ENABLED(CONFIG_DAX)
44-
struct dax_device *dax_get_by_host(const char *host);
4544
struct dax_device *alloc_dax(void *private, const char *host,
4645
const struct dax_operations *ops, unsigned long flags);
4746
void put_dax(struct dax_device *dax_dev);
@@ -73,10 +72,6 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
7372
return dax_synchronous(dax_dev);
7473
}
7574
#else
76-
static inline struct dax_device *dax_get_by_host(const char *host)
77-
{
78-
return NULL;
79-
}
8075
static inline struct dax_device *alloc_dax(void *private, const char *host,
8176
const struct dax_operations *ops, unsigned long flags)
8277
{

0 commit comments

Comments
 (0)