blob: d4d2032c19920b0e5347fa28813323835ca52cbd [file] [log] [blame]
Andy Adamson16b374c2010-10-20 00:18:04 -04001/*
2 * Device operations for the pnfs nfs4 file layout driver.
3 *
4 * Copyright (c) 2002
5 * The Regents of the University of Michigan
6 * All Rights Reserved
7 *
8 * Dean Hildebrand <dhildebz@umich.edu>
9 * Garth Goodson <Garth.Goodson@netapp.com>
10 *
11 * Permission is granted to use, copy, create derivative works, and
12 * redistribute this software and such derivative works for any purpose,
13 * so long as the name of the University of Michigan is not used in
14 * any advertising or publicity pertaining to the use or distribution
15 * of this software without specific, written prior authorization. If
16 * the above copyright notice or any other identification of the
17 * University of Michigan is included in any copy of any portion of
18 * this software, then the disclaimer below must also be included.
19 *
20 * This software is provided as is, without representation or warranty
21 * of any kind either express or implied, including without limitation
22 * the implied warranties of merchantability, fitness for a particular
23 * purpose, or noninfringement. The Regents of the University of
24 * Michigan shall not be liable for any damages, including special,
25 * indirect, incidental, or consequential damages, with respect to any
26 * claim arising out of or in connection with the use of the software,
27 * even if it has been or is hereafter advised of the possibility of
28 * such damages.
29 */
30
31#include <linux/nfs_fs.h>
32#include <linux/vmalloc.h>
Andy Adamson98fc6852012-04-27 17:53:45 -040033#include <linux/module.h>
Andy Adamson16b374c2010-10-20 00:18:04 -040034
35#include "internal.h"
36#include "nfs4filelayout.h"
37
38#define NFSDBG_FACILITY NFSDBG_PNFS_LD
39
Andy Adamson98fc6852012-04-27 17:53:45 -040040static unsigned int dataserver_timeo = NFS4_DEF_DS_TIMEO;
41static unsigned int dataserver_retrans = NFS4_DEF_DS_RETRANS;
42
Andy Adamson16b374c2010-10-20 00:18:04 -040043/*
44 * Data server cache
45 *
46 * Data servers can be mapped to different device ids.
47 * nfs4_pnfs_ds reference counting
48 * - set to 1 on allocation
49 * - incremented when a device id maps a data server already in the cache.
50 * - decremented when deviceid is removed from the cache.
51 */
Trond Myklebust17280172012-03-11 13:11:00 -040052static DEFINE_SPINLOCK(nfs4_ds_cache_lock);
Andy Adamson16b374c2010-10-20 00:18:04 -040053static LIST_HEAD(nfs4_data_server_cache);
54
55/* Debug routines */
56void
57print_ds(struct nfs4_pnfs_ds *ds)
58{
59 if (ds == NULL) {
60 printk("%s NULL device\n", __func__);
61 return;
62 }
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -040063 printk(" ds %s\n"
Andy Adamson16b374c2010-10-20 00:18:04 -040064 " ref count %d\n"
65 " client %p\n"
66 " cl_exchange_flags %x\n",
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -040067 ds->ds_remotestr,
Andy Adamson16b374c2010-10-20 00:18:04 -040068 atomic_read(&ds->ds_count), ds->ds_clp,
69 ds->ds_clp ? ds->ds_clp->cl_exchange_flags : 0);
70}
71
Weston Andros Adamson14f9a602011-05-31 18:48:57 -040072static bool
73same_sockaddr(struct sockaddr *addr1, struct sockaddr *addr2)
Andy Adamson16b374c2010-10-20 00:18:04 -040074{
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -040075 struct sockaddr_in *a, *b;
76 struct sockaddr_in6 *a6, *b6;
Andy Adamson16b374c2010-10-20 00:18:04 -040077
Weston Andros Adamson14f9a602011-05-31 18:48:57 -040078 if (addr1->sa_family != addr2->sa_family)
79 return false;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -040080
Weston Andros Adamson14f9a602011-05-31 18:48:57 -040081 switch (addr1->sa_family) {
82 case AF_INET:
83 a = (struct sockaddr_in *)addr1;
84 b = (struct sockaddr_in *)addr2;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -040085
Weston Andros Adamson14f9a602011-05-31 18:48:57 -040086 if (a->sin_addr.s_addr == b->sin_addr.s_addr &&
87 a->sin_port == b->sin_port)
88 return true;
89 break;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -040090
Weston Andros Adamson14f9a602011-05-31 18:48:57 -040091 case AF_INET6:
92 a6 = (struct sockaddr_in6 *)addr1;
93 b6 = (struct sockaddr_in6 *)addr2;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -040094
Weston Andros Adamson14f9a602011-05-31 18:48:57 -040095 /* LINKLOCAL addresses must have matching scope_id */
96 if (ipv6_addr_scope(&a6->sin6_addr) ==
97 IPV6_ADDR_SCOPE_LINKLOCAL &&
98 a6->sin6_scope_id != b6->sin6_scope_id)
99 return false;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400100
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400101 if (ipv6_addr_equal(&a6->sin6_addr, &b6->sin6_addr) &&
102 a6->sin6_port == b6->sin6_port)
103 return true;
104 break;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400105
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400106 default:
107 dprintk("%s: unhandled address family: %u\n",
108 __func__, addr1->sa_family);
109 return false;
110 }
111
112 return false;
113}
114
Trond Myklebust17280172012-03-11 13:11:00 -0400115static bool
Weston Andros Adamson2d3fe012012-02-03 15:45:40 -0500116_same_data_server_addrs_locked(const struct list_head *dsaddrs1,
117 const struct list_head *dsaddrs2)
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400118{
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400119 struct nfs4_pnfs_ds_addr *da1, *da2;
120
Weston Andros Adamson2d3fe012012-02-03 15:45:40 -0500121 /* step through both lists, comparing as we go */
122 for (da1 = list_first_entry(dsaddrs1, typeof(*da1), da_node),
123 da2 = list_first_entry(dsaddrs2, typeof(*da2), da_node);
124 da1 != NULL && da2 != NULL;
125 da1 = list_entry(da1->da_node.next, typeof(*da1), da_node),
126 da2 = list_entry(da2->da_node.next, typeof(*da2), da_node)) {
127 if (!same_sockaddr((struct sockaddr *)&da1->da_addr,
128 (struct sockaddr *)&da2->da_addr))
129 return false;
Andy Adamson16b374c2010-10-20 00:18:04 -0400130 }
Weston Andros Adamson2d3fe012012-02-03 15:45:40 -0500131 if (da1 == NULL && da2 == NULL)
132 return true;
133
134 return false;
Andy Adamson16b374c2010-10-20 00:18:04 -0400135}
136
Andy Adamsond83217c2011-03-01 01:34:17 +0000137/*
Weston Andros Adamson2d3fe012012-02-03 15:45:40 -0500138 * Lookup DS by addresses. nfs4_ds_cache_lock is held
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400139 */
Weston Andros Adamson2d3fe012012-02-03 15:45:40 -0500140static struct nfs4_pnfs_ds *
141_data_server_lookup_locked(const struct list_head *dsaddrs)
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400142{
Weston Andros Adamson2d3fe012012-02-03 15:45:40 -0500143 struct nfs4_pnfs_ds *ds;
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400144
Weston Andros Adamson2d3fe012012-02-03 15:45:40 -0500145 list_for_each_entry(ds, &nfs4_data_server_cache, ds_node)
146 if (_same_data_server_addrs_locked(&ds->ds_addrs, dsaddrs))
147 return ds;
148 return NULL;
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400149}
150
151/*
Andy Adamsond83217c2011-03-01 01:34:17 +0000152 * Create an rpc connection to the nfs4_pnfs_ds data server
Weston Andros Adamson35dbbc92011-06-01 16:32:21 -0400153 * Currently only supports IPv4 and IPv6 addresses
Andy Adamsond83217c2011-03-01 01:34:17 +0000154 */
155static int
156nfs4_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds)
157{
Weston Andros Adamson7e574f02011-05-31 18:48:58 -0400158 struct nfs_client *clp = ERR_PTR(-EIO);
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400159 struct nfs4_pnfs_ds_addr *da;
Andy Adamsond83217c2011-03-01 01:34:17 +0000160 int status = 0;
161
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400162 dprintk("--> %s DS %s au_flavor %d\n", __func__, ds->ds_remotestr,
Andy Adamsond83217c2011-03-01 01:34:17 +0000163 mds_srv->nfs_client->cl_rpcclient->cl_auth->au_flavor);
164
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400165 BUG_ON(list_empty(&ds->ds_addrs));
166
Weston Andros Adamson7e574f02011-05-31 18:48:58 -0400167 list_for_each_entry(da, &ds->ds_addrs, da_node) {
168 dprintk("%s: DS %s: trying address %s\n",
169 __func__, ds->ds_remotestr, da->da_remotestr);
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400170
Weston Andros Adamson7e574f02011-05-31 18:48:58 -0400171 clp = nfs4_set_ds_client(mds_srv->nfs_client,
Andy Adamson98fc6852012-04-27 17:53:45 -0400172 (struct sockaddr *)&da->da_addr,
173 da->da_addrlen, IPPROTO_TCP,
174 dataserver_timeo, dataserver_retrans);
Weston Andros Adamson7e574f02011-05-31 18:48:58 -0400175 if (!IS_ERR(clp))
176 break;
177 }
178
Andy Adamsond83217c2011-03-01 01:34:17 +0000179 if (IS_ERR(clp)) {
180 status = PTR_ERR(clp);
181 goto out;
182 }
183
184 if ((clp->cl_exchange_flags & EXCHGID4_FLAG_MASK_PNFS) != 0) {
185 if (!is_ds_client(clp)) {
186 status = -ENODEV;
187 goto out_put;
188 }
189 ds->ds_clp = clp;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400190 dprintk("%s [existing] server=%s\n", __func__,
191 ds->ds_remotestr);
Andy Adamsond83217c2011-03-01 01:34:17 +0000192 goto out;
193 }
194
195 /*
196 * Do not set NFS_CS_CHECK_LEASE_TIME instead set the DS lease to
197 * be equal to the MDS lease. Renewal is scheduled in create_session.
198 */
199 spin_lock(&mds_srv->nfs_client->cl_lock);
200 clp->cl_lease_time = mds_srv->nfs_client->cl_lease_time;
201 spin_unlock(&mds_srv->nfs_client->cl_lock);
202 clp->cl_last_renewal = jiffies;
203
204 /* New nfs_client */
205 status = nfs4_init_ds_session(clp);
206 if (status)
207 goto out_put;
208
209 ds->ds_clp = clp;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400210 dprintk("%s [new] addr: %s\n", __func__, ds->ds_remotestr);
Andy Adamsond83217c2011-03-01 01:34:17 +0000211out:
212 return status;
213out_put:
214 nfs_put_client(clp);
215 goto out;
216}
217
Andy Adamson16b374c2010-10-20 00:18:04 -0400218static void
219destroy_ds(struct nfs4_pnfs_ds *ds)
220{
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400221 struct nfs4_pnfs_ds_addr *da;
222
Andy Adamson16b374c2010-10-20 00:18:04 -0400223 dprintk("--> %s\n", __func__);
224 ifdebug(FACILITY)
225 print_ds(ds);
226
227 if (ds->ds_clp)
228 nfs_put_client(ds->ds_clp);
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400229
230 while (!list_empty(&ds->ds_addrs)) {
231 da = list_first_entry(&ds->ds_addrs,
232 struct nfs4_pnfs_ds_addr,
233 da_node);
234 list_del_init(&da->da_node);
235 kfree(da->da_remotestr);
236 kfree(da);
237 }
238
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400239 kfree(ds->ds_remotestr);
Andy Adamson16b374c2010-10-20 00:18:04 -0400240 kfree(ds);
241}
242
Benny Halevy1775bc32011-05-20 13:47:33 +0200243void
Andy Adamson16b374c2010-10-20 00:18:04 -0400244nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr)
245{
246 struct nfs4_pnfs_ds *ds;
247 int i;
248
Benny Halevya1eaecb2011-05-19 22:14:47 -0400249 nfs4_print_deviceid(&dsaddr->id_node.deviceid);
Andy Adamson16b374c2010-10-20 00:18:04 -0400250
251 for (i = 0; i < dsaddr->ds_num; i++) {
252 ds = dsaddr->ds_list[i];
253 if (ds != NULL) {
254 if (atomic_dec_and_lock(&ds->ds_count,
255 &nfs4_ds_cache_lock)) {
256 list_del_init(&ds->ds_node);
257 spin_unlock(&nfs4_ds_cache_lock);
258 destroy_ds(ds);
259 }
260 }
261 }
262 kfree(dsaddr->stripe_indices);
263 kfree(dsaddr);
264}
265
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400266/*
267 * Create a string with a human readable address and port to avoid
268 * complicated setup around many dprinks.
269 */
270static char *
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400271nfs4_pnfs_remotestr(struct list_head *dsaddrs, gfp_t gfp_flags)
Andy Adamson16b374c2010-10-20 00:18:04 -0400272{
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400273 struct nfs4_pnfs_ds_addr *da;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400274 char *remotestr;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400275 size_t len;
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400276 char *p;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400277
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400278 len = 3; /* '{', '}' and eol */
279 list_for_each_entry(da, dsaddrs, da_node) {
280 len += strlen(da->da_remotestr) + 1; /* string plus comma */
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400281 }
282
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400283 remotestr = kzalloc(len, gfp_flags);
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400284 if (!remotestr)
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400285 return NULL;
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400286
287 p = remotestr;
288 *(p++) = '{';
289 len--;
290 list_for_each_entry(da, dsaddrs, da_node) {
291 size_t ll = strlen(da->da_remotestr);
292
293 if (ll > len)
294 goto out_err;
295
296 memcpy(p, da->da_remotestr, ll);
297 p += ll;
298 len -= ll;
299
300 if (len < 1)
301 goto out_err;
302 (*p++) = ',';
303 len--;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400304 }
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400305 if (len < 2)
306 goto out_err;
307 *(p++) = '}';
308 *p = '\0';
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400309 return remotestr;
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400310out_err:
311 kfree(remotestr);
312 return NULL;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400313}
314
315static struct nfs4_pnfs_ds *
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400316nfs4_pnfs_ds_add(struct list_head *dsaddrs, gfp_t gfp_flags)
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400317{
318 struct nfs4_pnfs_ds *tmp_ds, *ds = NULL;
319 char *remotestr;
Andy Adamson16b374c2010-10-20 00:18:04 -0400320
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400321 if (list_empty(dsaddrs)) {
322 dprintk("%s: no addresses defined\n", __func__);
323 goto out;
324 }
325
326 ds = kzalloc(sizeof(*ds), gfp_flags);
Andy Adamson16b374c2010-10-20 00:18:04 -0400327 if (!ds)
328 goto out;
329
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400330 /* this is only used for debugging, so it's ok if its NULL */
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400331 remotestr = nfs4_pnfs_remotestr(dsaddrs, gfp_flags);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400332
Andy Adamson16b374c2010-10-20 00:18:04 -0400333 spin_lock(&nfs4_ds_cache_lock);
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400334 tmp_ds = _data_server_lookup_locked(dsaddrs);
Andy Adamson16b374c2010-10-20 00:18:04 -0400335 if (tmp_ds == NULL) {
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400336 INIT_LIST_HEAD(&ds->ds_addrs);
337 list_splice_init(dsaddrs, &ds->ds_addrs);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400338 ds->ds_remotestr = remotestr;
Andy Adamson16b374c2010-10-20 00:18:04 -0400339 atomic_set(&ds->ds_count, 1);
340 INIT_LIST_HEAD(&ds->ds_node);
341 ds->ds_clp = NULL;
342 list_add(&ds->ds_node, &nfs4_data_server_cache);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400343 dprintk("%s add new data server %s\n", __func__,
344 ds->ds_remotestr);
Andy Adamson16b374c2010-10-20 00:18:04 -0400345 } else {
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400346 kfree(remotestr);
Andy Adamson16b374c2010-10-20 00:18:04 -0400347 kfree(ds);
348 atomic_inc(&tmp_ds->ds_count);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400349 dprintk("%s data server %s found, inc'ed ds_count to %d\n",
350 __func__, tmp_ds->ds_remotestr,
Andy Adamson16b374c2010-10-20 00:18:04 -0400351 atomic_read(&tmp_ds->ds_count));
352 ds = tmp_ds;
353 }
354 spin_unlock(&nfs4_ds_cache_lock);
355out:
356 return ds;
357}
358
359/*
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400360 * Currently only supports ipv4, ipv6 and one multi-path address.
Andy Adamson16b374c2010-10-20 00:18:04 -0400361 */
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400362static struct nfs4_pnfs_ds_addr *
Stanislav Kinsbursky17094272012-01-19 19:05:57 +0400363decode_ds_addr(struct net *net, struct xdr_stream *streamp, gfp_t gfp_flags)
Andy Adamson16b374c2010-10-20 00:18:04 -0400364{
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400365 struct nfs4_pnfs_ds_addr *da = NULL;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400366 char *buf, *portstr;
Dan Carpenter13fff2f2012-01-12 10:07:35 +0300367 __be16 port;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400368 int nlen, rlen;
Andy Adamson16b374c2010-10-20 00:18:04 -0400369 int tmp[2];
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400370 __be32 *p;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400371 char *netid, *match_netid;
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400372 size_t len, match_netid_len;
373 char *startsep = "";
374 char *endsep = "";
375
Andy Adamson16b374c2010-10-20 00:18:04 -0400376
377 /* r_netid */
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400378 p = xdr_inline_decode(streamp, 4);
379 if (unlikely(!p))
380 goto out_err;
Andy Adamson16b374c2010-10-20 00:18:04 -0400381 nlen = be32_to_cpup(p++);
Andy Adamson16b374c2010-10-20 00:18:04 -0400382
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400383 p = xdr_inline_decode(streamp, nlen);
384 if (unlikely(!p))
385 goto out_err;
Andy Adamson16b374c2010-10-20 00:18:04 -0400386
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400387 netid = kmalloc(nlen+1, gfp_flags);
388 if (unlikely(!netid))
Andy Adamson16b374c2010-10-20 00:18:04 -0400389 goto out_err;
Andy Adamson16b374c2010-10-20 00:18:04 -0400390
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400391 netid[nlen] = '\0';
392 memcpy(netid, p, nlen);
393
394 /* r_addr: ip/ip6addr with port in dec octets - see RFC 5665 */
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400395 p = xdr_inline_decode(streamp, 4);
396 if (unlikely(!p))
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400397 goto out_free_netid;
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400398 rlen = be32_to_cpup(p);
399
400 p = xdr_inline_decode(streamp, rlen);
401 if (unlikely(!p))
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400402 goto out_free_netid;
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400403
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400404 /* port is ".ABC.DEF", 8 chars max */
405 if (rlen > INET6_ADDRSTRLEN + IPV6_SCOPE_ID_LEN + 8) {
Jesper Juhlad3d2ee2011-01-17 18:41:50 +0000406 dprintk("%s: Invalid address, length %d\n", __func__,
Andy Adamson16b374c2010-10-20 00:18:04 -0400407 rlen);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400408 goto out_free_netid;
Andy Adamson16b374c2010-10-20 00:18:04 -0400409 }
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400410 buf = kmalloc(rlen + 1, gfp_flags);
Stanislav Fomichevb9f81052011-02-05 23:13:01 +0000411 if (!buf) {
412 dprintk("%s: Not enough memory\n", __func__);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400413 goto out_free_netid;
Stanislav Fomichevb9f81052011-02-05 23:13:01 +0000414 }
Andy Adamson16b374c2010-10-20 00:18:04 -0400415 buf[rlen] = '\0';
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400416 memcpy(buf, p, rlen);
Andy Adamson16b374c2010-10-20 00:18:04 -0400417
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400418 /* replace port '.' with '-' */
419 portstr = strrchr(buf, '.');
420 if (!portstr) {
421 dprintk("%s: Failed finding expected dot in port\n",
422 __func__);
423 goto out_free_buf;
424 }
425 *portstr = '-';
426
427 /* find '.' between address and port */
428 portstr = strrchr(buf, '.');
429 if (!portstr) {
430 dprintk("%s: Failed finding expected dot between address and "
431 "port\n", __func__);
432 goto out_free_buf;
433 }
434 *portstr = '\0';
435
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400436 da = kzalloc(sizeof(*da), gfp_flags);
437 if (unlikely(!da))
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400438 goto out_free_buf;
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400439
440 INIT_LIST_HEAD(&da->da_node);
441
Stanislav Kinsbursky17094272012-01-19 19:05:57 +0400442 if (!rpc_pton(net, buf, portstr-buf, (struct sockaddr *)&da->da_addr,
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400443 sizeof(da->da_addr))) {
444 dprintk("%s: error parsing address %s\n", __func__, buf);
445 goto out_free_da;
Andy Adamson16b374c2010-10-20 00:18:04 -0400446 }
447
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400448 portstr++;
449 sscanf(portstr, "%d-%d", &tmp[0], &tmp[1]);
Andy Adamson16b374c2010-10-20 00:18:04 -0400450 port = htons((tmp[0] << 8) | (tmp[1]));
451
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400452 switch (da->da_addr.ss_family) {
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400453 case AF_INET:
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400454 ((struct sockaddr_in *)&da->da_addr)->sin_port = port;
455 da->da_addrlen = sizeof(struct sockaddr_in);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400456 match_netid = "tcp";
457 match_netid_len = 3;
458 break;
459
460 case AF_INET6:
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400461 ((struct sockaddr_in6 *)&da->da_addr)->sin6_port = port;
462 da->da_addrlen = sizeof(struct sockaddr_in6);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400463 match_netid = "tcp6";
464 match_netid_len = 4;
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400465 startsep = "[";
466 endsep = "]";
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400467 break;
468
469 default:
470 dprintk("%s: unsupported address family: %u\n",
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400471 __func__, da->da_addr.ss_family);
472 goto out_free_da;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400473 }
474
475 if (nlen != match_netid_len || strncmp(netid, match_netid, nlen)) {
476 dprintk("%s: ERROR: r_netid \"%s\" != \"%s\"\n",
477 __func__, netid, match_netid);
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400478 goto out_free_da;
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400479 }
480
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400481 /* save human readable address */
482 len = strlen(startsep) + strlen(buf) + strlen(endsep) + 7;
483 da->da_remotestr = kzalloc(len, gfp_flags);
484
485 /* NULL is ok, only used for dprintk */
486 if (da->da_remotestr)
487 snprintf(da->da_remotestr, len, "%s%s%s:%u", startsep,
488 buf, endsep, ntohs(port));
489
490 dprintk("%s: Parsed DS addr %s\n", __func__, da->da_remotestr);
491 kfree(buf);
492 kfree(netid);
493 return da;
494
495out_free_da:
496 kfree(da);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400497out_free_buf:
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400498 dprintk("%s: Error parsing DS addr: %s\n", __func__, buf);
Andy Adamson16b374c2010-10-20 00:18:04 -0400499 kfree(buf);
Weston Andros Adamsonc9895cb2011-05-31 18:48:56 -0400500out_free_netid:
501 kfree(netid);
Andy Adamson16b374c2010-10-20 00:18:04 -0400502out_err:
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400503 return NULL;
Andy Adamson16b374c2010-10-20 00:18:04 -0400504}
505
506/* Decode opaque device data and return the result */
507static struct nfs4_file_layout_dsaddr*
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400508decode_device(struct inode *ino, struct pnfs_device *pdev, gfp_t gfp_flags)
Andy Adamson16b374c2010-10-20 00:18:04 -0400509{
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400510 int i;
Andy Adamson16b374c2010-10-20 00:18:04 -0400511 u32 cnt, num;
512 u8 *indexp;
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400513 __be32 *p;
514 u8 *stripe_indices;
515 u8 max_stripe_index;
516 struct nfs4_file_layout_dsaddr *dsaddr = NULL;
517 struct xdr_stream stream;
Benny Halevyf7da7a12011-05-19 14:16:47 -0400518 struct xdr_buf buf;
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400519 struct page *scratch;
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400520 struct list_head dsaddrs;
521 struct nfs4_pnfs_ds_addr *da;
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400522
523 /* set up xdr stream */
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400524 scratch = alloc_page(gfp_flags);
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400525 if (!scratch)
526 goto out_err;
527
Benny Halevyf7da7a12011-05-19 14:16:47 -0400528 xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen);
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400529 xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
Andy Adamson16b374c2010-10-20 00:18:04 -0400530
531 /* Get the stripe count (number of stripe index) */
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400532 p = xdr_inline_decode(&stream, 4);
533 if (unlikely(!p))
534 goto out_err_free_scratch;
535
536 cnt = be32_to_cpup(p);
Andy Adamson16b374c2010-10-20 00:18:04 -0400537 dprintk("%s stripe count %d\n", __func__, cnt);
538 if (cnt > NFS4_PNFS_MAX_STRIPE_CNT) {
Weston Andros Adamsona0308892012-01-26 13:32:23 -0500539 printk(KERN_WARNING "NFS: %s: stripe count %d greater than "
Andy Adamson16b374c2010-10-20 00:18:04 -0400540 "supported maximum %d\n", __func__,
541 cnt, NFS4_PNFS_MAX_STRIPE_CNT);
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400542 goto out_err_free_scratch;
543 }
544
545 /* read stripe indices */
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400546 stripe_indices = kcalloc(cnt, sizeof(u8), gfp_flags);
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400547 if (!stripe_indices)
548 goto out_err_free_scratch;
549
550 p = xdr_inline_decode(&stream, cnt << 2);
551 if (unlikely(!p))
552 goto out_err_free_stripe_indices;
553
554 indexp = &stripe_indices[0];
555 max_stripe_index = 0;
556 for (i = 0; i < cnt; i++) {
557 *indexp = be32_to_cpup(p++);
558 max_stripe_index = max(max_stripe_index, *indexp);
559 indexp++;
Andy Adamson16b374c2010-10-20 00:18:04 -0400560 }
561
562 /* Check the multipath list count */
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400563 p = xdr_inline_decode(&stream, 4);
564 if (unlikely(!p))
565 goto out_err_free_stripe_indices;
566
567 num = be32_to_cpup(p);
Andy Adamson16b374c2010-10-20 00:18:04 -0400568 dprintk("%s ds_num %u\n", __func__, num);
569 if (num > NFS4_PNFS_MAX_MULTI_CNT) {
Weston Andros Adamsona0308892012-01-26 13:32:23 -0500570 printk(KERN_WARNING "NFS: %s: multipath count %d greater than "
Andy Adamson16b374c2010-10-20 00:18:04 -0400571 "supported maximum %d\n", __func__,
572 num, NFS4_PNFS_MAX_MULTI_CNT);
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400573 goto out_err_free_stripe_indices;
Andy Adamson16b374c2010-10-20 00:18:04 -0400574 }
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400575
576 /* validate stripe indices are all < num */
577 if (max_stripe_index >= num) {
Weston Andros Adamsona0308892012-01-26 13:32:23 -0500578 printk(KERN_WARNING "NFS: %s: stripe index %u >= num ds %u\n",
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400579 __func__, max_stripe_index, num);
580 goto out_err_free_stripe_indices;
581 }
582
Andy Adamson16b374c2010-10-20 00:18:04 -0400583 dsaddr = kzalloc(sizeof(*dsaddr) +
584 (sizeof(struct nfs4_pnfs_ds *) * (num - 1)),
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400585 gfp_flags);
Andy Adamson16b374c2010-10-20 00:18:04 -0400586 if (!dsaddr)
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400587 goto out_err_free_stripe_indices;
Andy Adamson16b374c2010-10-20 00:18:04 -0400588
589 dsaddr->stripe_count = cnt;
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400590 dsaddr->stripe_indices = stripe_indices;
591 stripe_indices = NULL;
Andy Adamson16b374c2010-10-20 00:18:04 -0400592 dsaddr->ds_num = num;
Benny Halevy1775bc32011-05-20 13:47:33 +0200593 nfs4_init_deviceid_node(&dsaddr->id_node,
594 NFS_SERVER(ino)->pnfs_curr_ld,
595 NFS_SERVER(ino)->nfs_client,
Benny Halevya1eaecb2011-05-19 22:14:47 -0400596 &pdev->dev_id);
Andy Adamson16b374c2010-10-20 00:18:04 -0400597
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400598 INIT_LIST_HEAD(&dsaddrs);
599
Andy Adamson16b374c2010-10-20 00:18:04 -0400600 for (i = 0; i < dsaddr->ds_num; i++) {
601 int j;
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400602 u32 mp_count;
Andy Adamson16b374c2010-10-20 00:18:04 -0400603
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400604 p = xdr_inline_decode(&stream, 4);
605 if (unlikely(!p))
606 goto out_err_free_deviceid;
607
608 mp_count = be32_to_cpup(p); /* multipath count */
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400609 for (j = 0; j < mp_count; j++) {
Stanislav Kinsbursky17094272012-01-19 19:05:57 +0400610 da = decode_ds_addr(NFS_SERVER(ino)->nfs_client->net,
611 &stream, gfp_flags);
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400612 if (da)
613 list_add_tail(&da->da_node, &dsaddrs);
614 }
615 if (list_empty(&dsaddrs)) {
616 dprintk("%s: no suitable DS addresses found\n",
617 __func__);
618 goto out_err_free_deviceid;
619 }
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400620
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400621 dsaddr->ds_list[i] = nfs4_pnfs_ds_add(&dsaddrs, gfp_flags);
622 if (!dsaddr->ds_list[i])
623 goto out_err_drain_dsaddrs;
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400624
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400625 /* If DS was already in cache, free ds addrs */
626 while (!list_empty(&dsaddrs)) {
627 da = list_first_entry(&dsaddrs,
628 struct nfs4_pnfs_ds_addr,
629 da_node);
630 list_del_init(&da->da_node);
631 kfree(da->da_remotestr);
632 kfree(da);
Andy Adamson16b374c2010-10-20 00:18:04 -0400633 }
634 }
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400635
636 __free_page(scratch);
Andy Adamson16b374c2010-10-20 00:18:04 -0400637 return dsaddr;
638
Weston Andros Adamson14f9a602011-05-31 18:48:57 -0400639out_err_drain_dsaddrs:
640 while (!list_empty(&dsaddrs)) {
641 da = list_first_entry(&dsaddrs, struct nfs4_pnfs_ds_addr,
642 da_node);
643 list_del_init(&da->da_node);
644 kfree(da->da_remotestr);
645 kfree(da);
646 }
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400647out_err_free_deviceid:
Andy Adamson16b374c2010-10-20 00:18:04 -0400648 nfs4_fl_free_deviceid(dsaddr);
Weston Andros Adamson35124a02011-03-24 16:48:21 -0400649 /* stripe_indicies was part of dsaddr */
650 goto out_err_free_scratch;
651out_err_free_stripe_indices:
652 kfree(stripe_indices);
653out_err_free_scratch:
654 __free_page(scratch);
Andy Adamson16b374c2010-10-20 00:18:04 -0400655out_err:
656 dprintk("%s ERROR: returning NULL\n", __func__);
657 return NULL;
658}
659
660/*
Christoph Hellwigea8eecd2011-03-01 01:34:21 +0000661 * Decode the opaque device specified in 'dev' and add it to the cache of
662 * available devices.
Andy Adamson16b374c2010-10-20 00:18:04 -0400663 */
Christoph Hellwigea8eecd2011-03-01 01:34:21 +0000664static struct nfs4_file_layout_dsaddr *
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400665decode_and_add_device(struct inode *inode, struct pnfs_device *dev, gfp_t gfp_flags)
Andy Adamson16b374c2010-10-20 00:18:04 -0400666{
Benny Halevya1eaecb2011-05-19 22:14:47 -0400667 struct nfs4_deviceid_node *d;
668 struct nfs4_file_layout_dsaddr *n, *new;
Andy Adamson16b374c2010-10-20 00:18:04 -0400669
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400670 new = decode_device(inode, dev, gfp_flags);
Christoph Hellwigea8eecd2011-03-01 01:34:21 +0000671 if (!new) {
Weston Andros Adamsona0308892012-01-26 13:32:23 -0500672 printk(KERN_WARNING "NFS: %s: Could not decode or add device\n",
Andy Adamson16b374c2010-10-20 00:18:04 -0400673 __func__);
674 return NULL;
675 }
676
Benny Halevya1eaecb2011-05-19 22:14:47 -0400677 d = nfs4_insert_deviceid_node(&new->id_node);
678 n = container_of(d, struct nfs4_file_layout_dsaddr, id_node);
679 if (n != new) {
Christoph Hellwigea8eecd2011-03-01 01:34:21 +0000680 nfs4_fl_free_deviceid(new);
Benny Halevya1eaecb2011-05-19 22:14:47 -0400681 return n;
Christoph Hellwigea8eecd2011-03-01 01:34:21 +0000682 }
Andy Adamson16b374c2010-10-20 00:18:04 -0400683
Christoph Hellwigea8eecd2011-03-01 01:34:21 +0000684 return new;
Andy Adamson16b374c2010-10-20 00:18:04 -0400685}
686
687/*
688 * Retrieve the information for dev_id, add it to the list
689 * of available devices, and return it.
690 */
691struct nfs4_file_layout_dsaddr *
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400692get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_flags)
Andy Adamson16b374c2010-10-20 00:18:04 -0400693{
694 struct pnfs_device *pdev = NULL;
695 u32 max_resp_sz;
696 int max_pages;
697 struct page **pages = NULL;
698 struct nfs4_file_layout_dsaddr *dsaddr = NULL;
699 int rc, i;
700 struct nfs_server *server = NFS_SERVER(inode);
701
702 /*
703 * Use the session max response size as the basis for setting
704 * GETDEVICEINFO's maxcount
705 */
706 max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
Andy Adamsone5265a02012-04-14 03:56:35 -0400707 max_pages = nfs_page_array_len(0, max_resp_sz);
Andy Adamson16b374c2010-10-20 00:18:04 -0400708 dprintk("%s inode %p max_resp_sz %u max_pages %d\n",
709 __func__, inode, max_resp_sz, max_pages);
710
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400711 pdev = kzalloc(sizeof(struct pnfs_device), gfp_flags);
Andy Adamson16b374c2010-10-20 00:18:04 -0400712 if (pdev == NULL)
713 return NULL;
714
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400715 pages = kzalloc(max_pages * sizeof(struct page *), gfp_flags);
Andy Adamson16b374c2010-10-20 00:18:04 -0400716 if (pages == NULL) {
717 kfree(pdev);
718 return NULL;
719 }
720 for (i = 0; i < max_pages; i++) {
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400721 pages[i] = alloc_page(gfp_flags);
Andy Adamson16b374c2010-10-20 00:18:04 -0400722 if (!pages[i])
723 goto out_free;
724 }
725
Andy Adamson16b374c2010-10-20 00:18:04 -0400726 memcpy(&pdev->dev_id, dev_id, sizeof(*dev_id));
727 pdev->layout_type = LAYOUT_NFSV4_1_FILES;
728 pdev->pages = pages;
729 pdev->pgbase = 0;
730 pdev->pglen = PAGE_SIZE * max_pages;
731 pdev->mincount = 0;
732
733 rc = nfs4_proc_getdeviceinfo(server, pdev);
734 dprintk("%s getdevice info returns %d\n", __func__, rc);
735 if (rc)
736 goto out_free;
737
738 /*
739 * Found new device, need to decode it and then add it to the
740 * list of known devices for this mountpoint.
741 */
Trond Myklebusta75b9df2011-05-11 18:00:51 -0400742 dsaddr = decode_and_add_device(inode, pdev, gfp_flags);
Andy Adamson16b374c2010-10-20 00:18:04 -0400743out_free:
Andy Adamson16b374c2010-10-20 00:18:04 -0400744 for (i = 0; i < max_pages; i++)
745 __free_page(pages[i]);
746 kfree(pages);
747 kfree(pdev);
748 dprintk("<-- %s dsaddr %p\n", __func__, dsaddr);
749 return dsaddr;
750}
751
Christoph Hellwigea8eecd2011-03-01 01:34:21 +0000752void
753nfs4_fl_put_deviceid(struct nfs4_file_layout_dsaddr *dsaddr)
Andy Adamson16b374c2010-10-20 00:18:04 -0400754{
Benny Halevy1775bc32011-05-20 13:47:33 +0200755 nfs4_put_deviceid_node(&dsaddr->id_node);
Andy Adamson16b374c2010-10-20 00:18:04 -0400756}
Fred Isamancfe7f412011-03-01 01:34:18 +0000757
758/*
759 * Want res = (offset - layout->pattern_offset)/ layout->stripe_unit
760 * Then: ((res + fsi) % dsaddr->stripe_count)
761 */
762u32
763nfs4_fl_calc_j_index(struct pnfs_layout_segment *lseg, loff_t offset)
764{
765 struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
766 u64 tmp;
767
768 tmp = offset - flseg->pattern_offset;
769 do_div(tmp, flseg->stripe_unit);
770 tmp += flseg->first_stripe_index;
771 return do_div(tmp, flseg->dsaddr->stripe_count);
772}
773
774u32
775nfs4_fl_calc_ds_index(struct pnfs_layout_segment *lseg, u32 j)
776{
777 return FILELAYOUT_LSEG(lseg)->dsaddr->stripe_indices[j];
778}
779
780struct nfs_fh *
781nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, u32 j)
782{
783 struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
784 u32 i;
785
786 if (flseg->stripe_type == STRIPE_SPARSE) {
787 if (flseg->num_fh == 1)
788 i = 0;
789 else if (flseg->num_fh == 0)
790 /* Use the MDS OPEN fh set in nfs_read_rpcsetup */
791 return NULL;
792 else
793 i = nfs4_fl_calc_ds_index(lseg, j);
794 } else
795 i = j;
796 return flseg->fh_array[i];
797}
798
799struct nfs4_pnfs_ds *
800nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx)
801{
802 struct nfs4_file_layout_dsaddr *dsaddr = FILELAYOUT_LSEG(lseg)->dsaddr;
803 struct nfs4_pnfs_ds *ds = dsaddr->ds_list[ds_idx];
Andy Adamson554d4582012-04-27 17:53:42 -0400804 struct nfs4_deviceid_node *devid = FILELAYOUT_DEVID_NODE(lseg);
805
806 if (filelayout_test_devid_invalid(devid))
807 return NULL;
Fred Isamancfe7f412011-03-01 01:34:18 +0000808
809 if (ds == NULL) {
Weston Andros Adamsona0308892012-01-26 13:32:23 -0500810 printk(KERN_ERR "NFS: %s: No data server for offset index %d\n",
Fred Isamancfe7f412011-03-01 01:34:18 +0000811 __func__, ds_idx);
Andy Adamson554d4582012-04-27 17:53:42 -0400812 goto mark_dev_invalid;
Fred Isamancfe7f412011-03-01 01:34:18 +0000813 }
814
815 if (!ds->ds_clp) {
Andy Adamson568e8c42011-03-01 01:34:22 +0000816 struct nfs_server *s = NFS_SERVER(lseg->pls_layout->plh_inode);
Fred Isamancfe7f412011-03-01 01:34:18 +0000817 int err;
818
Andy Adamson568e8c42011-03-01 01:34:22 +0000819 err = nfs4_ds_connect(s, ds);
Andy Adamson554d4582012-04-27 17:53:42 -0400820 if (err)
821 goto mark_dev_invalid;
Fred Isamancfe7f412011-03-01 01:34:18 +0000822 }
823 return ds;
Andy Adamson554d4582012-04-27 17:53:42 -0400824
825mark_dev_invalid:
826 filelayout_mark_devid_invalid(devid);
827 return NULL;
Fred Isamancfe7f412011-03-01 01:34:18 +0000828}
Andy Adamson98fc6852012-04-27 17:53:45 -0400829
830module_param(dataserver_retrans, uint, 0644);
831MODULE_PARM_DESC(dataserver_retrans, "The number of times the NFSv4.1 client "
832 "retries a request before it attempts further "
833 " recovery action.");
834module_param(dataserver_timeo, uint, 0644);
835MODULE_PARM_DESC(dataserver_timeo, "The time (in tenths of a second) the "
836 "NFSv4.1 client waits for a response from a "
837 " data server before it retries an NFS request.");