nfs4client.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  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. * Limit the mount rsize, wsize and dtsize using negotiated fore
  823. * channel attributes.
  824. */
  825. static void nfs4_session_limit_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->dtsize > server_resp_sz)
  837. server->dtsize = server_resp_sz;
  838. if (server->rsize > server_resp_sz)
  839. server->rsize = server_resp_sz;
  840. if (server->wsize > server_rqst_sz)
  841. server->wsize = server_rqst_sz;
  842. #endif /* CONFIG_NFS_V4_1 */
  843. }
  844. static int nfs4_server_common_setup(struct nfs_server *server,
  845. struct nfs_fh *mntfh, bool auth_probe)
  846. {
  847. struct nfs_fattr *fattr;
  848. int error;
  849. /* data servers support only a subset of NFSv4.1 */
  850. if (is_ds_only_client(server->nfs_client))
  851. return -EPROTONOSUPPORT;
  852. fattr = nfs_alloc_fattr();
  853. if (fattr == NULL)
  854. return -ENOMEM;
  855. /* We must ensure the session is initialised first */
  856. error = nfs4_init_session(server->nfs_client);
  857. if (error < 0)
  858. goto out;
  859. /* Set the basic capabilities */
  860. server->caps |= server->nfs_client->cl_mvops->init_caps;
  861. if (server->flags & NFS_MOUNT_NORDIRPLUS)
  862. server->caps &= ~NFS_CAP_READDIRPLUS;
  863. /*
  864. * Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower
  865. * authentication.
  866. */
  867. if (nfs4_disable_idmapping &&
  868. server->client->cl_auth->au_flavor == RPC_AUTH_UNIX)
  869. server->caps |= NFS_CAP_UIDGID_NOMAP;
  870. /* Probe the root fh to retrieve its FSID and filehandle */
  871. error = nfs4_get_rootfh(server, mntfh, auth_probe);
  872. if (error < 0)
  873. goto out;
  874. dprintk("Server FSID: %llx:%llx\n",
  875. (unsigned long long) server->fsid.major,
  876. (unsigned long long) server->fsid.minor);
  877. nfs_display_fhandle(mntfh, "Pseudo-fs root FH");
  878. error = nfs_probe_fsinfo(server, mntfh, fattr);
  879. if (error < 0)
  880. goto out;
  881. nfs4_session_limit_rwsize(server);
  882. if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
  883. server->namelen = NFS4_MAXNAMLEN;
  884. nfs_server_insert_lists(server);
  885. server->mount_time = jiffies;
  886. server->destroy = nfs4_destroy_server;
  887. out:
  888. nfs_free_fattr(fattr);
  889. return error;
  890. }
  891. /*
  892. * Create a version 4 volume record
  893. */
  894. static int nfs4_init_server(struct nfs_server *server,
  895. struct nfs_parsed_mount_data *data)
  896. {
  897. struct rpc_timeout timeparms;
  898. int error;
  899. nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
  900. data->timeo, data->retrans);
  901. /* Initialise the client representation from the mount data */
  902. server->flags = data->flags;
  903. server->options = data->options;
  904. server->auth_info = data->auth_info;
  905. /* Use the first specified auth flavor. If this flavor isn't
  906. * allowed by the server, use the SECINFO path to try the
  907. * other specified flavors */
  908. if (data->auth_info.flavor_len >= 1)
  909. data->selected_flavor = data->auth_info.flavors[0];
  910. else
  911. data->selected_flavor = RPC_AUTH_UNIX;
  912. /* Get a client record */
  913. error = nfs4_set_client(server,
  914. data->nfs_server.hostname,
  915. (const struct sockaddr *)&data->nfs_server.address,
  916. data->nfs_server.addrlen,
  917. data->client_address,
  918. data->nfs_server.protocol,
  919. &timeparms,
  920. data->minorversion,
  921. data->net);
  922. if (error < 0)
  923. return error;
  924. if (data->rsize)
  925. server->rsize = nfs_block_size(data->rsize, NULL);
  926. if (data->wsize)
  927. server->wsize = nfs_block_size(data->wsize, NULL);
  928. server->acregmin = data->acregmin * HZ;
  929. server->acregmax = data->acregmax * HZ;
  930. server->acdirmin = data->acdirmin * HZ;
  931. server->acdirmax = data->acdirmax * HZ;
  932. server->port = data->nfs_server.port;
  933. return nfs_init_server_rpcclient(server, &timeparms,
  934. data->selected_flavor);
  935. }
  936. /*
  937. * Create a version 4 volume record
  938. * - keyed on server and FSID
  939. */
  940. /*struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
  941. struct nfs_fh *mntfh)*/
  942. struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info,
  943. struct nfs_subversion *nfs_mod)
  944. {
  945. struct nfs_server *server;
  946. bool auth_probe;
  947. int error;
  948. server = nfs_alloc_server();
  949. if (!server)
  950. return ERR_PTR(-ENOMEM);
  951. auth_probe = mount_info->parsed->auth_info.flavor_len < 1;
  952. /* set up the general RPC client */
  953. error = nfs4_init_server(server, mount_info->parsed);
  954. if (error < 0)
  955. goto error;
  956. error = nfs4_server_common_setup(server, mount_info->mntfh, auth_probe);
  957. if (error < 0)
  958. goto error;
  959. return server;
  960. error:
  961. nfs_free_server(server);
  962. return ERR_PTR(error);
  963. }
  964. /*
  965. * Create an NFS4 referral server record
  966. */
  967. struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
  968. struct nfs_fh *mntfh)
  969. {
  970. struct nfs_client *parent_client;
  971. struct nfs_server *server, *parent_server;
  972. bool auth_probe;
  973. int error;
  974. server = nfs_alloc_server();
  975. if (!server)
  976. return ERR_PTR(-ENOMEM);
  977. parent_server = NFS_SB(data->sb);
  978. parent_client = parent_server->nfs_client;
  979. /* Initialise the client representation from the parent server */
  980. nfs_server_copy_userdata(server, parent_server);
  981. /* Get a client representation */
  982. #if IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA)
  983. rpc_set_port(data->addr, NFS_RDMA_PORT);
  984. error = nfs4_set_client(server, data->hostname,
  985. data->addr,
  986. data->addrlen,
  987. parent_client->cl_ipaddr,
  988. XPRT_TRANSPORT_RDMA,
  989. parent_server->client->cl_timeout,
  990. parent_client->cl_mvops->minor_version,
  991. parent_client->cl_net);
  992. if (!error)
  993. goto init_server;
  994. #endif /* IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA) */
  995. rpc_set_port(data->addr, NFS_PORT);
  996. error = nfs4_set_client(server, data->hostname,
  997. data->addr,
  998. data->addrlen,
  999. parent_client->cl_ipaddr,
  1000. XPRT_TRANSPORT_TCP,
  1001. parent_server->client->cl_timeout,
  1002. parent_client->cl_mvops->minor_version,
  1003. parent_client->cl_net);
  1004. if (error < 0)
  1005. goto error;
  1006. #if IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA)
  1007. init_server:
  1008. #endif
  1009. error = nfs_init_server_rpcclient(server, parent_server->client->cl_timeout, data->authflavor);
  1010. if (error < 0)
  1011. goto error;
  1012. auth_probe = parent_server->auth_info.flavor_len < 1;
  1013. error = nfs4_server_common_setup(server, mntfh, auth_probe);
  1014. if (error < 0)
  1015. goto error;
  1016. return server;
  1017. error:
  1018. nfs_free_server(server);
  1019. return ERR_PTR(error);
  1020. }
  1021. /*
  1022. * Grab the destination's particulars, including lease expiry time.
  1023. *
  1024. * Returns zero if probe succeeded and retrieved FSID matches the FSID
  1025. * we have cached.
  1026. */
  1027. static int nfs_probe_destination(struct nfs_server *server)
  1028. {
  1029. struct inode *inode = d_inode(server->super->s_root);
  1030. struct nfs_fattr *fattr;
  1031. int error;
  1032. fattr = nfs_alloc_fattr();
  1033. if (fattr == NULL)
  1034. return -ENOMEM;
  1035. /* Sanity: the probe won't work if the destination server
  1036. * does not recognize the migrated FH. */
  1037. error = nfs_probe_fsinfo(server, NFS_FH(inode), fattr);
  1038. nfs_free_fattr(fattr);
  1039. return error;
  1040. }
  1041. /**
  1042. * nfs4_update_server - Move an nfs_server to a different nfs_client
  1043. *
  1044. * @server: represents FSID to be moved
  1045. * @hostname: new end-point's hostname
  1046. * @sap: new end-point's socket address
  1047. * @salen: size of "sap"
  1048. * @net: net namespace
  1049. *
  1050. * The nfs_server must be quiescent before this function is invoked.
  1051. * Either its session is drained (NFSv4.1+), or its transport is
  1052. * plugged and drained (NFSv4.0).
  1053. *
  1054. * Returns zero on success, or a negative errno value.
  1055. */
  1056. int nfs4_update_server(struct nfs_server *server, const char *hostname,
  1057. struct sockaddr *sap, size_t salen, struct net *net)
  1058. {
  1059. struct nfs_client *clp = server->nfs_client;
  1060. struct rpc_clnt *clnt = server->client;
  1061. struct xprt_create xargs = {
  1062. .ident = clp->cl_proto,
  1063. .net = net,
  1064. .dstaddr = sap,
  1065. .addrlen = salen,
  1066. .servername = hostname,
  1067. };
  1068. char buf[INET6_ADDRSTRLEN + 1];
  1069. struct sockaddr_storage address;
  1070. struct sockaddr *localaddr = (struct sockaddr *)&address;
  1071. int error;
  1072. error = rpc_switch_client_transport(clnt, &xargs, clnt->cl_timeout);
  1073. if (error != 0)
  1074. return error;
  1075. error = rpc_localaddr(clnt, localaddr, sizeof(address));
  1076. if (error != 0)
  1077. return error;
  1078. if (rpc_ntop(localaddr, buf, sizeof(buf)) == 0)
  1079. return -EAFNOSUPPORT;
  1080. nfs_server_remove_lists(server);
  1081. set_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status);
  1082. error = nfs4_set_client(server, hostname, sap, salen, buf,
  1083. clp->cl_proto, clnt->cl_timeout,
  1084. clp->cl_minorversion, net);
  1085. clear_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status);
  1086. if (error != 0) {
  1087. nfs_server_insert_lists(server);
  1088. return error;
  1089. }
  1090. nfs_put_client(clp);
  1091. if (server->nfs_client->cl_hostname == NULL)
  1092. server->nfs_client->cl_hostname = kstrdup(hostname, GFP_KERNEL);
  1093. nfs_server_insert_lists(server);
  1094. return nfs_probe_destination(server);
  1095. }