Skip to content

Commit 11eb537

Browse files
Anna SchumakerTrond Myklebust
authored andcommitted
NFS: Convert the NFS module list into an array
Using a linked list here seems unnecessarily complex, especially since possible index values are '2', '3', and '4'. Let's just use an array for direct access. Signed-off-by: Anna Schumaker <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 6278c86 commit 11eb537

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

fs/nfs/client.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@
5656

5757
static DECLARE_WAIT_QUEUE_HEAD(nfs_client_active_wq);
5858
static DEFINE_RWLOCK(nfs_version_lock);
59-
static LIST_HEAD(nfs_versions);
59+
60+
static struct nfs_subversion *nfs_version_mods[5] = {
61+
[2] = NULL,
62+
[3] = NULL,
63+
[4] = NULL,
64+
};
6065

6166
/*
6267
* RPC cruft for NFS
@@ -78,17 +83,14 @@ const struct rpc_program nfs_program = {
7883
static struct nfs_subversion *find_nfs_version(unsigned int version)
7984
{
8085
struct nfs_subversion *nfs;
81-
read_lock(&nfs_version_lock);
82-
83-
list_for_each_entry(nfs, &nfs_versions, list) {
84-
if (nfs->rpc_ops->version == version) {
85-
read_unlock(&nfs_version_lock);
86-
return nfs;
87-
}
88-
}
8986

87+
read_lock(&nfs_version_lock);
88+
nfs = nfs_version_mods[version];
9089
read_unlock(&nfs_version_lock);
91-
return ERR_PTR(-EPROTONOSUPPORT);
90+
91+
if (nfs == NULL)
92+
return ERR_PTR(-EPROTONOSUPPORT);
93+
return nfs;
9294
}
9395

9496
struct nfs_subversion *get_nfs_version(unsigned int version)
@@ -114,7 +116,7 @@ void register_nfs_version(struct nfs_subversion *nfs)
114116
{
115117
write_lock(&nfs_version_lock);
116118

117-
list_add(&nfs->list, &nfs_versions);
119+
nfs_version_mods[nfs->rpc_ops->version] = nfs;
118120
nfs_version[nfs->rpc_ops->version] = nfs->rpc_vers;
119121

120122
write_unlock(&nfs_version_lock);
@@ -126,7 +128,7 @@ void unregister_nfs_version(struct nfs_subversion *nfs)
126128
write_lock(&nfs_version_lock);
127129

128130
nfs_version[nfs->rpc_ops->version] = NULL;
129-
list_del(&nfs->list);
131+
nfs_version_mods[nfs->rpc_ops->version] = NULL;
130132

131133
write_unlock(&nfs_version_lock);
132134
}

fs/nfs/nfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct nfs_subversion {
1919
const struct nfs_rpc_ops *rpc_ops; /* NFS operations */
2020
const struct super_operations *sops; /* NFS Super operations */
2121
const struct xattr_handler * const *xattr; /* NFS xattr handlers */
22-
struct list_head list; /* List of NFS versions */
2322
};
2423

2524
struct nfs_subversion *get_nfs_version(unsigned int);

0 commit comments

Comments
 (0)