Skip to content

Commit 288d722

Browse files
Anna SchumakerTrond Myklebust
authored andcommitted
NFS: Implement get_nfs_version()
This is a pair for put_nfs_version(), and is used for incrementing the reference count on the nfs version module. I also updated the callers I could find who had this hardcoded up until now. Signed-off-by: Anna Schumaker <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 3c91e4b commit 288d722

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

fs/nfs/client.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,18 @@ struct nfs_subversion *find_nfs_version(unsigned int version)
100100
if (!nfs)
101101
return ERR_PTR(-EPROTONOSUPPORT);
102102

103-
if (!try_module_get(nfs->owner))
103+
if (!get_nfs_version(nfs))
104104
return ERR_PTR(-EAGAIN);
105105

106106
return nfs;
107107
}
108108

109+
int get_nfs_version(struct nfs_subversion *nfs)
110+
{
111+
return try_module_get(nfs->owner);
112+
}
113+
EXPORT_SYMBOL_GPL(get_nfs_version);
114+
109115
void put_nfs_version(struct nfs_subversion *nfs)
110116
{
111117
module_put(nfs->owner);
@@ -149,7 +155,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
149155

150156
clp->cl_minorversion = cl_init->minorversion;
151157
clp->cl_nfs_mod = cl_init->nfs_mod;
152-
if (!try_module_get(clp->cl_nfs_mod->owner))
158+
if (!get_nfs_version(clp->cl_nfs_mod))
153159
goto error_dealloc;
154160

155161
clp->rpc_ops = clp->cl_nfs_mod->rpc_ops;

fs/nfs/fs_context.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ static int nfs_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc)
15411541
}
15421542
nfs_copy_fh(ctx->mntfh, src->mntfh);
15431543

1544-
__module_get(ctx->nfs_mod->owner);
1544+
get_nfs_version(ctx->nfs_mod);
15451545
ctx->client_address = NULL;
15461546
ctx->mount_server.hostname = NULL;
15471547
ctx->nfs_server.export_path = NULL;
@@ -1633,7 +1633,7 @@ static int nfs_init_fs_context(struct fs_context *fc)
16331633
}
16341634

16351635
ctx->nfs_mod = nfss->nfs_client->cl_nfs_mod;
1636-
__module_get(ctx->nfs_mod->owner);
1636+
get_nfs_version(ctx->nfs_mod);
16371637
} else {
16381638
/* defaults */
16391639
ctx->timeo = NFS_UNSPEC_TIMEO;

fs/nfs/namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ struct vfsmount *nfs_d_automount(struct path *path)
182182
ctx->version = client->rpc_ops->version;
183183
ctx->minorversion = client->cl_minorversion;
184184
ctx->nfs_mod = client->cl_nfs_mod;
185-
__module_get(ctx->nfs_mod->owner);
185+
get_nfs_version(ctx->nfs_mod);
186186

187187
ret = client->rpc_ops->submount(fc, server);
188188
if (ret < 0) {

fs/nfs/nfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct nfs_subversion {
2222
};
2323

2424
struct nfs_subversion *find_nfs_version(unsigned int);
25+
int get_nfs_version(struct nfs_subversion *);
2526
void put_nfs_version(struct nfs_subversion *);
2627
void register_nfs_version(struct nfs_subversion *);
2728
void unregister_nfs_version(struct nfs_subversion *);

0 commit comments

Comments
 (0)