Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <anna.schumaker@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

authored by

Anna Schumaker and committed by
Trond Myklebust
288d7224 3c91e4b7

+12 -5
+8 -2
fs/nfs/client.c
··· 100 100 if (!nfs) 101 101 return ERR_PTR(-EPROTONOSUPPORT); 102 102 103 - if (!try_module_get(nfs->owner)) 103 + if (!get_nfs_version(nfs)) 104 104 return ERR_PTR(-EAGAIN); 105 105 106 106 return nfs; 107 107 } 108 + 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); 108 114 109 115 void put_nfs_version(struct nfs_subversion *nfs) 110 116 { ··· 155 149 156 150 clp->cl_minorversion = cl_init->minorversion; 157 151 clp->cl_nfs_mod = cl_init->nfs_mod; 158 - if (!try_module_get(clp->cl_nfs_mod->owner)) 152 + if (!get_nfs_version(clp->cl_nfs_mod)) 159 153 goto error_dealloc; 160 154 161 155 clp->rpc_ops = clp->cl_nfs_mod->rpc_ops;
+2 -2
fs/nfs/fs_context.c
··· 1541 1541 } 1542 1542 nfs_copy_fh(ctx->mntfh, src->mntfh); 1543 1543 1544 - __module_get(ctx->nfs_mod->owner); 1544 + get_nfs_version(ctx->nfs_mod); 1545 1545 ctx->client_address = NULL; 1546 1546 ctx->mount_server.hostname = NULL; 1547 1547 ctx->nfs_server.export_path = NULL; ··· 1633 1633 } 1634 1634 1635 1635 ctx->nfs_mod = nfss->nfs_client->cl_nfs_mod; 1636 - __module_get(ctx->nfs_mod->owner); 1636 + get_nfs_version(ctx->nfs_mod); 1637 1637 } else { 1638 1638 /* defaults */ 1639 1639 ctx->timeo = NFS_UNSPEC_TIMEO;
+1 -1
fs/nfs/namespace.c
··· 182 182 ctx->version = client->rpc_ops->version; 183 183 ctx->minorversion = client->cl_minorversion; 184 184 ctx->nfs_mod = client->cl_nfs_mod; 185 - __module_get(ctx->nfs_mod->owner); 185 + get_nfs_version(ctx->nfs_mod); 186 186 187 187 ret = client->rpc_ops->submount(fc, server); 188 188 if (ret < 0) {
+1
fs/nfs/nfs.h
··· 22 22 }; 23 23 24 24 struct nfs_subversion *find_nfs_version(unsigned int); 25 + int get_nfs_version(struct nfs_subversion *); 25 26 void put_nfs_version(struct nfs_subversion *); 26 27 void register_nfs_version(struct nfs_subversion *); 27 28 void unregister_nfs_version(struct nfs_subversion *);