host.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /*
  2. * linux/fs/lockd/host.c
  3. *
  4. * Management for NLM peer hosts. The nlm_host struct is shared
  5. * between client and server implementation. The only reason to
  6. * do so is to reduce code bloat.
  7. *
  8. * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
  9. */
  10. #include <linux/types.h>
  11. #include <linux/slab.h>
  12. #include <linux/in.h>
  13. #include <linux/in6.h>
  14. #include <linux/sunrpc/clnt.h>
  15. #include <linux/sunrpc/svc.h>
  16. #include <linux/lockd/lockd.h>
  17. #include <linux/lockd/sm_inter.h>
  18. #include <linux/mutex.h>
  19. #include <net/ipv6.h>
  20. #define NLMDBG_FACILITY NLMDBG_HOSTCACHE
  21. #define NLM_HOST_NRHASH 32
  22. #define NLM_HOST_REBIND (60 * HZ)
  23. #define NLM_HOST_EXPIRE (300 * HZ)
  24. #define NLM_HOST_COLLECT (120 * HZ)
  25. static struct hlist_head nlm_hosts[NLM_HOST_NRHASH];
  26. static unsigned long next_gc;
  27. static int nrhosts;
  28. static DEFINE_MUTEX(nlm_host_mutex);
  29. static void nlm_gc_hosts(void);
  30. static struct nsm_handle * __nsm_find(const struct sockaddr_in *,
  31. const char *, unsigned int, int);
  32. static struct nsm_handle * nsm_find(const struct sockaddr_in *sin,
  33. const char *hostname,
  34. unsigned int hostname_len);
  35. /*
  36. * Hash function must work well on big- and little-endian platforms
  37. */
  38. static unsigned int __nlm_hash32(const __be32 n)
  39. {
  40. unsigned int hash = (__force u32)n ^ ((__force u32)n >> 16);
  41. return hash ^ (hash >> 8);
  42. }
  43. static unsigned int __nlm_hash_addr4(const struct sockaddr *sap)
  44. {
  45. const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
  46. return __nlm_hash32(sin->sin_addr.s_addr);
  47. }
  48. static unsigned int __nlm_hash_addr6(const struct sockaddr *sap)
  49. {
  50. const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
  51. const struct in6_addr addr = sin6->sin6_addr;
  52. return __nlm_hash32(addr.s6_addr32[0]) ^
  53. __nlm_hash32(addr.s6_addr32[1]) ^
  54. __nlm_hash32(addr.s6_addr32[2]) ^
  55. __nlm_hash32(addr.s6_addr32[3]);
  56. }
  57. static unsigned int nlm_hash_address(const struct sockaddr *sap)
  58. {
  59. unsigned int hash;
  60. switch (sap->sa_family) {
  61. case AF_INET:
  62. hash = __nlm_hash_addr4(sap);
  63. break;
  64. case AF_INET6:
  65. hash = __nlm_hash_addr6(sap);
  66. break;
  67. default:
  68. hash = 0;
  69. }
  70. return hash & (NLM_HOST_NRHASH - 1);
  71. }
  72. static void nlm_clear_port(struct sockaddr *sap)
  73. {
  74. switch (sap->sa_family) {
  75. case AF_INET:
  76. ((struct sockaddr_in *)sap)->sin_port = 0;
  77. break;
  78. case AF_INET6:
  79. ((struct sockaddr_in6 *)sap)->sin6_port = 0;
  80. break;
  81. }
  82. }
  83. static void nlm_display_address(const struct sockaddr *sap,
  84. char *buf, const size_t len)
  85. {
  86. const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
  87. const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
  88. switch (sap->sa_family) {
  89. case AF_UNSPEC:
  90. snprintf(buf, len, "unspecified");
  91. break;
  92. case AF_INET:
  93. snprintf(buf, len, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr));
  94. break;
  95. case AF_INET6:
  96. if (ipv6_addr_v4mapped(&sin6->sin6_addr))
  97. snprintf(buf, len, NIPQUAD_FMT,
  98. NIPQUAD(sin6->sin6_addr.s6_addr32[3]));
  99. else
  100. snprintf(buf, len, NIP6_FMT, NIP6(sin6->sin6_addr));
  101. break;
  102. default:
  103. snprintf(buf, len, "unsupported address family");
  104. break;
  105. }
  106. }
  107. /*
  108. * Common host lookup routine for server & client
  109. */
  110. static struct nlm_host *nlm_lookup_host(int server,
  111. const struct sockaddr_in *sin,
  112. int proto, u32 version,
  113. const char *hostname,
  114. unsigned int hostname_len,
  115. const struct sockaddr_in *ssin)
  116. {
  117. struct hlist_head *chain;
  118. struct hlist_node *pos;
  119. struct nlm_host *host;
  120. struct nsm_handle *nsm = NULL;
  121. dprintk("lockd: nlm_lookup_host(proto=%d, vers=%u,"
  122. " my role is %s, hostname=%.*s)\n",
  123. proto, version, server ? "server" : "client",
  124. hostname_len, hostname ? hostname : "<none>");
  125. mutex_lock(&nlm_host_mutex);
  126. if (time_after_eq(jiffies, next_gc))
  127. nlm_gc_hosts();
  128. /* We may keep several nlm_host objects for a peer, because each
  129. * nlm_host is identified by
  130. * (address, protocol, version, server/client)
  131. * We could probably simplify this a little by putting all those
  132. * different NLM rpc_clients into one single nlm_host object.
  133. * This would allow us to have one nlm_host per address.
  134. */
  135. chain = &nlm_hosts[nlm_hash_address((struct sockaddr *)sin)];
  136. hlist_for_each_entry(host, pos, chain, h_hash) {
  137. if (!nlm_cmp_addr(nlm_addr(host), (struct sockaddr *)sin))
  138. continue;
  139. /* See if we have an NSM handle for this client */
  140. if (!nsm)
  141. nsm = host->h_nsmhandle;
  142. if (host->h_proto != proto)
  143. continue;
  144. if (host->h_version != version)
  145. continue;
  146. if (host->h_server != server)
  147. continue;
  148. if (!nlm_cmp_addr(nlm_srcaddr(host), (struct sockaddr *)ssin))
  149. continue;
  150. /* Move to head of hash chain. */
  151. hlist_del(&host->h_hash);
  152. hlist_add_head(&host->h_hash, chain);
  153. nlm_get_host(host);
  154. dprintk("lockd: nlm_lookup_host found host %s (%s)\n",
  155. host->h_name, host->h_addrbuf);
  156. goto out;
  157. }
  158. /*
  159. * The host wasn't in our hash table. If we don't
  160. * have an NSM handle for it yet, create one.
  161. */
  162. if (nsm)
  163. atomic_inc(&nsm->sm_count);
  164. else {
  165. host = NULL;
  166. nsm = nsm_find(sin, hostname, hostname_len);
  167. if (!nsm) {
  168. dprintk("lockd: nlm_lookup_host failed; "
  169. "no nsm handle\n");
  170. goto out;
  171. }
  172. }
  173. host = kzalloc(sizeof(*host), GFP_KERNEL);
  174. if (!host) {
  175. nsm_release(nsm);
  176. dprintk("lockd: nlm_lookup_host failed; no memory\n");
  177. goto out;
  178. }
  179. host->h_name = nsm->sm_name;
  180. memcpy(nlm_addr(host), sin, sizeof(*sin));
  181. host->h_addrlen = sizeof(*sin);
  182. nlm_clear_port(nlm_addr(host));
  183. memcpy(nlm_srcaddr(host), ssin, sizeof(*ssin));
  184. host->h_version = version;
  185. host->h_proto = proto;
  186. host->h_rpcclnt = NULL;
  187. mutex_init(&host->h_mutex);
  188. host->h_nextrebind = jiffies + NLM_HOST_REBIND;
  189. host->h_expires = jiffies + NLM_HOST_EXPIRE;
  190. atomic_set(&host->h_count, 1);
  191. init_waitqueue_head(&host->h_gracewait);
  192. init_rwsem(&host->h_rwsem);
  193. host->h_state = 0; /* pseudo NSM state */
  194. host->h_nsmstate = 0; /* real NSM state */
  195. host->h_nsmhandle = nsm;
  196. host->h_server = server;
  197. hlist_add_head(&host->h_hash, chain);
  198. INIT_LIST_HEAD(&host->h_lockowners);
  199. spin_lock_init(&host->h_lock);
  200. INIT_LIST_HEAD(&host->h_granted);
  201. INIT_LIST_HEAD(&host->h_reclaim);
  202. nrhosts++;
  203. nlm_display_address((struct sockaddr *)&host->h_addr,
  204. host->h_addrbuf, sizeof(host->h_addrbuf));
  205. nlm_display_address((struct sockaddr *)&host->h_srcaddr,
  206. host->h_srcaddrbuf, sizeof(host->h_srcaddrbuf));
  207. dprintk("lockd: nlm_lookup_host created host %s\n",
  208. host->h_name);
  209. out:
  210. mutex_unlock(&nlm_host_mutex);
  211. return host;
  212. }
  213. /*
  214. * Destroy a host
  215. */
  216. static void
  217. nlm_destroy_host(struct nlm_host *host)
  218. {
  219. struct rpc_clnt *clnt;
  220. BUG_ON(!list_empty(&host->h_lockowners));
  221. BUG_ON(atomic_read(&host->h_count));
  222. /*
  223. * Release NSM handle and unmonitor host.
  224. */
  225. nsm_unmonitor(host);
  226. clnt = host->h_rpcclnt;
  227. if (clnt != NULL)
  228. rpc_shutdown_client(clnt);
  229. kfree(host);
  230. }
  231. /*
  232. * Find an NLM server handle in the cache. If there is none, create it.
  233. */
  234. struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *sin,
  235. int proto, u32 version,
  236. const char *hostname,
  237. unsigned int hostname_len)
  238. {
  239. const struct sockaddr_in source = {
  240. .sin_family = AF_UNSPEC,
  241. };
  242. return nlm_lookup_host(0, sin, proto, version,
  243. hostname, hostname_len, &source);
  244. }
  245. /*
  246. * Find an NLM client handle in the cache. If there is none, create it.
  247. */
  248. struct nlm_host *
  249. nlmsvc_lookup_host(struct svc_rqst *rqstp,
  250. const char *hostname, unsigned int hostname_len)
  251. {
  252. const struct sockaddr_in source = {
  253. .sin_family = AF_INET,
  254. .sin_addr = rqstp->rq_daddr.addr,
  255. };
  256. return nlm_lookup_host(1, svc_addr_in(rqstp),
  257. rqstp->rq_prot, rqstp->rq_vers,
  258. hostname, hostname_len, &source);
  259. }
  260. /*
  261. * Create the NLM RPC client for an NLM peer
  262. */
  263. struct rpc_clnt *
  264. nlm_bind_host(struct nlm_host *host)
  265. {
  266. struct rpc_clnt *clnt;
  267. dprintk("lockd: nlm_bind_host %s (%s), my addr=%s\n",
  268. host->h_name, host->h_addrbuf, host->h_srcaddrbuf);
  269. /* Lock host handle */
  270. mutex_lock(&host->h_mutex);
  271. /* If we've already created an RPC client, check whether
  272. * RPC rebind is required
  273. */
  274. if ((clnt = host->h_rpcclnt) != NULL) {
  275. if (time_after_eq(jiffies, host->h_nextrebind)) {
  276. rpc_force_rebind(clnt);
  277. host->h_nextrebind = jiffies + NLM_HOST_REBIND;
  278. dprintk("lockd: next rebind in %lu jiffies\n",
  279. host->h_nextrebind - jiffies);
  280. }
  281. } else {
  282. unsigned long increment = nlmsvc_timeout;
  283. struct rpc_timeout timeparms = {
  284. .to_initval = increment,
  285. .to_increment = increment,
  286. .to_maxval = increment * 6UL,
  287. .to_retries = 5U,
  288. };
  289. struct rpc_create_args args = {
  290. .protocol = host->h_proto,
  291. .address = nlm_addr(host),
  292. .addrsize = host->h_addrlen,
  293. .saddress = nlm_srcaddr(host),
  294. .timeout = &timeparms,
  295. .servername = host->h_name,
  296. .program = &nlm_program,
  297. .version = host->h_version,
  298. .authflavor = RPC_AUTH_UNIX,
  299. .flags = (RPC_CLNT_CREATE_NOPING |
  300. RPC_CLNT_CREATE_AUTOBIND),
  301. };
  302. /*
  303. * lockd retries server side blocks automatically so we want
  304. * those to be soft RPC calls. Client side calls need to be
  305. * hard RPC tasks.
  306. */
  307. if (!host->h_server)
  308. args.flags |= RPC_CLNT_CREATE_HARDRTRY;
  309. clnt = rpc_create(&args);
  310. if (!IS_ERR(clnt))
  311. host->h_rpcclnt = clnt;
  312. else {
  313. printk("lockd: couldn't create RPC handle for %s\n", host->h_name);
  314. clnt = NULL;
  315. }
  316. }
  317. mutex_unlock(&host->h_mutex);
  318. return clnt;
  319. }
  320. /*
  321. * Force a portmap lookup of the remote lockd port
  322. */
  323. void
  324. nlm_rebind_host(struct nlm_host *host)
  325. {
  326. dprintk("lockd: rebind host %s\n", host->h_name);
  327. if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) {
  328. rpc_force_rebind(host->h_rpcclnt);
  329. host->h_nextrebind = jiffies + NLM_HOST_REBIND;
  330. }
  331. }
  332. /*
  333. * Increment NLM host count
  334. */
  335. struct nlm_host * nlm_get_host(struct nlm_host *host)
  336. {
  337. if (host) {
  338. dprintk("lockd: get host %s\n", host->h_name);
  339. atomic_inc(&host->h_count);
  340. host->h_expires = jiffies + NLM_HOST_EXPIRE;
  341. }
  342. return host;
  343. }
  344. /*
  345. * Release NLM host after use
  346. */
  347. void nlm_release_host(struct nlm_host *host)
  348. {
  349. if (host != NULL) {
  350. dprintk("lockd: release host %s\n", host->h_name);
  351. BUG_ON(atomic_read(&host->h_count) < 0);
  352. if (atomic_dec_and_test(&host->h_count)) {
  353. BUG_ON(!list_empty(&host->h_lockowners));
  354. BUG_ON(!list_empty(&host->h_granted));
  355. BUG_ON(!list_empty(&host->h_reclaim));
  356. }
  357. }
  358. }
  359. /*
  360. * We were notified that the host indicated by address &sin
  361. * has rebooted.
  362. * Release all resources held by that peer.
  363. */
  364. void nlm_host_rebooted(const struct sockaddr_in *sin,
  365. const char *hostname,
  366. unsigned int hostname_len,
  367. u32 new_state)
  368. {
  369. struct hlist_head *chain;
  370. struct hlist_node *pos;
  371. struct nsm_handle *nsm;
  372. struct nlm_host *host;
  373. /* Find the NSM handle for this peer */
  374. nsm = __nsm_find(sin, hostname, hostname_len, 0);
  375. if (nsm == NULL) {
  376. dprintk("lockd: never saw rebooted peer '%.*s' before\n",
  377. hostname_len, hostname);
  378. return;
  379. }
  380. dprintk("lockd: nlm_host_rebooted(%.*s, %s)\n",
  381. hostname_len, hostname, nsm->sm_addrbuf);
  382. /* When reclaiming locks on this peer, make sure that
  383. * we set up a new notification */
  384. nsm->sm_monitored = 0;
  385. /* Mark all hosts tied to this NSM state as having rebooted.
  386. * We run the loop repeatedly, because we drop the host table
  387. * lock for this.
  388. * To avoid processing a host several times, we match the nsmstate.
  389. */
  390. again: mutex_lock(&nlm_host_mutex);
  391. for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) {
  392. hlist_for_each_entry(host, pos, chain, h_hash) {
  393. if (host->h_nsmhandle == nsm
  394. && host->h_nsmstate != new_state) {
  395. host->h_nsmstate = new_state;
  396. host->h_state++;
  397. nlm_get_host(host);
  398. mutex_unlock(&nlm_host_mutex);
  399. if (host->h_server) {
  400. /* We're server for this guy, just ditch
  401. * all the locks he held. */
  402. nlmsvc_free_host_resources(host);
  403. } else {
  404. /* He's the server, initiate lock recovery. */
  405. nlmclnt_recovery(host);
  406. }
  407. nlm_release_host(host);
  408. goto again;
  409. }
  410. }
  411. }
  412. mutex_unlock(&nlm_host_mutex);
  413. }
  414. /*
  415. * Shut down the hosts module.
  416. * Note that this routine is called only at server shutdown time.
  417. */
  418. void
  419. nlm_shutdown_hosts(void)
  420. {
  421. struct hlist_head *chain;
  422. struct hlist_node *pos;
  423. struct nlm_host *host;
  424. dprintk("lockd: shutting down host module\n");
  425. mutex_lock(&nlm_host_mutex);
  426. /* First, make all hosts eligible for gc */
  427. dprintk("lockd: nuking all hosts...\n");
  428. for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) {
  429. hlist_for_each_entry(host, pos, chain, h_hash) {
  430. host->h_expires = jiffies - 1;
  431. if (host->h_rpcclnt) {
  432. rpc_shutdown_client(host->h_rpcclnt);
  433. host->h_rpcclnt = NULL;
  434. }
  435. }
  436. }
  437. /* Then, perform a garbage collection pass */
  438. nlm_gc_hosts();
  439. mutex_unlock(&nlm_host_mutex);
  440. /* complain if any hosts are left */
  441. if (nrhosts) {
  442. printk(KERN_WARNING "lockd: couldn't shutdown host module!\n");
  443. dprintk("lockd: %d hosts left:\n", nrhosts);
  444. for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) {
  445. hlist_for_each_entry(host, pos, chain, h_hash) {
  446. dprintk(" %s (cnt %d use %d exp %ld)\n",
  447. host->h_name, atomic_read(&host->h_count),
  448. host->h_inuse, host->h_expires);
  449. }
  450. }
  451. }
  452. }
  453. /*
  454. * Garbage collect any unused NLM hosts.
  455. * This GC combines reference counting for async operations with
  456. * mark & sweep for resources held by remote clients.
  457. */
  458. static void
  459. nlm_gc_hosts(void)
  460. {
  461. struct hlist_head *chain;
  462. struct hlist_node *pos, *next;
  463. struct nlm_host *host;
  464. dprintk("lockd: host garbage collection\n");
  465. for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) {
  466. hlist_for_each_entry(host, pos, chain, h_hash)
  467. host->h_inuse = 0;
  468. }
  469. /* Mark all hosts that hold locks, blocks or shares */
  470. nlmsvc_mark_resources();
  471. for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) {
  472. hlist_for_each_entry_safe(host, pos, next, chain, h_hash) {
  473. if (atomic_read(&host->h_count) || host->h_inuse
  474. || time_before(jiffies, host->h_expires)) {
  475. dprintk("nlm_gc_hosts skipping %s (cnt %d use %d exp %ld)\n",
  476. host->h_name, atomic_read(&host->h_count),
  477. host->h_inuse, host->h_expires);
  478. continue;
  479. }
  480. dprintk("lockd: delete host %s\n", host->h_name);
  481. hlist_del_init(&host->h_hash);
  482. nlm_destroy_host(host);
  483. nrhosts--;
  484. }
  485. }
  486. next_gc = jiffies + NLM_HOST_COLLECT;
  487. }
  488. /*
  489. * Manage NSM handles
  490. */
  491. static LIST_HEAD(nsm_handles);
  492. static DEFINE_SPINLOCK(nsm_lock);
  493. static struct nsm_handle *
  494. __nsm_find(const struct sockaddr_in *sin,
  495. const char *hostname, unsigned int hostname_len,
  496. int create)
  497. {
  498. struct nsm_handle *nsm = NULL;
  499. struct nsm_handle *pos;
  500. if (!sin)
  501. return NULL;
  502. if (hostname && memchr(hostname, '/', hostname_len) != NULL) {
  503. if (printk_ratelimit()) {
  504. printk(KERN_WARNING "Invalid hostname \"%.*s\" "
  505. "in NFS lock request\n",
  506. hostname_len, hostname);
  507. }
  508. return NULL;
  509. }
  510. retry:
  511. spin_lock(&nsm_lock);
  512. list_for_each_entry(pos, &nsm_handles, sm_link) {
  513. if (hostname && nsm_use_hostnames) {
  514. if (strlen(pos->sm_name) != hostname_len
  515. || memcmp(pos->sm_name, hostname, hostname_len))
  516. continue;
  517. } else if (!nlm_cmp_addr(nsm_addr(pos), (struct sockaddr *)sin))
  518. continue;
  519. atomic_inc(&pos->sm_count);
  520. kfree(nsm);
  521. nsm = pos;
  522. goto found;
  523. }
  524. if (nsm) {
  525. list_add(&nsm->sm_link, &nsm_handles);
  526. goto found;
  527. }
  528. spin_unlock(&nsm_lock);
  529. if (!create)
  530. return NULL;
  531. nsm = kzalloc(sizeof(*nsm) + hostname_len + 1, GFP_KERNEL);
  532. if (nsm == NULL)
  533. return NULL;
  534. memcpy(nsm_addr(nsm), sin, sizeof(*sin));
  535. nsm->sm_addrlen = sizeof(*sin);
  536. nsm->sm_name = (char *) (nsm + 1);
  537. memcpy(nsm->sm_name, hostname, hostname_len);
  538. nsm->sm_name[hostname_len] = '\0';
  539. nlm_display_address((struct sockaddr *)&nsm->sm_addr,
  540. nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
  541. atomic_set(&nsm->sm_count, 1);
  542. goto retry;
  543. found:
  544. spin_unlock(&nsm_lock);
  545. return nsm;
  546. }
  547. static struct nsm_handle *
  548. nsm_find(const struct sockaddr_in *sin, const char *hostname,
  549. unsigned int hostname_len)
  550. {
  551. return __nsm_find(sin, hostname, hostname_len, 1);
  552. }
  553. /*
  554. * Release an NSM handle
  555. */
  556. void
  557. nsm_release(struct nsm_handle *nsm)
  558. {
  559. if (!nsm)
  560. return;
  561. if (atomic_dec_and_lock(&nsm->sm_count, &nsm_lock)) {
  562. list_del(&nsm->sm_link);
  563. spin_unlock(&nsm_lock);
  564. kfree(nsm);
  565. }
  566. }