diff options
author | Andy Adamson <andros@netapp.com> | 2011-02-28 20:34:17 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-03-11 15:38:42 -0500 |
commit | d83217c13531fd59730d77b5c2284e90e56c0a50 (patch) | |
tree | e347037afc91fdb81e0e2fcf7225d30462fb90af /fs/nfs/nfs4filelayoutdev.c | |
parent | 64419a9b20938d9070fdd8c58c2fa23c911915f8 (diff) |
NFSv4.1: data server connection
Introduce a data server set_client and init session following the
nfs4_set_client and nfs4_init_session convention.
Once a new nfs_client is on the nfs_client_list, the nfs_client cl_cons_state
serializes access to creating an nfs_client struct with matching properties.
Use the new nfs_get_client() that initializes new clients.
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4filelayoutdev.c')
-rw-r--r-- | fs/nfs/nfs4filelayoutdev.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c index b73c34375f60..8bc91fb8b6fa 100644 --- a/fs/nfs/nfs4filelayoutdev.c +++ b/fs/nfs/nfs4filelayoutdev.c | |||
@@ -104,6 +104,67 @@ _data_server_lookup_locked(u32 ip_addr, u32 port) | |||
104 | return NULL; | 104 | return NULL; |
105 | } | 105 | } |
106 | 106 | ||
107 | /* | ||
108 | * Create an rpc connection to the nfs4_pnfs_ds data server | ||
109 | * Currently only support IPv4 | ||
110 | */ | ||
111 | static int | ||
112 | nfs4_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds) | ||
113 | { | ||
114 | struct nfs_client *clp; | ||
115 | struct sockaddr_in sin; | ||
116 | int status = 0; | ||
117 | |||
118 | dprintk("--> %s ip:port %x:%hu au_flavor %d\n", __func__, | ||
119 | ntohl(ds->ds_ip_addr), ntohs(ds->ds_port), | ||
120 | mds_srv->nfs_client->cl_rpcclient->cl_auth->au_flavor); | ||
121 | |||
122 | sin.sin_family = AF_INET; | ||
123 | sin.sin_addr.s_addr = ds->ds_ip_addr; | ||
124 | sin.sin_port = ds->ds_port; | ||
125 | |||
126 | clp = nfs4_set_ds_client(mds_srv->nfs_client, (struct sockaddr *)&sin, | ||
127 | sizeof(sin), IPPROTO_TCP); | ||
128 | if (IS_ERR(clp)) { | ||
129 | status = PTR_ERR(clp); | ||
130 | goto out; | ||
131 | } | ||
132 | |||
133 | if ((clp->cl_exchange_flags & EXCHGID4_FLAG_MASK_PNFS) != 0) { | ||
134 | if (!is_ds_client(clp)) { | ||
135 | status = -ENODEV; | ||
136 | goto out_put; | ||
137 | } | ||
138 | ds->ds_clp = clp; | ||
139 | dprintk("%s [existing] ip=%x, port=%hu\n", __func__, | ||
140 | ntohl(ds->ds_ip_addr), ntohs(ds->ds_port)); | ||
141 | goto out; | ||
142 | } | ||
143 | |||
144 | /* | ||
145 | * Do not set NFS_CS_CHECK_LEASE_TIME instead set the DS lease to | ||
146 | * be equal to the MDS lease. Renewal is scheduled in create_session. | ||
147 | */ | ||
148 | spin_lock(&mds_srv->nfs_client->cl_lock); | ||
149 | clp->cl_lease_time = mds_srv->nfs_client->cl_lease_time; | ||
150 | spin_unlock(&mds_srv->nfs_client->cl_lock); | ||
151 | clp->cl_last_renewal = jiffies; | ||
152 | |||
153 | /* New nfs_client */ | ||
154 | status = nfs4_init_ds_session(clp); | ||
155 | if (status) | ||
156 | goto out_put; | ||
157 | |||
158 | ds->ds_clp = clp; | ||
159 | dprintk("%s [new] ip=%x, port=%hu\n", __func__, ntohl(ds->ds_ip_addr), | ||
160 | ntohs(ds->ds_port)); | ||
161 | out: | ||
162 | return status; | ||
163 | out_put: | ||
164 | nfs_put_client(clp); | ||
165 | goto out; | ||
166 | } | ||
167 | |||
107 | static void | 168 | static void |
108 | destroy_ds(struct nfs4_pnfs_ds *ds) | 169 | destroy_ds(struct nfs4_pnfs_ds *ds) |
109 | { | 170 | { |