nfs4client.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  1. /*
  2. * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
  3. * Written by David Howells (dhowells@redhat.com)
  4. */
  5. #include <linux/module.h>
  6. #include <linux/nfs_fs.h>
  7. #include <linux/nfs_mount.h>
  8. #include <linux/sunrpc/addr.h>
  9. #include <linux/sunrpc/auth.h>
  10. #include <linux/sunrpc/xprt.h>
  11. #include <linux/sunrpc/bc_xprt.h>
  12. #include <linux/sunrpc/rpc_pipe_fs.h>
  13. #include "internal.h"
  14. #include "callback.h"
  15. #include "delegation.h"
  16. #include "nfs4session.h"
  17. #include "nfs4idmap.h"
  18. #include "pnfs.h"
  19. #include "netns.h"
  20. #define NFSDBG_FACILITY NFSDBG_CLIENT
  21. /*
  22. * Get a unique NFSv4.0 callback identifier which will be used
  23. * by the V4.0 callback service to lookup the nfs_client struct
  24. */
  25. static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion)
  26. {
  27. int ret = 0;
  28. struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
  29. if (clp->rpc_ops->version != 4 || minorversion != 0)
  30. return ret;
  31. idr_preload(GFP_KERNEL);
  32. spin_lock(&nn->nfs_client_lock);
  33. ret = idr_alloc(&nn->cb_ident_idr, clp, 1, 0, GFP_NOWAIT);
  34. if (ret >= 0)
  35. clp->cl_cb_ident = ret;
  36. spin_unlock(&nn->nfs_client_lock);
  37. idr_preload_end();
  38. return ret < 0 ? ret : 0;
  39. }
  40. #ifdef CONFIG_NFS_V4_1
  41. /**
  42. * Per auth flavor data server rpc clients
  43. */
  44. struct nfs4_ds_server {
  45. struct list_head list; /* ds_clp->cl_ds_clients */
  46. struct rpc_clnt *rpc_clnt;
  47. };
  48. /**
  49. * Common lookup case for DS I/O
  50. */
  51. static struct nfs4_ds_server *
  52. nfs4_find_ds_client(struct nfs_client *ds_clp, rpc_authflavor_t flavor)
  53. {
  54. struct nfs4_ds_server *dss;
  55. rcu_read_lock();
  56. list_for_each_entry_rcu(dss, &ds_clp->cl_ds_clients, list) {
  57. if (dss->rpc_clnt->cl_auth->au_flavor != flavor)
  58. continue;
  59. goto out;
  60. }
  61. dss = NULL;
  62. out:
  63. rcu_read_unlock();
  64. return dss;
  65. }
  66. static struct nfs4_ds_server *
  67. nfs4_add_ds_client(struct nfs_client *ds_clp, rpc_authflavor_t flavor,
  68. struct nfs4_ds_server *new)
  69. {
  70. struct nfs4_ds_server *dss;
  71. spin_lock(&ds_clp->cl_lock);
  72. list_for_each_entry(dss, &ds_clp->cl_ds_clients, list) {
  73. if (dss->rpc_clnt->cl_auth->au_flavor != flavor)
  74. continue;
  75. goto out;
  76. }
  77. if (new)
  78. list_add_rcu(&new->list, &ds_clp->cl_ds_clients);
  79. dss = new;
  80. out:
  81. spin_unlock(&ds_clp->cl_lock); /* need some lock to protect list */
  82. return dss;
  83. }
  84. static struct nfs4_ds_server *
  85. nfs4_alloc_ds_server(struct nfs_client *ds_clp, rpc_authflavor_t flavor)
  86. {
  87. struct nfs4_ds_server *dss;
  88. dss = kmalloc(sizeof(*dss), GFP_NOFS);
  89. if (dss == NULL)
  90. return ERR_PTR(-ENOMEM);
  91. dss->rpc_clnt = rpc_clone_client_set_auth(ds_clp->cl_rpcclient, flavor);
  92. if (IS_ERR(dss->rpc_clnt)) {
  93. int err = PTR_ERR(dss->rpc_clnt);
  94. kfree (dss);
  95. return ERR_PTR(err);
  96. }
  97. INIT_LIST_HEAD(&dss->list);
  98. return dss;
  99. }
  100. static void
  101. nfs4_free_ds_server(struct nfs4_ds_server *dss)
  102. {
  103. rpc_release_client(dss->rpc_clnt);
  104. kfree(dss);
  105. }
  106. /**
  107. * Find or create a DS rpc client with th MDS server rpc client auth flavor
  108. * in the nfs_client cl_ds_clients list.
  109. */
  110. struct rpc_clnt *
  111. nfs4_find_or_create_ds_client(struct nfs_client *ds_clp, struct inode *inode)
  112. {
  113. struct nfs4_ds_server *dss, *new;
  114. rpc_authflavor_t flavor = NFS_SERVER(inode)->client->cl_auth->au_flavor;
  115. dss = nfs4_find_ds_client(ds_clp, flavor);
  116. if (dss != NULL)
  117. goto out;
  118. new = nfs4_alloc_ds_server(ds_clp, flavor);
  119. if (IS_ERR(new))
  120. return ERR_CAST(new);
  121. dss = nfs4_add_ds_client(ds_clp, flavor, new);
  122. if (dss != new)
  123. nfs4_free_ds_server(new);
  124. out:
  125. return dss->rpc_clnt;
  126. }
  127. EXPORT_SYMBOL_GPL(nfs4_find_or_create_ds_client);
  128. static void
  129. nfs4_shutdown_ds_clients(struct nfs_client *clp)
  130. {
  131. struct nfs4_ds_server *dss;
  132. LIST_HEAD(shutdown_list);
  133. while (!list_empty(&clp->cl_ds_clients)) {
  134. dss = list_entry(clp->cl_ds_clients.next,
  135. struct nfs4_ds_server, list);
  136. list_del(&dss->list);
  137. rpc_shutdown_client(dss->rpc_clnt);
  138. kfree (dss);
  139. }
  140. }
  141. static void
  142. nfs4_cleanup_callback(struct nfs_client *clp)
  143. {
  144. struct nfs4_copy_state *cp_state;
  145. while (!list_empty(&clp->pending_cb_stateids)) {
  146. cp_state = list_entry(clp->pending_cb_stateids.next,
  147. struct nfs4_copy_state, copies);
  148. list_del(&cp_state->copies);
  149. kfree(cp_state);
  150. }
  151. }
  152. void nfs41_shutdown_client(struct nfs_client *clp)
  153. {
  154. if (nfs4_has_session(clp)) {
  155. nfs4_cleanup_callback(clp);
  156. nfs4_shutdown_ds_clients(clp);
  157. nfs4_destroy_session(clp->cl_session);
  158. nfs4_destroy_clientid(clp);
  159. }
  160. }
  161. #endif /* CONFIG_NFS_V4_1 */
  162. void nfs40_shutdown_client(struct nfs_client *clp)
  163. {
  164. if (clp->cl_slot_tbl) {
  165. nfs4_shutdown_slot_table(clp->cl_slot_tbl);
  166. kfree(clp->cl_slot_tbl);
  167. }
  168. }
  169. struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
  170. {
  171. int err;
  172. struct nfs_client *clp = nfs_alloc_client(cl_init);
  173. if (IS_ERR(clp))
  174. return clp;
  175. err = nfs_get_cb_ident_idr(clp, cl_init->minorversion);
  176. if (err)
  177. goto error;
  178. if (cl_init->minorversion > NFS4_MAX_MINOR_VERSION) {
  179. err = -EINVAL;
  180. goto error;
  181. }
  182. spin_lock_init(&clp->cl_lock);
  183. INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
  184. INIT_LIST_HEAD(&clp->cl_ds_clients);
  185. rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
  186. clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
  187. clp->cl_minorversion = cl_init->minorversion;
  188. clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
  189. clp->cl_mig_gen = 1;
  190. #if IS_ENABLED(CONFIG_NFS_V4_1)
  191. init_waitqueue_head(&clp->cl_lock_waitq);
  192. #endif
  193. INIT_LIST_HEAD(&clp->pending_cb_stateids);
  194. return clp;
  195. error:
  196. nfs_free_client(clp);
  197. return ERR_PTR(err);
  198. }
  199. /*
  200. * Destroy the NFS4 callback service
  201. */
  202. static void nfs4_destroy_callback(struct nfs_client *clp)
  203. {
  204. if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
  205. nfs_callback_down(clp->cl_mvops->minor_version, clp->cl_net);
  206. }
  207. static void nfs4_shutdown_client(struct nfs_client *clp)
  208. {
  209. if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state))
  210. nfs4_kill_renewd(clp);
  211. clp->cl_mvops->shutdown_client(clp);
  212. nfs4_destroy_callback(clp);
  213. if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
  214. nfs_idmap_delete(clp);
  215. rpc_destroy_wait_queue(&clp->cl_rpcwaitq);
  216. kfree(clp->cl_serverowner);
  217. kfree(clp->cl_serverscope);
  218. kfree(clp->cl_implid);
  219. kfree(clp->cl_owner_id);
  220. }
  221. void nfs4_free_client(struct nfs_client *clp)
  222. {
  223. nfs4_shutdown_client(clp);
  224. nfs_free_client(clp);
  225. }
  226. /*
  227. * Initialize the NFS4 callback service
  228. */
  229. static int nfs4_init_callback(struct nfs_client *clp)
  230. {
  231. struct rpc_xprt *xprt;
  232. int error;
  233. xprt = rcu_dereference_raw(clp->cl_rpcclient->cl_xprt);
  234. if (nfs4_has_session(clp)) {
  235. error = xprt_setup_backchannel(xprt, NFS41_BC_MIN_CALLBACKS);
  236. if (error < 0)
  237. return error;
  238. }
  239. error = nfs_callback_up(clp->cl_mvops->minor_version, xprt);
  240. if (error < 0) {
  241. dprintk("%s: failed to start callback. Error = %d\n",
  242. __func__, error);
  243. return error;
  244. }
  245. __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
  246. return 0;
  247. }
  248. /**
  249. * nfs40_init_client - nfs_client initialization tasks for NFSv4.0
  250. * @clp - nfs_client to initialize
  251. *
  252. * Returns zero on success, or a negative errno if some error occurred.
  253. */
  254. int nfs40_init_client(struct nfs_client *clp)
  255. {
  256. struct nfs4_slot_table *tbl;
  257. int ret;
  258. tbl = kzalloc(sizeof(*tbl), GFP_NOFS);
  259. if (tbl == NULL)
  260. return -ENOMEM;
  261. ret = nfs4_setup_slot_table(tbl, NFS4_MAX_SLOT_TABLE,
  262. "NFSv4.0 transport Slot table");
  263. if (ret) {
  264. kfree(tbl);
  265. return ret;
  266. }
  267. clp->cl_slot_tbl = tbl;
  268. return 0;
  269. }
  270. #if defined(CONFIG_NFS_V4_1)
  271. /**
  272. * nfs41_init_client - nfs_client initialization tasks for NFSv4.1+
  273. * @clp - nfs_client to initialize
  274. *
  275. * Returns zero on success, or a negative errno if some error occurred.
  276. */
  277. int nfs41_init_client(struct nfs_client *clp)
  278. {
  279. struct nfs4_session *session = NULL;
  280. /*
  281. * Create the session and mark it expired.
  282. * When a SEQUENCE operation encounters the expired session
  283. * it will do session recovery to initialize it.
  284. */
  285. session = nfs4_alloc_session(clp);
  286. if (!session)
  287. return -ENOMEM;
  288. clp->cl_session = session;
  289. /*
  290. * The create session reply races with the server back
  291. * channel probe. Mark the client NFS_CS_SESSION_INITING
  292. * so that the client back channel can find the
  293. * nfs_client struct
  294. */
  295. nfs_mark_client_ready(clp, NFS_CS_SESSION_INITING);
  296. return 0;
  297. }
  298. #endif /* CONFIG_NFS_V4_1 */
  299. /*
  300. * Initialize the minor version specific parts of an NFS4 client record
  301. */
  302. static int nfs4_init_client_minor_version(struct nfs_client *clp)
  303. {
  304. int ret;
  305. ret = clp->cl_mvops->init_client(clp);
  306. if (ret)
  307. return ret;
  308. return nfs4_init_callback(clp);
  309. }
  310. /**
  311. * nfs4_init_client - Initialise an NFS4 client record
  312. *
  313. * @clp: nfs_client to initialise
  314. * @timeparms: timeout parameters for underlying RPC transport
  315. * @ip_addr: callback IP address in presentation format
  316. * @authflavor: authentication flavor for underlying RPC transport
  317. *
  318. * Returns pointer to an NFS client, or an ERR_PTR value.
  319. */
  320. struct nfs_client *nfs4_init_client(struct nfs_client *clp,
  321. const struct nfs_client_initdata *cl_init)
  322. {
  323. char buf[INET6_ADDRSTRLEN + 1];
  324. const char *ip_addr = cl_init->ip_addr;
  325. struct nfs_client *old;
  326. int error;
  327. if (clp->cl_cons_state == NFS_CS_READY)
  328. /* the client is initialised already */
  329. return clp;
  330. /* Check NFS protocol revision and initialize RPC op vector */
  331. clp->rpc_ops = &nfs_v4_clientops;
  332. if (clp->cl_minorversion != 0)
  333. __set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags);
  334. __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
  335. __set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags);
  336. error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_GSS_KRB5I);
  337. if (error == -EINVAL)
  338. error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
  339. if (error < 0)
  340. goto error;
  341. /* If no clientaddr= option was specified, find a usable cb address */
  342. if (ip_addr == NULL) {
  343. struct sockaddr_storage cb_addr;
  344. struct sockaddr *sap = (struct sockaddr *)&cb_addr;
  345. error = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
  346. if (error < 0)
  347. goto error;
  348. error = rpc_ntop(sap, buf, sizeof(buf));
  349. if (error < 0)
  350. goto error;
  351. ip_addr = (const char *)buf;
  352. }
  353. strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
  354. error = nfs_idmap_new(clp);
  355. if (error < 0) {
  356. dprintk("%s: failed to create idmapper. Error = %d\n",
  357. __func__, error);
  358. goto error;
  359. }
  360. __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
  361. error = nfs4_init_client_minor_version(clp);
  362. if (error < 0)
  363. goto error;
  364. error = nfs4_discover_server_trunking(clp, &old);
  365. if (error < 0)
  366. goto error;
  367. if (clp != old) {
  368. clp->cl_preserve_clid = true;
  369. /*
  370. * Mark the client as having failed initialization so other
  371. * processes walking the nfs_client_list in nfs_match_client()
  372. * won't try to use it.
  373. */
  374. nfs_mark_client_ready(clp, -EPERM);
  375. }
  376. nfs_put_client(clp);
  377. clear_bit(NFS_CS_TSM_POSSIBLE, &clp->cl_flags);
  378. return old;
  379. error:
  380. nfs_mark_client_ready(clp, error);
  381. nfs_put_client(clp);
  382. return ERR_PTR(error);
  383. }
  384. /*
  385. * SETCLIENTID just did a callback update with the callback ident in
  386. * "drop," but server trunking discovery claims "drop" and "keep" are
  387. * actually the same server. Swap the callback IDs so that "keep"
  388. * will continue to use the callback ident the server now knows about,
  389. * and so that "keep"'s original callback ident is destroyed when
  390. * "drop" is freed.
  391. */
  392. static void nfs4_swap_callback_idents(struct nfs_client *keep,
  393. struct nfs_client *drop)
  394. {
  395. struct nfs_net *nn = net_generic(keep->cl_net, nfs_net_id);
  396. unsigned int save = keep->cl_cb_ident;
  397. if (keep->cl_cb_ident == drop->cl_cb_ident)
  398. return;
  399. dprintk("%s: keeping callback ident %u and dropping ident %u\n",
  400. __func__, keep->cl_cb_ident, drop->cl_cb_ident);
  401. spin_lock(&nn->nfs_client_lock);
  402. idr_replace(&nn->cb_ident_idr, keep, drop->cl_cb_ident);
  403. keep->cl_cb_ident = drop->cl_cb_ident;
  404. idr_replace(&nn->cb_ident_idr, drop, save);
  405. drop->cl_cb_ident = save;
  406. spin_unlock(&nn->nfs_client_lock);
  407. }
  408. static bool nfs4_match_client_owner_id(const struct nfs_client *clp1,
  409. const struct nfs_client *clp2)
  410. {
  411. if (clp1->cl_owner_id == NULL || clp2->cl_owner_id == NULL)
  412. return true;
  413. return strcmp(clp1->cl_owner_id, clp2->cl_owner_id) == 0;
  414. }
  415. static bool nfs4_same_verifier(nfs4_verifier *v1, nfs4_verifier *v2)
  416. {
  417. return memcmp(v1->data, v2->data, sizeof(v1->data)) == 0;
  418. }
  419. static int nfs4_match_client(struct nfs_client *pos, struct nfs_client *new,
  420. struct nfs_client **prev, struct nfs_net *nn)
  421. {
  422. int status;
  423. if (pos->rpc_ops != new->rpc_ops)
  424. return 1;
  425. if (pos->cl_minorversion != new->cl_minorversion)
  426. return 1;
  427. /* If "pos" isn't marked ready, we can't trust the
  428. * remaining fields in "pos", especially the client
  429. * ID and serverowner fields. Wait for CREATE_SESSION
  430. * to finish. */
  431. if (pos->cl_cons_state > NFS_CS_READY) {
  432. refcount_inc(&pos->cl_count);
  433. spin_unlock(&nn->nfs_client_lock);
  434. nfs_put_client(*prev);
  435. *prev = pos;
  436. status = nfs_wait_client_init_complete(pos);
  437. spin_lock(&nn->nfs_client_lock);
  438. if (status < 0)
  439. return status;
  440. }
  441. if (pos->cl_cons_state != NFS_CS_READY)
  442. return 1;
  443. if (pos->cl_clientid != new->cl_clientid)
  444. return 1;
  445. /* NFSv4.1 always uses the uniform string, however someone
  446. * might switch the uniquifier string on us.
  447. */
  448. if (!nfs4_match_client_owner_id(pos, new))
  449. return 1;
  450. return 0;
  451. }
  452. /**
  453. * nfs40_walk_client_list - Find server that recognizes a client ID
  454. *
  455. * @new: nfs_client with client ID to test
  456. * @result: OUT: found nfs_client, or new
  457. * @cred: credential to use for trunking test
  458. *
  459. * Returns zero, a negative errno, or a negative NFS4ERR status.
  460. * If zero is returned, an nfs_client pointer is planted in "result."
  461. *
  462. * NB: nfs40_walk_client_list() relies on the new nfs_client being
  463. * the last nfs_client on the list.
  464. */
  465. int nfs40_walk_client_list(struct nfs_client *new,
  466. struct nfs_client **result,
  467. struct rpc_cred *cred)
  468. {
  469. struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
  470. struct nfs_client *pos, *prev = NULL;
  471. struct nfs4_setclientid_res clid = {
  472. .clientid = new->cl_clientid,
  473. .confirm = new->cl_confirm,
  474. };
  475. int status = -NFS4ERR_STALE_CLIENTID;
  476. spin_lock(&nn->nfs_client_lock);
  477. list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {
  478. if (pos == new)
  479. goto found;
  480. status = nfs4_match_client(pos, new, &prev, nn);
  481. if (status < 0)
  482. goto out_unlock;
  483. if (status != 0)
  484. continue;
  485. /*
  486. * We just sent a new SETCLIENTID, which should have
  487. * caused the server to return a new cl_confirm. So if
  488. * cl_confirm is the same, then this is a different
  489. * server that just returned the same cl_confirm by
  490. * coincidence:
  491. */
  492. if ((new != pos) && nfs4_same_verifier(&pos->cl_confirm,
  493. &new->cl_confirm))
  494. continue;
  495. /*
  496. * But if the cl_confirm's are different, then the only
  497. * way that a SETCLIENTID_CONFIRM to pos can succeed is
  498. * if new and pos point to the same server:
  499. */
  500. found:
  501. refcount_inc(&pos->cl_count);
  502. spin_unlock(&nn->nfs_client_lock);
  503. nfs_put_client(prev);
  504. prev = pos;
  505. status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
  506. switch (status) {
  507. case -NFS4ERR_STALE_CLIENTID:
  508. break;
  509. case 0:
  510. nfs4_swap_callback_idents(pos, new);
  511. pos->cl_confirm = new->cl_confirm;
  512. nfs_mark_client_ready(pos, NFS_CS_READY);
  513. prev = NULL;
  514. *result = pos;
  515. goto out;
  516. case -ERESTARTSYS:
  517. case -ETIMEDOUT:
  518. /* The callback path may have been inadvertently
  519. * changed. Schedule recovery!
  520. */
  521. nfs4_schedule_path_down_recovery(pos);
  522. default:
  523. goto out;
  524. }
  525. spin_lock(&nn->nfs_client_lock);
  526. }
  527. out_unlock:
  528. spin_unlock(&nn->nfs_client_lock);
  529. /* No match found. The server lost our clientid */
  530. out:
  531. nfs_put_client(prev);
  532. return status;
  533. }
  534. #ifdef CONFIG_NFS_V4_1
  535. /*
  536. * Returns true if the server major ids match
  537. */
  538. static bool
  539. nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1,
  540. struct nfs41_server_owner *o2)
  541. {
  542. if (o1->major_id_sz != o2->major_id_sz)
  543. return false;
  544. return memcmp(o1->major_id, o2->major_id, o1->major_id_sz) == 0;
  545. }
  546. /*
  547. * Returns true if the server scopes match
  548. */
  549. static bool
  550. nfs4_check_server_scope(struct nfs41_server_scope *s1,
  551. struct nfs41_server_scope *s2)
  552. {
  553. if (s1->server_scope_sz != s2->server_scope_sz)
  554. return false;
  555. return memcmp(s1->server_scope, s2->server_scope,
  556. s1->server_scope_sz) == 0;
  557. }
  558. /**
  559. * nfs4_detect_session_trunking - Checks for session trunking.
  560. *
  561. * Called after a successful EXCHANGE_ID on a multi-addr connection.
  562. * Upon success, add the transport.
  563. *
  564. * @clp: original mount nfs_client
  565. * @res: result structure from an exchange_id using the original mount
  566. * nfs_client with a new multi_addr transport
  567. *
  568. * Returns zero on success, otherwise -EINVAL
  569. *
  570. * Note: since the exchange_id for the new multi_addr transport uses the
  571. * same nfs_client from the original mount, the cl_owner_id is reused,
  572. * so eir_clientowner is the same.
  573. */
  574. int nfs4_detect_session_trunking(struct nfs_client *clp,
  575. struct nfs41_exchange_id_res *res,
  576. struct rpc_xprt *xprt)
  577. {
  578. /* Check eir_clientid */
  579. if (clp->cl_clientid != res->clientid)
  580. goto out_err;
  581. /* Check eir_server_owner so_major_id */
  582. if (!nfs4_check_serverowner_major_id(clp->cl_serverowner,
  583. res->server_owner))
  584. goto out_err;
  585. /* Check eir_server_owner so_minor_id */
  586. if (clp->cl_serverowner->minor_id != res->server_owner->minor_id)
  587. goto out_err;
  588. /* Check eir_server_scope */
  589. if (!nfs4_check_server_scope(clp->cl_serverscope, res->server_scope))
  590. goto out_err;
  591. pr_info("NFS: %s: Session trunking succeeded for %s\n",
  592. clp->cl_hostname,
  593. xprt->address_strings[RPC_DISPLAY_ADDR]);
  594. return 0;
  595. out_err:
  596. pr_info("NFS: %s: Session trunking failed for %s\n", clp->cl_hostname,
  597. xprt->address_strings[RPC_DISPLAY_ADDR]);
  598. return -EINVAL;
  599. }
  600. /**
  601. * nfs41_walk_client_list - Find nfs_client that matches a client/server owner
  602. *
  603. * @new: nfs_client with client ID to test
  604. * @result: OUT: found nfs_client, or new
  605. * @cred: credential to use for trunking test
  606. *
  607. * Returns zero, a negative errno, or a negative NFS4ERR status.
  608. * If zero is returned, an nfs_client pointer is planted in "result."
  609. *
  610. * NB: nfs41_walk_client_list() relies on the new nfs_client being
  611. * the last nfs_client on the list.
  612. */
  613. int nfs41_walk_client_list(struct nfs_client *new,
  614. struct nfs_client **result,
  615. struct rpc_cred *cred)
  616. {
  617. struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
  618. struct nfs_client *pos, *prev = NULL;
  619. int status = -NFS4ERR_STALE_CLIENTID;
  620. spin_lock(&nn->nfs_client_lock);
  621. list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {
  622. if (pos == new)
  623. goto found;
  624. status = nfs4_match_client(pos, new, &prev, nn);
  625. if (status < 0)
  626. goto out;
  627. if (status != 0)
  628. continue;
  629. /*
  630. * Note that session trunking is just a special subcase of
  631. * client id trunking. In either case, we want to fall back
  632. * to using the existing nfs_client.
  633. */
  634. if (!nfs4_check_serverowner_major_id(pos->cl_serverowner,
  635. new->cl_serverowner))
  636. continue;
  637. found:
  638. refcount_inc(&pos->cl_count);
  639. *result = pos;
  640. status = 0;
  641. break;
  642. }
  643. out:
  644. spin_unlock(&nn->nfs_client_lock);
  645. nfs_put_client(prev);
  646. return status;
  647. }
  648. #endif /* CONFIG_NFS_V4_1 */
  649. static void nfs4_destroy_server(struct nfs_server *server)
  650. {
  651. nfs_server_return_all_delegations(server);
  652. unset_pnfs_layoutdriver(server);
  653. nfs4_purge_state_owners(server);
  654. }
  655. /*
  656. * NFSv4.0 callback thread helper
  657. *
  658. * Find a client by callback identifier
  659. */
  660. struct nfs_client *
  661. nfs4_find_client_ident(struct net *net, int cb_ident)
  662. {
  663. struct nfs_client *clp;
  664. struct nfs_net *nn = net_generic(net, nfs_net_id);
  665. spin_lock(&nn->nfs_client_lock);
  666. clp = idr_find(&nn->cb_ident_idr, cb_ident);
  667. if (clp)
  668. refcount_inc(&clp->cl_count);
  669. spin_unlock(&nn->nfs_client_lock);
  670. return clp;
  671. }
  672. #if defined(CONFIG_NFS_V4_1)
  673. /* Common match routine for v4.0 and v4.1 callback services */
  674. static bool nfs4_cb_match_client(const struct sockaddr *addr,
  675. struct nfs_client *clp, u32 minorversion)
  676. {
  677. struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
  678. /* Don't match clients that failed to initialise */
  679. if (!(clp->cl_cons_state == NFS_CS_READY ||
  680. clp->cl_cons_state == NFS_CS_SESSION_INITING))
  681. return false;
  682. smp_rmb();
  683. /* Match the version and minorversion */
  684. if (clp->rpc_ops->version != 4 ||
  685. clp->cl_minorversion != minorversion)
  686. return false;
  687. /* Match only the IP address, not the port number */
  688. return rpc_cmp_addr(addr, clap);
  689. }
  690. /*
  691. * NFSv4.1 callback thread helper
  692. * For CB_COMPOUND calls, find a client by IP address, protocol version,
  693. * minorversion, and sessionID
  694. *
  695. * Returns NULL if no such client
  696. */
  697. struct nfs_client *
  698. nfs4_find_client_sessionid(struct net *net, const struct sockaddr *addr,
  699. struct nfs4_sessionid *sid, u32 minorversion)
  700. {
  701. struct nfs_client *clp;
  702. struct nfs_net *nn = net_generic(net, nfs_net_id);
  703. spin_lock(&nn->nfs_client_lock);
  704. list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
  705. if (!nfs4_cb_match_client(addr, clp, minorversion))
  706. continue;
  707. if (!nfs4_has_session(clp))
  708. continue;
  709. /* Match sessionid*/
  710. if (memcmp(clp->cl_session->sess_id.data,
  711. sid->data, NFS4_MAX_SESSIONID_LEN) != 0)
  712. continue;
  713. refcount_inc(&clp->cl_count);
  714. spin_unlock(&nn->nfs_client_lock);
  715. return clp;
  716. }
  717. spin_unlock(&nn->nfs_client_lock);
  718. return NULL;
  719. }
  720. #else /* CONFIG_NFS_V4_1 */
  721. struct nfs_client *
  722. nfs4_find_client_sessionid(struct net *net, const struct sockaddr *addr,
  723. struct nfs4_sessionid *sid, u32 minorversion)
  724. {
  725. return NULL;
  726. }
  727. #endif /* CONFIG_NFS_V4_1 */
  728. /*
  729. * Set up an NFS4 client
  730. */
  731. static int nfs4_set_client(struct nfs_server *server,
  732. const char *hostname,
  733. const struct sockaddr *addr,
  734. const size_t addrlen,
  735. const char *ip_addr,
  736. int proto, const struct rpc_timeout *timeparms,
  737. u32 minorversion, struct net *net)
  738. {
  739. struct nfs_client_initdata cl_init = {
  740. .hostname = hostname,
  741. .addr = addr,
  742. .addrlen = addrlen,
  743. .ip_addr = ip_addr,
  744. .nfs_mod = &nfs_v4,
  745. .proto = proto,
  746. .minorversion = minorversion,
  747. .net = net,
  748. .timeparms = timeparms,
  749. };
  750. struct nfs_client *clp;
  751. if (server->flags & NFS_MOUNT_NORESVPORT)
  752. set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags);
  753. if (server->options & NFS_OPTION_MIGRATION)
  754. set_bit(NFS_CS_MIGRATION, &cl_init.init_flags);
  755. if (test_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status))
  756. set_bit(NFS_CS_TSM_POSSIBLE, &cl_init.init_flags);
  757. server->port = rpc_get_port(addr);
  758. /* Allocate or find a client reference we can use */
  759. clp = nfs_get_client(&cl_init);
  760. if (IS_ERR(clp))
  761. return PTR_ERR(clp);
  762. if (server->nfs_client == clp) {
  763. nfs_put_client(clp);
  764. return -ELOOP;
  765. }
  766. /*
  767. * Query for the lease time on clientid setup or renewal
  768. *
  769. * Note that this will be set on nfs_clients that were created
  770. * only for the DS role and did not set this bit, but now will
  771. * serve a dual role.
  772. */
  773. set_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state);
  774. server->nfs_client = clp;
  775. return 0;
  776. }
  777. /*
  778. * Set up a pNFS Data Server client.
  779. *
  780. * Return any existing nfs_client that matches server address,port,version
  781. * and minorversion.
  782. *
  783. * For a new nfs_client, use a soft mount (default), a low retrans and a
  784. * low timeout interval so that if a connection is lost, we retry through
  785. * the MDS.
  786. */
  787. struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv,
  788. const struct sockaddr *ds_addr, int ds_addrlen,
  789. int ds_proto, unsigned int ds_timeo, unsigned int ds_retrans,
  790. u32 minor_version)
  791. {
  792. struct rpc_timeout ds_timeout;
  793. struct nfs_client *mds_clp = mds_srv->nfs_client;
  794. struct nfs_client_initdata cl_init = {
  795. .addr = ds_addr,
  796. .addrlen = ds_addrlen,
  797. .nodename = mds_clp->cl_rpcclient->cl_nodename,
  798. .ip_addr = mds_clp->cl_ipaddr,
  799. .nfs_mod = &nfs_v4,
  800. .proto = ds_proto,
  801. .minorversion = minor_version,
  802. .net = mds_clp->cl_net,
  803. .timeparms = &ds_timeout,
  804. };
  805. char buf[INET6_ADDRSTRLEN + 1];
  806. if (rpc_ntop(ds_addr, buf, sizeof(buf)) <= 0)
  807. return ERR_PTR(-EINVAL);
  808. cl_init.hostname = buf;
  809. if (mds_srv->flags & NFS_MOUNT_NORESVPORT)
  810. __set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags);
  811. /*
  812. * Set an authflavor equual to the MDS value. Use the MDS nfs_client
  813. * cl_ipaddr so as to use the same EXCHANGE_ID co_ownerid as the MDS
  814. * (section 13.1 RFC 5661).
  815. */
  816. nfs_init_timeout_values(&ds_timeout, ds_proto, ds_timeo, ds_retrans);
  817. return nfs_get_client(&cl_init);
  818. }
  819. EXPORT_SYMBOL_GPL(nfs4_set_ds_client);
  820. /*
  821. * Session has been established, and the client marked ready.
  822. * Set the mount rsize and wsize with negotiated fore channel
  823. * attributes which will be bound checked in nfs_server_set_fsinfo.
  824. */
  825. static void nfs4_session_set_rwsize(struct nfs_server *server)
  826. {
  827. #ifdef CONFIG_NFS_V4_1
  828. struct nfs4_session *sess;
  829. u32 server_resp_sz;
  830. u32 server_rqst_sz;
  831. if (!nfs4_has_session(server->nfs_client))
  832. return;
  833. sess = server->nfs_client->cl_session;
  834. server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
  835. server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
  836. if (!server->rsize || server->rsize > server_resp_sz)
  837. server->rsize = server_resp_sz;
  838. if (!server->wsize || server->wsize > server_rqst_sz)
  839. server->wsize = server_rqst_sz;
  840. #endif /* CONFIG_NFS_V4_1 */
  841. }
  842. static int nfs4_server_common_setup(struct nfs_server *server,
  843. struct nfs_fh *mntfh, bool auth_probe)
  844. {
  845. struct nfs_fattr *fattr;
  846. int error;
  847. /* data servers support only a subset of NFSv4.1 */
  848. if (is_ds_only_client(server->nfs_client))
  849. return -EPROTONOSUPPORT;
  850. fattr = nfs_alloc_fattr();
  851. if (fattr == NULL)
  852. return -ENOMEM;
  853. /* We must ensure the session is initialised first */
  854. error = nfs4_init_session(server->nfs_client);
  855. if (error < 0)
  856. goto out;
  857. /* Set the basic capabilities */
  858. server->caps |= server->nfs_client->cl_mvops->init_caps;
  859. if (server->flags & NFS_MOUNT_NORDIRPLUS)
  860. server->caps &= ~NFS_CAP_READDIRPLUS;
  861. /*
  862. * Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower
  863. * authentication.
  864. */
  865. if (nfs4_disable_idmapping &&
  866. server->client->cl_auth->au_flavor == RPC_AUTH_UNIX)
  867. server->caps |= NFS_CAP_UIDGID_NOMAP;
  868. /* Probe the root fh to retrieve its FSID and filehandle */
  869. error = nfs4_get_rootfh(server, mntfh, auth_probe);
  870. if (error < 0)
  871. goto out;
  872. dprintk("Server FSID: %llx:%llx\n",
  873. (unsigned long long) server->fsid.major,
  874. (unsigned long long) server->fsid.minor);
  875. nfs_display_fhandle(mntfh, "Pseudo-fs root FH");
  876. nfs4_session_set_rwsize(server);
  877. error = nfs_probe_fsinfo(server, mntfh, fattr);
  878. if (error < 0)
  879. goto out;
  880. if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
  881. server->namelen = NFS4_MAXNAMLEN;
  882. nfs_server_insert_lists(server);
  883. server->mount_time = jiffies;
  884. server->destroy = nfs4_destroy_server;
  885. out:
  886. nfs_free_fattr(fattr);
  887. return error;
  888. }
  889. /*
  890. * Create a version 4 volume record
  891. */
  892. static int nfs4_init_server(struct nfs_server *server,
  893. struct nfs_parsed_mount_data *data)
  894. {
  895. struct rpc_timeout timeparms;
  896. int error;
  897. nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
  898. data->timeo, data->retrans);
  899. /* Initialise the client representation from the mount data */
  900. server->flags = data->flags;
  901. server->options = data->options;
  902. server->auth_info = data->auth_info;
  903. /* Use the first specified auth flavor. If this flavor isn't
  904. * allowed by the server, use the SECINFO path to try the
  905. * other specified flavors */
  906. if (data->auth_info.flavor_len >= 1)
  907. data->selected_flavor = data->auth_info.flavors[0];
  908. else
  909. data->selected_flavor = RPC_AUTH_UNIX;
  910. /* Get a client record */
  911. error = nfs4_set_client(server,
  912. data->nfs_server.hostname,
  913. (const struct sockaddr *)&data->nfs_server.address,
  914. data->nfs_server.addrlen,
  915. data->client_address,
  916. data->nfs_server.protocol,
  917. &timeparms,
  918. data->minorversion,
  919. data->net);
  920. if (error < 0)
  921. return error;
  922. if (data->rsize)
  923. server->rsize = nfs_block_size(data->rsize, NULL);
  924. if (data->wsize)
  925. server->wsize = nfs_block_size(data->wsize, NULL);
  926. server->acregmin = data->acregmin * HZ;
  927. server->acregmax = data->acregmax * HZ;
  928. server->acdirmin = data->acdirmin * HZ;
  929. server->acdirmax = data->acdirmax * HZ;
  930. server->port = data->nfs_server.port;
  931. return nfs_init_server_rpcclient(server, &timeparms,
  932. data->selected_flavor);
  933. }
  934. /*
  935. * Create a version 4 volume record
  936. * - keyed on server and FSID
  937. */
  938. /*struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
  939. struct nfs_fh *mntfh)*/
  940. struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info,
  941. struct nfs_subversion *nfs_mod)
  942. {
  943. struct nfs_server *server;
  944. bool auth_probe;
  945. int error;
  946. server = nfs_alloc_server();
  947. if (!server)
  948. return ERR_PTR(-ENOMEM);
  949. auth_probe = mount_info->parsed->auth_info.flavor_len < 1;
  950. /* set up the general RPC client */
  951. error = nfs4_init_server(server, mount_info->parsed);
  952. if (error < 0)
  953. goto error;
  954. error = nfs4_server_common_setup(server, mount_info->mntfh, auth_probe);
  955. if (error < 0)
  956. goto error;
  957. return server;
  958. error:
  959. nfs_free_server(server);
  960. return ERR_PTR(error);
  961. }
  962. /*
  963. * Create an NFS4 referral server record
  964. */
  965. struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
  966. struct nfs_fh *mntfh)
  967. {
  968. struct nfs_client *parent_client;
  969. struct nfs_server *server, *parent_server;
  970. bool auth_probe;
  971. int error;
  972. server = nfs_alloc_server();
  973. if (!server)
  974. return ERR_PTR(-ENOMEM);
  975. parent_server = NFS_SB(data->sb);
  976. parent_client = parent_server->nfs_client;
  977. /* Initialise the client representation from the parent server */
  978. nfs_server_copy_userdata(server, parent_server);
  979. /* Get a client representation */
  980. #if IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA)
  981. rpc_set_port(data->addr, NFS_RDMA_PORT);
  982. error = nfs4_set_client(server, data->hostname,
  983. data->addr,
  984. data->addrlen,
  985. parent_client->cl_ipaddr,
  986. XPRT_TRANSPORT_RDMA,
  987. parent_server->client->cl_timeout,
  988. parent_client->cl_mvops->minor_version,
  989. parent_client->cl_net);
  990. if (!error)
  991. goto init_server;
  992. #endif /* IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA) */
  993. rpc_set_port(data->addr, NFS_PORT);
  994. error = nfs4_set_client(server, data->hostname,
  995. data->addr,
  996. data->addrlen,
  997. parent_client->cl_ipaddr,
  998. XPRT_TRANSPORT_TCP,
  999. parent_server->client->cl_timeout,
  1000. parent_client->cl_mvops->minor_version,
  1001. parent_client->cl_net);
  1002. if (error < 0)
  1003. goto error;
  1004. #if IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA)
  1005. init_server:
  1006. #endif
  1007. error = nfs_init_server_rpcclient(server, parent_server->client->cl_timeout, data->authflavor);
  1008. if (error < 0)
  1009. goto error;
  1010. auth_probe = parent_server->auth_info.flavor_len < 1;
  1011. error = nfs4_server_common_setup(server, mntfh, auth_probe);
  1012. if (error < 0)
  1013. goto error;
  1014. return server;
  1015. error:
  1016. nfs_free_server(server);
  1017. return ERR_PTR(error);
  1018. }
  1019. /*
  1020. * Grab the destination's particulars, including lease expiry time.
  1021. *
  1022. * Returns zero if probe succeeded and retrieved FSID matches the FSID
  1023. * we have cached.
  1024. */
  1025. static int nfs_probe_destination(struct nfs_server *server)
  1026. {
  1027. struct inode *inode = d_inode(server->super->s_root);
  1028. struct nfs_fattr *fattr;
  1029. int error;
  1030. fattr = nfs_alloc_fattr();
  1031. if (fattr == NULL)
  1032. return -ENOMEM;
  1033. /* Sanity: the probe won't work if the destination server
  1034. * does not recognize the migrated FH. */
  1035. error = nfs_probe_fsinfo(server, NFS_FH(inode), fattr);
  1036. nfs_free_fattr(fattr);
  1037. return error;
  1038. }
  1039. /**
  1040. * nfs4_update_server - Move an nfs_server to a different nfs_client
  1041. *
  1042. * @server: represents FSID to be moved
  1043. * @hostname: new end-point's hostname
  1044. * @sap: new end-point's socket address
  1045. * @salen: size of "sap"
  1046. * @net: net namespace
  1047. *
  1048. * The nfs_server must be quiescent before this function is invoked.
  1049. * Either its session is drained (NFSv4.1+), or its transport is
  1050. * plugged and drained (NFSv4.0).
  1051. *
  1052. * Returns zero on success, or a negative errno value.
  1053. */
  1054. int nfs4_update_server(struct nfs_server *server, const char *hostname,
  1055. struct sockaddr *sap, size_t salen, struct net *net)
  1056. {
  1057. struct nfs_client *clp = server->nfs_client;
  1058. struct rpc_clnt *clnt = server->client;
  1059. struct xprt_create xargs = {
  1060. .ident = clp->cl_proto,
  1061. .net = net,
  1062. .dstaddr = sap,
  1063. .addrlen = salen,
  1064. .servername = hostname,
  1065. };
  1066. char buf[INET6_ADDRSTRLEN + 1];
  1067. struct sockaddr_storage address;
  1068. struct sockaddr *localaddr = (struct sockaddr *)&address;
  1069. int error;
  1070. error = rpc_switch_client_transport(clnt, &xargs, clnt->cl_timeout);
  1071. if (error != 0)
  1072. return error;
  1073. error = rpc_localaddr(clnt, localaddr, sizeof(address));
  1074. if (error != 0)
  1075. return error;
  1076. if (rpc_ntop(localaddr, buf, sizeof(buf)) == 0)
  1077. return -EAFNOSUPPORT;
  1078. nfs_server_remove_lists(server);
  1079. set_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status);
  1080. error = nfs4_set_client(server, hostname, sap, salen, buf,
  1081. clp->cl_proto, clnt->cl_timeout,
  1082. clp->cl_minorversion, net);
  1083. clear_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status);
  1084. if (error != 0) {
  1085. nfs_server_insert_lists(server);
  1086. return error;
  1087. }
  1088. nfs_put_client(clp);
  1089. if (server->nfs_client->cl_hostname == NULL)
  1090. server->nfs_client->cl_hostname = kstrdup(hostname, GFP_KERNEL);
  1091. nfs_server_insert_lists(server);
  1092. return nfs_probe_destination(server);
  1093. }