~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/nfs/nfs3client.c

Version: ~ [ linux-5.13-rc5 ] ~ [ linux-5.12.9 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.42 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.124 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.193 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.235 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.271 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.271 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <linux/nfs_fs.h>
  2 #include <linux/nfs_mount.h>
  3 #include <linux/sunrpc/addr.h>
  4 #include "internal.h"
  5 #include "nfs3_fs.h"
  6 
  7 #ifdef CONFIG_NFS_V3_ACL
  8 static struct rpc_stat          nfsacl_rpcstat = { &nfsacl_program };
  9 static const struct rpc_version *nfsacl_version[] = {
 10         [3]                     = &nfsacl_version3,
 11 };
 12 
 13 const struct rpc_program nfsacl_program = {
 14         .name                   = "nfsacl",
 15         .number                 = NFS_ACL_PROGRAM,
 16         .nrvers                 = ARRAY_SIZE(nfsacl_version),
 17         .version                = nfsacl_version,
 18         .stats                  = &nfsacl_rpcstat,
 19 };
 20 
 21 /*
 22  * Initialise an NFSv3 ACL client connection
 23  */
 24 static void nfs_init_server_aclclient(struct nfs_server *server)
 25 {
 26         if (server->flags & NFS_MOUNT_NOACL)
 27                 goto out_noacl;
 28 
 29         server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3);
 30         if (IS_ERR(server->client_acl))
 31                 goto out_noacl;
 32 
 33         /* No errors! Assume that Sun nfsacls are supported */
 34         server->caps |= NFS_CAP_ACLS;
 35         return;
 36 
 37 out_noacl:
 38         server->caps &= ~NFS_CAP_ACLS;
 39 }
 40 #else
 41 static inline void nfs_init_server_aclclient(struct nfs_server *server)
 42 {
 43         server->flags &= ~NFS_MOUNT_NOACL;
 44         server->caps &= ~NFS_CAP_ACLS;
 45 }
 46 #endif
 47 
 48 struct nfs_server *nfs3_create_server(struct nfs_mount_info *mount_info,
 49                                       struct nfs_subversion *nfs_mod)
 50 {
 51         struct nfs_server *server = nfs_create_server(mount_info, nfs_mod);
 52         /* Create a client RPC handle for the NFS v3 ACL management interface */
 53         if (!IS_ERR(server))
 54                 nfs_init_server_aclclient(server);
 55         return server;
 56 }
 57 
 58 struct nfs_server *nfs3_clone_server(struct nfs_server *source,
 59                                      struct nfs_fh *fh,
 60                                      struct nfs_fattr *fattr,
 61                                      rpc_authflavor_t flavor)
 62 {
 63         struct nfs_server *server = nfs_clone_server(source, fh, fattr, flavor);
 64         if (!IS_ERR(server) && !IS_ERR(source->client_acl))
 65                 nfs_init_server_aclclient(server);
 66         return server;
 67 }
 68 
 69 /*
 70  * Set up a pNFS Data Server client over NFSv3.
 71  *
 72  * Return any existing nfs_client that matches server address,port,version
 73  * and minorversion.
 74  *
 75  * For a new nfs_client, use a soft mount (default), a low retrans and a
 76  * low timeout interval so that if a connection is lost, we retry through
 77  * the MDS.
 78  */
 79 struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,
 80                 const struct sockaddr *ds_addr, int ds_addrlen,
 81                 int ds_proto, unsigned int ds_timeo, unsigned int ds_retrans)
 82 {
 83         struct rpc_timeout ds_timeout;
 84         struct nfs_client *mds_clp = mds_srv->nfs_client;
 85         struct nfs_client_initdata cl_init = {
 86                 .addr = ds_addr,
 87                 .addrlen = ds_addrlen,
 88                 .nodename = mds_clp->cl_rpcclient->cl_nodename,
 89                 .ip_addr = mds_clp->cl_ipaddr,
 90                 .nfs_mod = &nfs_v3,
 91                 .proto = ds_proto,
 92                 .net = mds_clp->cl_net,
 93                 .timeparms = &ds_timeout,
 94         };
 95         struct nfs_client *clp;
 96         char buf[INET6_ADDRSTRLEN + 1];
 97 
 98         /* fake a hostname because lockd wants it */
 99         if (rpc_ntop(ds_addr, buf, sizeof(buf)) <= 0)
100                 return ERR_PTR(-EINVAL);
101         cl_init.hostname = buf;
102 
103         if (mds_srv->flags & NFS_MOUNT_NORESVPORT)
104                 set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags);
105 
106         /* Use the MDS nfs_client cl_ipaddr. */
107         nfs_init_timeout_values(&ds_timeout, ds_proto, ds_timeo, ds_retrans);
108         clp = nfs_get_client(&cl_init);
109 
110         return clp;
111 }
112 EXPORT_SYMBOL_GPL(nfs3_set_ds_client);
113 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp