]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
NFS: Implement get_nfs_version()
authorAnna Schumaker <anna.schumaker@oracle.com>
Tue, 1 Oct 2024 20:33:44 +0000 (16:33 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 8 Nov 2024 19:17:37 +0000 (14:17 -0500)
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 <anna.schumaker@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/client.c
fs/nfs/fs_context.c
fs/nfs/namespace.c
fs/nfs/nfs.h

index 4c94fe419c406ec7993776deb62ccbd164c364bb..550ca934c9cfca57446661afbab381733a25a92d 100644 (file)
@@ -100,12 +100,18 @@ struct nfs_subversion *find_nfs_version(unsigned int version)
        if (!nfs)
                return ERR_PTR(-EPROTONOSUPPORT);
 
-       if (!try_module_get(nfs->owner))
+       if (!get_nfs_version(nfs))
                return ERR_PTR(-EAGAIN);
 
        return nfs;
 }
 
+int get_nfs_version(struct nfs_subversion *nfs)
+{
+       return try_module_get(nfs->owner);
+}
+EXPORT_SYMBOL_GPL(get_nfs_version);
+
 void put_nfs_version(struct nfs_subversion *nfs)
 {
        module_put(nfs->owner);
@@ -149,7 +155,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
 
        clp->cl_minorversion = cl_init->minorversion;
        clp->cl_nfs_mod = cl_init->nfs_mod;
-       if (!try_module_get(clp->cl_nfs_mod->owner))
+       if (!get_nfs_version(clp->cl_nfs_mod))
                goto error_dealloc;
 
        clp->rpc_ops = clp->cl_nfs_mod->rpc_ops;
index d553daa4c09ca35a4a11d7d7d6d91109f2014d73..b069385eea176766591cb7fd010f7efed687c34a 100644 (file)
@@ -1541,7 +1541,7 @@ static int nfs_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc)
        }
        nfs_copy_fh(ctx->mntfh, src->mntfh);
 
-       __module_get(ctx->nfs_mod->owner);
+       get_nfs_version(ctx->nfs_mod);
        ctx->client_address             = NULL;
        ctx->mount_server.hostname      = NULL;
        ctx->nfs_server.export_path     = NULL;
@@ -1633,7 +1633,7 @@ static int nfs_init_fs_context(struct fs_context *fc)
                }
 
                ctx->nfs_mod = nfss->nfs_client->cl_nfs_mod;
-               __module_get(ctx->nfs_mod->owner);
+               get_nfs_version(ctx->nfs_mod);
        } else {
                /* defaults */
                ctx->timeo              = NFS_UNSPEC_TIMEO;
index e7494cdd957e51bfc830df03dc2f74c8848d1f45..2d53574da6059093e89ee4761b930ec20dd10968 100644 (file)
@@ -182,7 +182,7 @@ struct vfsmount *nfs_d_automount(struct path *path)
        ctx->version            = client->rpc_ops->version;
        ctx->minorversion       = client->cl_minorversion;
        ctx->nfs_mod            = client->cl_nfs_mod;
-       __module_get(ctx->nfs_mod->owner);
+       get_nfs_version(ctx->nfs_mod);
 
        ret = client->rpc_ops->submount(fc, server);
        if (ret < 0) {
index a30bf8ef79d7de915592fc5afcab6076bd0bfb13..8a5f51be013a6ab4c1557934246fa56911cc72ce 100644 (file)
@@ -22,6 +22,7 @@ struct nfs_subversion {
 };
 
 struct nfs_subversion *find_nfs_version(unsigned int);
+int get_nfs_version(struct nfs_subversion *);
 void put_nfs_version(struct nfs_subversion *);
 void register_nfs_version(struct nfs_subversion *);
 void unregister_nfs_version(struct nfs_subversion *);