export.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. #define MSNFS /* HACK HACK */
  2. /*
  3. * linux/fs/nfsd/export.c
  4. *
  5. * NFS exporting and validation.
  6. *
  7. * We maintain a list of clients, each of which has a list of
  8. * exports. To export an fs to a given client, you first have
  9. * to create the client entry with NFSCTL_ADDCLIENT, which
  10. * creates a client control block and adds it to the hash
  11. * table. Then, you call NFSCTL_EXPORT for each fs.
  12. *
  13. *
  14. * Copyright (C) 1995, 1996 Olaf Kirch, <okir@monad.swb.de>
  15. */
  16. #include <linux/unistd.h>
  17. #include <linux/slab.h>
  18. #include <linux/sched.h>
  19. #include <linux/stat.h>
  20. #include <linux/in.h>
  21. #include <linux/seq_file.h>
  22. #include <linux/syscalls.h>
  23. #include <linux/rwsem.h>
  24. #include <linux/dcache.h>
  25. #include <linux/namei.h>
  26. #include <linux/mount.h>
  27. #include <linux/hash.h>
  28. #include <linux/module.h>
  29. #include <linux/sunrpc/svc.h>
  30. #include <linux/nfsd/nfsd.h>
  31. #include <linux/nfsd/nfsfh.h>
  32. #include <linux/nfsd/syscall.h>
  33. #include <linux/lockd/bind.h>
  34. #define NFSDDBG_FACILITY NFSDDBG_EXPORT
  35. #define NFSD_PARANOIA 1
  36. typedef struct auth_domain svc_client;
  37. typedef struct svc_export svc_export;
  38. static void exp_do_unexport(svc_export *unexp);
  39. static int exp_verify_string(char *cp, int max);
  40. /*
  41. * We have two caches.
  42. * One maps client+vfsmnt+dentry to export options - the export map
  43. * The other maps client+filehandle-fragment to export options. - the expkey map
  44. *
  45. * The export options are actually stored in the first map, and the
  46. * second map contains a reference to the entry in the first map.
  47. */
  48. #define EXPKEY_HASHBITS 8
  49. #define EXPKEY_HASHMAX (1 << EXPKEY_HASHBITS)
  50. #define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1)
  51. static struct cache_head *expkey_table[EXPKEY_HASHMAX];
  52. void expkey_put(struct cache_head *item, struct cache_detail *cd)
  53. {
  54. if (cache_put(item, cd)) {
  55. struct svc_expkey *key = container_of(item, struct svc_expkey, h);
  56. if (test_bit(CACHE_VALID, &item->flags) &&
  57. !test_bit(CACHE_NEGATIVE, &item->flags)) {
  58. dput(key->ek_dentry);
  59. mntput(key->ek_mnt);
  60. }
  61. auth_domain_put(key->ek_client);
  62. kfree(key);
  63. }
  64. }
  65. static void expkey_request(struct cache_detail *cd,
  66. struct cache_head *h,
  67. char **bpp, int *blen)
  68. {
  69. /* client fsidtype \xfsid */
  70. struct svc_expkey *ek = container_of(h, struct svc_expkey, h);
  71. char type[5];
  72. qword_add(bpp, blen, ek->ek_client->name);
  73. snprintf(type, 5, "%d", ek->ek_fsidtype);
  74. qword_add(bpp, blen, type);
  75. qword_addhex(bpp, blen, (char*)ek->ek_fsid, key_len(ek->ek_fsidtype));
  76. (*bpp)[-1] = '\n';
  77. }
  78. static struct svc_expkey *svc_expkey_update(struct svc_expkey *new, struct svc_expkey *old);
  79. static struct svc_expkey *svc_expkey_lookup(struct svc_expkey *);
  80. static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
  81. {
  82. /* client fsidtype fsid [path] */
  83. char *buf;
  84. int len;
  85. struct auth_domain *dom = NULL;
  86. int err;
  87. int fsidtype;
  88. char *ep;
  89. struct svc_expkey key;
  90. struct svc_expkey *ek;
  91. if (mesg[mlen-1] != '\n')
  92. return -EINVAL;
  93. mesg[mlen-1] = 0;
  94. buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
  95. err = -ENOMEM;
  96. if (!buf) goto out;
  97. err = -EINVAL;
  98. if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
  99. goto out;
  100. err = -ENOENT;
  101. dom = auth_domain_find(buf);
  102. if (!dom)
  103. goto out;
  104. dprintk("found domain %s\n", buf);
  105. err = -EINVAL;
  106. if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
  107. goto out;
  108. fsidtype = simple_strtoul(buf, &ep, 10);
  109. if (*ep)
  110. goto out;
  111. dprintk("found fsidtype %d\n", fsidtype);
  112. if (fsidtype > 2)
  113. goto out;
  114. if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
  115. goto out;
  116. dprintk("found fsid length %d\n", len);
  117. if (len != key_len(fsidtype))
  118. goto out;
  119. /* OK, we seem to have a valid key */
  120. key.h.flags = 0;
  121. key.h.expiry_time = get_expiry(&mesg);
  122. if (key.h.expiry_time == 0)
  123. goto out;
  124. key.ek_client = dom;
  125. key.ek_fsidtype = fsidtype;
  126. memcpy(key.ek_fsid, buf, len);
  127. ek = svc_expkey_lookup(&key);
  128. err = -ENOMEM;
  129. if (!ek)
  130. goto out;
  131. /* now we want a pathname, or empty meaning NEGATIVE */
  132. err = -EINVAL;
  133. if ((len=qword_get(&mesg, buf, PAGE_SIZE)) < 0)
  134. goto out;
  135. dprintk("Path seems to be <%s>\n", buf);
  136. err = 0;
  137. if (len == 0) {
  138. set_bit(CACHE_NEGATIVE, &key.h.flags);
  139. ek = svc_expkey_update(&key, ek);
  140. if (ek)
  141. expkey_put(&ek->h, &svc_expkey_cache);
  142. else err = -ENOMEM;
  143. } else {
  144. struct nameidata nd;
  145. err = path_lookup(buf, 0, &nd);
  146. if (err)
  147. goto out;
  148. dprintk("Found the path %s\n", buf);
  149. key.ek_mnt = nd.mnt;
  150. key.ek_dentry = nd.dentry;
  151. ek = svc_expkey_update(&key, ek);
  152. if (ek)
  153. expkey_put(&ek->h, &svc_expkey_cache);
  154. else
  155. err = -ENOMEM;
  156. path_release(&nd);
  157. }
  158. cache_flush();
  159. out:
  160. if (dom)
  161. auth_domain_put(dom);
  162. kfree(buf);
  163. return err;
  164. }
  165. static int expkey_show(struct seq_file *m,
  166. struct cache_detail *cd,
  167. struct cache_head *h)
  168. {
  169. struct svc_expkey *ek ;
  170. if (h ==NULL) {
  171. seq_puts(m, "#domain fsidtype fsid [path]\n");
  172. return 0;
  173. }
  174. ek = container_of(h, struct svc_expkey, h);
  175. seq_printf(m, "%s %d 0x%08x", ek->ek_client->name,
  176. ek->ek_fsidtype, ek->ek_fsid[0]);
  177. if (ek->ek_fsidtype != 1)
  178. seq_printf(m, "%08x", ek->ek_fsid[1]);
  179. if (ek->ek_fsidtype == 2)
  180. seq_printf(m, "%08x", ek->ek_fsid[2]);
  181. if (test_bit(CACHE_VALID, &h->flags) &&
  182. !test_bit(CACHE_NEGATIVE, &h->flags)) {
  183. seq_printf(m, " ");
  184. seq_path(m, ek->ek_mnt, ek->ek_dentry, "\\ \t\n");
  185. }
  186. seq_printf(m, "\n");
  187. return 0;
  188. }
  189. static inline int expkey_match (struct cache_head *a, struct cache_head *b)
  190. {
  191. struct svc_expkey *orig = container_of(a, struct svc_expkey, h);
  192. struct svc_expkey *new = container_of(b, struct svc_expkey, h);
  193. if (orig->ek_fsidtype != new->ek_fsidtype ||
  194. orig->ek_client != new->ek_client ||
  195. memcmp(orig->ek_fsid, new->ek_fsid, key_len(orig->ek_fsidtype)) != 0)
  196. return 0;
  197. return 1;
  198. }
  199. static inline void expkey_init(struct cache_head *cnew,
  200. struct cache_head *citem)
  201. {
  202. struct svc_expkey *new = container_of(cnew, struct svc_expkey, h);
  203. struct svc_expkey *item = container_of(citem, struct svc_expkey, h);
  204. kref_get(&item->ek_client->ref);
  205. new->ek_client = item->ek_client;
  206. new->ek_fsidtype = item->ek_fsidtype;
  207. new->ek_fsid[0] = item->ek_fsid[0];
  208. new->ek_fsid[1] = item->ek_fsid[1];
  209. new->ek_fsid[2] = item->ek_fsid[2];
  210. }
  211. static inline void expkey_update(struct cache_head *cnew,
  212. struct cache_head *citem)
  213. {
  214. struct svc_expkey *new = container_of(cnew, struct svc_expkey, h);
  215. struct svc_expkey *item = container_of(citem, struct svc_expkey, h);
  216. new->ek_mnt = mntget(item->ek_mnt);
  217. new->ek_dentry = dget(item->ek_dentry);
  218. }
  219. static struct cache_head *expkey_alloc(void)
  220. {
  221. struct svc_expkey *i = kmalloc(sizeof(*i), GFP_KERNEL);
  222. if (i)
  223. return &i->h;
  224. else
  225. return NULL;
  226. }
  227. struct cache_detail svc_expkey_cache = {
  228. .owner = THIS_MODULE,
  229. .hash_size = EXPKEY_HASHMAX,
  230. .hash_table = expkey_table,
  231. .name = "nfsd.fh",
  232. .cache_put = expkey_put,
  233. .cache_request = expkey_request,
  234. .cache_parse = expkey_parse,
  235. .cache_show = expkey_show,
  236. .match = expkey_match,
  237. .init = expkey_init,
  238. .update = expkey_update,
  239. .alloc = expkey_alloc,
  240. };
  241. static struct svc_expkey *
  242. svc_expkey_lookup(struct svc_expkey *item)
  243. {
  244. struct cache_head *ch;
  245. int hash = item->ek_fsidtype;
  246. char * cp = (char*)item->ek_fsid;
  247. int len = key_len(item->ek_fsidtype);
  248. hash ^= hash_mem(cp, len, EXPKEY_HASHBITS);
  249. hash ^= hash_ptr(item->ek_client, EXPKEY_HASHBITS);
  250. hash &= EXPKEY_HASHMASK;
  251. ch = sunrpc_cache_lookup(&svc_expkey_cache, &item->h,
  252. hash);
  253. if (ch)
  254. return container_of(ch, struct svc_expkey, h);
  255. else
  256. return NULL;
  257. }
  258. static struct svc_expkey *
  259. svc_expkey_update(struct svc_expkey *new, struct svc_expkey *old)
  260. {
  261. struct cache_head *ch;
  262. int hash = new->ek_fsidtype;
  263. char * cp = (char*)new->ek_fsid;
  264. int len = key_len(new->ek_fsidtype);
  265. hash ^= hash_mem(cp, len, EXPKEY_HASHBITS);
  266. hash ^= hash_ptr(new->ek_client, EXPKEY_HASHBITS);
  267. hash &= EXPKEY_HASHMASK;
  268. ch = sunrpc_cache_update(&svc_expkey_cache, &new->h,
  269. &old->h, hash);
  270. if (ch)
  271. return container_of(ch, struct svc_expkey, h);
  272. else
  273. return NULL;
  274. }
  275. #define EXPORT_HASHBITS 8
  276. #define EXPORT_HASHMAX (1<< EXPORT_HASHBITS)
  277. #define EXPORT_HASHMASK (EXPORT_HASHMAX -1)
  278. static struct cache_head *export_table[EXPORT_HASHMAX];
  279. void svc_export_put(struct cache_head *item, struct cache_detail *cd)
  280. {
  281. if (cache_put(item, cd)) {
  282. struct svc_export *exp = container_of(item, struct svc_export, h);
  283. dput(exp->ex_dentry);
  284. mntput(exp->ex_mnt);
  285. auth_domain_put(exp->ex_client);
  286. kfree(exp);
  287. }
  288. }
  289. static void svc_export_request(struct cache_detail *cd,
  290. struct cache_head *h,
  291. char **bpp, int *blen)
  292. {
  293. /* client path */
  294. struct svc_export *exp = container_of(h, struct svc_export, h);
  295. char *pth;
  296. qword_add(bpp, blen, exp->ex_client->name);
  297. pth = d_path(exp->ex_dentry, exp->ex_mnt, *bpp, *blen);
  298. if (IS_ERR(pth)) {
  299. /* is this correct? */
  300. (*bpp)[0] = '\n';
  301. return;
  302. }
  303. qword_add(bpp, blen, pth);
  304. (*bpp)[-1] = '\n';
  305. }
  306. struct svc_export *svc_export_update(struct svc_export *new, struct svc_export *old);
  307. static struct svc_export *svc_export_lookup(struct svc_export *);
  308. static int check_export(struct inode *inode, int flags)
  309. {
  310. /* We currently export only dirs and regular files.
  311. * This is what umountd does.
  312. */
  313. if (!S_ISDIR(inode->i_mode) &&
  314. !S_ISREG(inode->i_mode))
  315. return -ENOTDIR;
  316. /* There are two requirements on a filesystem to be exportable.
  317. * 1: We must be able to identify the filesystem from a number.
  318. * either a device number (so FS_REQUIRES_DEV needed)
  319. * or an FSID number (so NFSEXP_FSID needed).
  320. * 2: We must be able to find an inode from a filehandle.
  321. * This means that s_export_op must be set.
  322. */
  323. if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) &&
  324. !(flags & NFSEXP_FSID)) {
  325. dprintk("exp_export: export of non-dev fs without fsid");
  326. return -EINVAL;
  327. }
  328. if (!inode->i_sb->s_export_op) {
  329. dprintk("exp_export: export of invalid fs type.\n");
  330. return -EINVAL;
  331. }
  332. /* Ok, we can export it */;
  333. if (!inode->i_sb->s_export_op->find_exported_dentry)
  334. inode->i_sb->s_export_op->find_exported_dentry =
  335. find_exported_dentry;
  336. return 0;
  337. }
  338. static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
  339. {
  340. /* client path expiry [flags anonuid anongid fsid] */
  341. char *buf;
  342. int len;
  343. int err;
  344. struct auth_domain *dom = NULL;
  345. struct nameidata nd;
  346. struct svc_export exp, *expp;
  347. int an_int;
  348. nd.dentry = NULL;
  349. if (mesg[mlen-1] != '\n')
  350. return -EINVAL;
  351. mesg[mlen-1] = 0;
  352. buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
  353. err = -ENOMEM;
  354. if (!buf) goto out;
  355. /* client */
  356. len = qword_get(&mesg, buf, PAGE_SIZE);
  357. err = -EINVAL;
  358. if (len <= 0) goto out;
  359. err = -ENOENT;
  360. dom = auth_domain_find(buf);
  361. if (!dom)
  362. goto out;
  363. /* path */
  364. err = -EINVAL;
  365. if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
  366. goto out;
  367. err = path_lookup(buf, 0, &nd);
  368. if (err) goto out;
  369. exp.h.flags = 0;
  370. exp.ex_client = dom;
  371. exp.ex_mnt = nd.mnt;
  372. exp.ex_dentry = nd.dentry;
  373. /* expiry */
  374. err = -EINVAL;
  375. exp.h.expiry_time = get_expiry(&mesg);
  376. if (exp.h.expiry_time == 0)
  377. goto out;
  378. /* flags */
  379. err = get_int(&mesg, &an_int);
  380. if (err == -ENOENT)
  381. set_bit(CACHE_NEGATIVE, &exp.h.flags);
  382. else {
  383. if (err || an_int < 0) goto out;
  384. exp.ex_flags= an_int;
  385. /* anon uid */
  386. err = get_int(&mesg, &an_int);
  387. if (err) goto out;
  388. exp.ex_anon_uid= an_int;
  389. /* anon gid */
  390. err = get_int(&mesg, &an_int);
  391. if (err) goto out;
  392. exp.ex_anon_gid= an_int;
  393. /* fsid */
  394. err = get_int(&mesg, &an_int);
  395. if (err) goto out;
  396. exp.ex_fsid = an_int;
  397. err = check_export(nd.dentry->d_inode, exp.ex_flags);
  398. if (err) goto out;
  399. }
  400. expp = svc_export_lookup(&exp);
  401. if (expp)
  402. expp = svc_export_update(&exp, expp);
  403. else
  404. err = -ENOMEM;
  405. cache_flush();
  406. if (expp == NULL)
  407. err = -ENOMEM;
  408. else
  409. exp_put(expp);
  410. out:
  411. if (nd.dentry)
  412. path_release(&nd);
  413. if (dom)
  414. auth_domain_put(dom);
  415. kfree(buf);
  416. return err;
  417. }
  418. static void exp_flags(struct seq_file *m, int flag, int fsid, uid_t anonu, uid_t anong);
  419. static int svc_export_show(struct seq_file *m,
  420. struct cache_detail *cd,
  421. struct cache_head *h)
  422. {
  423. struct svc_export *exp ;
  424. if (h ==NULL) {
  425. seq_puts(m, "#path domain(flags)\n");
  426. return 0;
  427. }
  428. exp = container_of(h, struct svc_export, h);
  429. seq_path(m, exp->ex_mnt, exp->ex_dentry, " \t\n\\");
  430. seq_putc(m, '\t');
  431. seq_escape(m, exp->ex_client->name, " \t\n\\");
  432. seq_putc(m, '(');
  433. if (test_bit(CACHE_VALID, &h->flags) &&
  434. !test_bit(CACHE_NEGATIVE, &h->flags))
  435. exp_flags(m, exp->ex_flags, exp->ex_fsid,
  436. exp->ex_anon_uid, exp->ex_anon_gid);
  437. seq_puts(m, ")\n");
  438. return 0;
  439. }
  440. static int svc_export_match(struct cache_head *a, struct cache_head *b)
  441. {
  442. struct svc_export *orig = container_of(a, struct svc_export, h);
  443. struct svc_export *new = container_of(b, struct svc_export, h);
  444. return orig->ex_client == new->ex_client &&
  445. orig->ex_dentry == new->ex_dentry &&
  446. orig->ex_mnt == new->ex_mnt;
  447. }
  448. static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
  449. {
  450. struct svc_export *new = container_of(cnew, struct svc_export, h);
  451. struct svc_export *item = container_of(citem, struct svc_export, h);
  452. kref_get(&item->ex_client->ref);
  453. new->ex_client = item->ex_client;
  454. new->ex_dentry = dget(item->ex_dentry);
  455. new->ex_mnt = mntget(item->ex_mnt);
  456. }
  457. static void export_update(struct cache_head *cnew, struct cache_head *citem)
  458. {
  459. struct svc_export *new = container_of(cnew, struct svc_export, h);
  460. struct svc_export *item = container_of(citem, struct svc_export, h);
  461. new->ex_flags = item->ex_flags;
  462. new->ex_anon_uid = item->ex_anon_uid;
  463. new->ex_anon_gid = item->ex_anon_gid;
  464. new->ex_fsid = item->ex_fsid;
  465. }
  466. static struct cache_head *svc_export_alloc(void)
  467. {
  468. struct svc_export *i = kmalloc(sizeof(*i), GFP_KERNEL);
  469. if (i)
  470. return &i->h;
  471. else
  472. return NULL;
  473. }
  474. struct cache_detail svc_export_cache = {
  475. .owner = THIS_MODULE,
  476. .hash_size = EXPORT_HASHMAX,
  477. .hash_table = export_table,
  478. .name = "nfsd.export",
  479. .cache_put = svc_export_put,
  480. .cache_request = svc_export_request,
  481. .cache_parse = svc_export_parse,
  482. .cache_show = svc_export_show,
  483. .match = svc_export_match,
  484. .init = svc_export_init,
  485. .update = export_update,
  486. .alloc = svc_export_alloc,
  487. };
  488. static struct svc_export *
  489. svc_export_lookup(struct svc_export *exp)
  490. {
  491. struct cache_head *ch;
  492. int hash;
  493. hash = hash_ptr(exp->ex_client, EXPORT_HASHBITS);
  494. hash ^= hash_ptr(exp->ex_dentry, EXPORT_HASHBITS);
  495. hash ^= hash_ptr(exp->ex_mnt, EXPORT_HASHBITS);
  496. ch = sunrpc_cache_lookup(&svc_export_cache, &exp->h,
  497. hash);
  498. if (ch)
  499. return container_of(ch, struct svc_export, h);
  500. else
  501. return NULL;
  502. }
  503. struct svc_export *
  504. svc_export_update(struct svc_export *new, struct svc_export *old)
  505. {
  506. struct cache_head *ch;
  507. int hash;
  508. hash = hash_ptr(old->ex_client, EXPORT_HASHBITS);
  509. hash ^= hash_ptr(old->ex_dentry, EXPORT_HASHBITS);
  510. hash ^= hash_ptr(old->ex_mnt, EXPORT_HASHBITS);
  511. ch = sunrpc_cache_update(&svc_export_cache, &new->h,
  512. &old->h,
  513. hash);
  514. if (ch)
  515. return container_of(ch, struct svc_export, h);
  516. else
  517. return NULL;
  518. }
  519. struct svc_expkey *
  520. exp_find_key(svc_client *clp, int fsid_type, u32 *fsidv, struct cache_req *reqp)
  521. {
  522. struct svc_expkey key, *ek;
  523. int err;
  524. if (!clp)
  525. return NULL;
  526. key.ek_client = clp;
  527. key.ek_fsidtype = fsid_type;
  528. memcpy(key.ek_fsid, fsidv, key_len(fsid_type));
  529. ek = svc_expkey_lookup(&key);
  530. if (ek != NULL)
  531. if ((err = cache_check(&svc_expkey_cache, &ek->h, reqp)))
  532. ek = ERR_PTR(err);
  533. return ek;
  534. }
  535. static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv,
  536. struct svc_export *exp)
  537. {
  538. struct svc_expkey key, *ek;
  539. key.ek_client = clp;
  540. key.ek_fsidtype = fsid_type;
  541. memcpy(key.ek_fsid, fsidv, key_len(fsid_type));
  542. key.ek_mnt = exp->ex_mnt;
  543. key.ek_dentry = exp->ex_dentry;
  544. key.h.expiry_time = NEVER;
  545. key.h.flags = 0;
  546. ek = svc_expkey_lookup(&key);
  547. if (ek)
  548. ek = svc_expkey_update(&key,ek);
  549. if (ek) {
  550. expkey_put(&ek->h, &svc_expkey_cache);
  551. return 0;
  552. }
  553. return -ENOMEM;
  554. }
  555. /*
  556. * Find the client's export entry matching xdev/xino.
  557. */
  558. static inline struct svc_expkey *
  559. exp_get_key(svc_client *clp, dev_t dev, ino_t ino)
  560. {
  561. u32 fsidv[3];
  562. if (old_valid_dev(dev)) {
  563. mk_fsid_v0(fsidv, dev, ino);
  564. return exp_find_key(clp, 0, fsidv, NULL);
  565. }
  566. mk_fsid_v3(fsidv, dev, ino);
  567. return exp_find_key(clp, 3, fsidv, NULL);
  568. }
  569. /*
  570. * Find the client's export entry matching fsid
  571. */
  572. static inline struct svc_expkey *
  573. exp_get_fsid_key(svc_client *clp, int fsid)
  574. {
  575. u32 fsidv[2];
  576. mk_fsid_v1(fsidv, fsid);
  577. return exp_find_key(clp, 1, fsidv, NULL);
  578. }
  579. svc_export *
  580. exp_get_by_name(svc_client *clp, struct vfsmount *mnt, struct dentry *dentry,
  581. struct cache_req *reqp)
  582. {
  583. struct svc_export *exp, key;
  584. if (!clp)
  585. return NULL;
  586. key.ex_client = clp;
  587. key.ex_mnt = mnt;
  588. key.ex_dentry = dentry;
  589. exp = svc_export_lookup(&key);
  590. if (exp != NULL)
  591. switch (cache_check(&svc_export_cache, &exp->h, reqp)) {
  592. case 0: break;
  593. case -EAGAIN:
  594. exp = ERR_PTR(-EAGAIN);
  595. break;
  596. default:
  597. exp = NULL;
  598. }
  599. return exp;
  600. }
  601. /*
  602. * Find the export entry for a given dentry.
  603. */
  604. struct svc_export *
  605. exp_parent(svc_client *clp, struct vfsmount *mnt, struct dentry *dentry,
  606. struct cache_req *reqp)
  607. {
  608. svc_export *exp;
  609. dget(dentry);
  610. exp = exp_get_by_name(clp, mnt, dentry, reqp);
  611. while (exp == NULL && !IS_ROOT(dentry)) {
  612. struct dentry *parent;
  613. parent = dget_parent(dentry);
  614. dput(dentry);
  615. dentry = parent;
  616. exp = exp_get_by_name(clp, mnt, dentry, reqp);
  617. }
  618. dput(dentry);
  619. return exp;
  620. }
  621. /*
  622. * Hashtable locking. Write locks are placed only by user processes
  623. * wanting to modify export information.
  624. * Write locking only done in this file. Read locking
  625. * needed externally.
  626. */
  627. static DECLARE_RWSEM(hash_sem);
  628. void
  629. exp_readlock(void)
  630. {
  631. down_read(&hash_sem);
  632. }
  633. static inline void
  634. exp_writelock(void)
  635. {
  636. down_write(&hash_sem);
  637. }
  638. void
  639. exp_readunlock(void)
  640. {
  641. up_read(&hash_sem);
  642. }
  643. static inline void
  644. exp_writeunlock(void)
  645. {
  646. up_write(&hash_sem);
  647. }
  648. static void exp_fsid_unhash(struct svc_export *exp)
  649. {
  650. struct svc_expkey *ek;
  651. if ((exp->ex_flags & NFSEXP_FSID) == 0)
  652. return;
  653. ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid);
  654. if (ek && !IS_ERR(ek)) {
  655. ek->h.expiry_time = get_seconds()-1;
  656. expkey_put(&ek->h, &svc_expkey_cache);
  657. }
  658. svc_expkey_cache.nextcheck = get_seconds();
  659. }
  660. static int exp_fsid_hash(svc_client *clp, struct svc_export *exp)
  661. {
  662. u32 fsid[2];
  663. if ((exp->ex_flags & NFSEXP_FSID) == 0)
  664. return 0;
  665. mk_fsid_v1(fsid, exp->ex_fsid);
  666. return exp_set_key(clp, 1, fsid, exp);
  667. }
  668. static int exp_hash(struct auth_domain *clp, struct svc_export *exp)
  669. {
  670. u32 fsid[2];
  671. struct inode *inode = exp->ex_dentry->d_inode;
  672. dev_t dev = inode->i_sb->s_dev;
  673. if (old_valid_dev(dev)) {
  674. mk_fsid_v0(fsid, dev, inode->i_ino);
  675. return exp_set_key(clp, 0, fsid, exp);
  676. }
  677. mk_fsid_v3(fsid, dev, inode->i_ino);
  678. return exp_set_key(clp, 3, fsid, exp);
  679. }
  680. static void exp_unhash(struct svc_export *exp)
  681. {
  682. struct svc_expkey *ek;
  683. struct inode *inode = exp->ex_dentry->d_inode;
  684. ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino);
  685. if (ek && !IS_ERR(ek)) {
  686. ek->h.expiry_time = get_seconds()-1;
  687. expkey_put(&ek->h, &svc_expkey_cache);
  688. }
  689. svc_expkey_cache.nextcheck = get_seconds();
  690. }
  691. /*
  692. * Export a file system.
  693. */
  694. int
  695. exp_export(struct nfsctl_export *nxp)
  696. {
  697. svc_client *clp;
  698. struct svc_export *exp = NULL;
  699. struct svc_export new;
  700. struct svc_expkey *fsid_key = NULL;
  701. struct nameidata nd;
  702. int err;
  703. /* Consistency check */
  704. err = -EINVAL;
  705. if (!exp_verify_string(nxp->ex_path, NFS_MAXPATHLEN) ||
  706. !exp_verify_string(nxp->ex_client, NFSCLNT_IDMAX))
  707. goto out;
  708. dprintk("exp_export called for %s:%s (%x/%ld fl %x).\n",
  709. nxp->ex_client, nxp->ex_path,
  710. (unsigned)nxp->ex_dev, (long)nxp->ex_ino,
  711. nxp->ex_flags);
  712. /* Try to lock the export table for update */
  713. exp_writelock();
  714. /* Look up client info */
  715. if (!(clp = auth_domain_find(nxp->ex_client)))
  716. goto out_unlock;
  717. /* Look up the dentry */
  718. err = path_lookup(nxp->ex_path, 0, &nd);
  719. if (err)
  720. goto out_unlock;
  721. err = -EINVAL;
  722. exp = exp_get_by_name(clp, nd.mnt, nd.dentry, NULL);
  723. /* must make sure there won't be an ex_fsid clash */
  724. if ((nxp->ex_flags & NFSEXP_FSID) &&
  725. (fsid_key = exp_get_fsid_key(clp, nxp->ex_dev)) &&
  726. !IS_ERR(fsid_key) &&
  727. fsid_key->ek_mnt &&
  728. (fsid_key->ek_mnt != nd.mnt || fsid_key->ek_dentry != nd.dentry) )
  729. goto finish;
  730. if (exp) {
  731. /* just a flags/id/fsid update */
  732. exp_fsid_unhash(exp);
  733. exp->ex_flags = nxp->ex_flags;
  734. exp->ex_anon_uid = nxp->ex_anon_uid;
  735. exp->ex_anon_gid = nxp->ex_anon_gid;
  736. exp->ex_fsid = nxp->ex_dev;
  737. err = exp_fsid_hash(clp, exp);
  738. goto finish;
  739. }
  740. err = check_export(nd.dentry->d_inode, nxp->ex_flags);
  741. if (err) goto finish;
  742. err = -ENOMEM;
  743. dprintk("nfsd: creating export entry %p for client %p\n", exp, clp);
  744. new.h.expiry_time = NEVER;
  745. new.h.flags = 0;
  746. new.ex_client = clp;
  747. new.ex_mnt = nd.mnt;
  748. new.ex_dentry = nd.dentry;
  749. new.ex_flags = nxp->ex_flags;
  750. new.ex_anon_uid = nxp->ex_anon_uid;
  751. new.ex_anon_gid = nxp->ex_anon_gid;
  752. new.ex_fsid = nxp->ex_dev;
  753. exp = svc_export_lookup(&new);
  754. if (exp)
  755. exp = svc_export_update(&new, exp);
  756. if (!exp)
  757. goto finish;
  758. if (exp_hash(clp, exp) ||
  759. exp_fsid_hash(clp, exp)) {
  760. /* failed to create at least one index */
  761. exp_do_unexport(exp);
  762. cache_flush();
  763. err = -ENOMEM;
  764. }
  765. finish:
  766. if (exp)
  767. exp_put(exp);
  768. if (fsid_key && !IS_ERR(fsid_key))
  769. expkey_put(&fsid_key->h, &svc_expkey_cache);
  770. if (clp)
  771. auth_domain_put(clp);
  772. path_release(&nd);
  773. out_unlock:
  774. exp_writeunlock();
  775. out:
  776. return err;
  777. }
  778. /*
  779. * Unexport a file system. The export entry has already
  780. * been removed from the client's list of exported fs's.
  781. */
  782. static void
  783. exp_do_unexport(svc_export *unexp)
  784. {
  785. unexp->h.expiry_time = get_seconds()-1;
  786. svc_export_cache.nextcheck = get_seconds();
  787. exp_unhash(unexp);
  788. exp_fsid_unhash(unexp);
  789. }
  790. /*
  791. * unexport syscall.
  792. */
  793. int
  794. exp_unexport(struct nfsctl_export *nxp)
  795. {
  796. struct auth_domain *dom;
  797. svc_export *exp;
  798. struct nameidata nd;
  799. int err;
  800. /* Consistency check */
  801. if (!exp_verify_string(nxp->ex_path, NFS_MAXPATHLEN) ||
  802. !exp_verify_string(nxp->ex_client, NFSCLNT_IDMAX))
  803. return -EINVAL;
  804. exp_writelock();
  805. err = -EINVAL;
  806. dom = auth_domain_find(nxp->ex_client);
  807. if (!dom) {
  808. dprintk("nfsd: unexport couldn't find %s\n", nxp->ex_client);
  809. goto out_unlock;
  810. }
  811. err = path_lookup(nxp->ex_path, 0, &nd);
  812. if (err)
  813. goto out_domain;
  814. err = -EINVAL;
  815. exp = exp_get_by_name(dom, nd.mnt, nd.dentry, NULL);
  816. path_release(&nd);
  817. if (!exp)
  818. goto out_domain;
  819. exp_do_unexport(exp);
  820. exp_put(exp);
  821. err = 0;
  822. out_domain:
  823. auth_domain_put(dom);
  824. cache_flush();
  825. out_unlock:
  826. exp_writeunlock();
  827. return err;
  828. }
  829. /*
  830. * Obtain the root fh on behalf of a client.
  831. * This could be done in user space, but I feel that it adds some safety
  832. * since its harder to fool a kernel module than a user space program.
  833. */
  834. int
  835. exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
  836. {
  837. struct svc_export *exp;
  838. struct nameidata nd;
  839. struct inode *inode;
  840. struct svc_fh fh;
  841. int err;
  842. err = -EPERM;
  843. /* NB: we probably ought to check that it's NUL-terminated */
  844. if (path_lookup(path, 0, &nd)) {
  845. printk("nfsd: exp_rootfh path not found %s", path);
  846. return err;
  847. }
  848. inode = nd.dentry->d_inode;
  849. dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n",
  850. path, nd.dentry, clp->name,
  851. inode->i_sb->s_id, inode->i_ino);
  852. exp = exp_parent(clp, nd.mnt, nd.dentry, NULL);
  853. if (!exp) {
  854. dprintk("nfsd: exp_rootfh export not found.\n");
  855. goto out;
  856. }
  857. /*
  858. * fh must be initialized before calling fh_compose
  859. */
  860. fh_init(&fh, maxsize);
  861. if (fh_compose(&fh, exp, nd.dentry, NULL))
  862. err = -EINVAL;
  863. else
  864. err = 0;
  865. memcpy(f, &fh.fh_handle, sizeof(struct knfsd_fh));
  866. fh_put(&fh);
  867. exp_put(exp);
  868. out:
  869. path_release(&nd);
  870. return err;
  871. }
  872. struct svc_export *
  873. exp_find(struct auth_domain *clp, int fsid_type, u32 *fsidv,
  874. struct cache_req *reqp)
  875. {
  876. struct svc_export *exp;
  877. struct svc_expkey *ek = exp_find_key(clp, fsid_type, fsidv, reqp);
  878. if (!ek || IS_ERR(ek))
  879. return ERR_PTR(PTR_ERR(ek));
  880. exp = exp_get_by_name(clp, ek->ek_mnt, ek->ek_dentry, reqp);
  881. expkey_put(&ek->h, &svc_expkey_cache);
  882. if (!exp || IS_ERR(exp))
  883. return ERR_PTR(PTR_ERR(exp));
  884. return exp;
  885. }
  886. /*
  887. * Called when we need the filehandle for the root of the pseudofs,
  888. * for a given NFSv4 client. The root is defined to be the
  889. * export point with fsid==0
  890. */
  891. int
  892. exp_pseudoroot(struct auth_domain *clp, struct svc_fh *fhp,
  893. struct cache_req *creq)
  894. {
  895. struct svc_expkey *fsid_key;
  896. struct svc_export *exp;
  897. int rv;
  898. u32 fsidv[2];
  899. mk_fsid_v1(fsidv, 0);
  900. fsid_key = exp_find_key(clp, 1, fsidv, creq);
  901. if (IS_ERR(fsid_key) && PTR_ERR(fsid_key) == -EAGAIN)
  902. return nfserr_dropit;
  903. if (!fsid_key || IS_ERR(fsid_key))
  904. return nfserr_perm;
  905. exp = exp_get_by_name(clp, fsid_key->ek_mnt, fsid_key->ek_dentry, creq);
  906. if (exp == NULL)
  907. rv = nfserr_perm;
  908. else if (IS_ERR(exp))
  909. rv = nfserrno(PTR_ERR(exp));
  910. else
  911. rv = fh_compose(fhp, exp,
  912. fsid_key->ek_dentry, NULL);
  913. expkey_put(&fsid_key->h, &svc_expkey_cache);
  914. return rv;
  915. }
  916. /* Iterator */
  917. static void *e_start(struct seq_file *m, loff_t *pos)
  918. {
  919. loff_t n = *pos;
  920. unsigned hash, export;
  921. struct cache_head *ch;
  922. exp_readlock();
  923. read_lock(&svc_export_cache.hash_lock);
  924. if (!n--)
  925. return (void *)1;
  926. hash = n >> 32;
  927. export = n & ((1LL<<32) - 1);
  928. for (ch=export_table[hash]; ch; ch=ch->next)
  929. if (!export--)
  930. return ch;
  931. n &= ~((1LL<<32) - 1);
  932. do {
  933. hash++;
  934. n += 1LL<<32;
  935. } while(hash < EXPORT_HASHMAX && export_table[hash]==NULL);
  936. if (hash >= EXPORT_HASHMAX)
  937. return NULL;
  938. *pos = n+1;
  939. return export_table[hash];
  940. }
  941. static void *e_next(struct seq_file *m, void *p, loff_t *pos)
  942. {
  943. struct cache_head *ch = p;
  944. int hash = (*pos >> 32);
  945. if (p == (void *)1)
  946. hash = 0;
  947. else if (ch->next == NULL) {
  948. hash++;
  949. *pos += 1LL<<32;
  950. } else {
  951. ++*pos;
  952. return ch->next;
  953. }
  954. *pos &= ~((1LL<<32) - 1);
  955. while (hash < EXPORT_HASHMAX && export_table[hash] == NULL) {
  956. hash++;
  957. *pos += 1LL<<32;
  958. }
  959. if (hash >= EXPORT_HASHMAX)
  960. return NULL;
  961. ++*pos;
  962. return export_table[hash];
  963. }
  964. static void e_stop(struct seq_file *m, void *p)
  965. {
  966. read_unlock(&svc_export_cache.hash_lock);
  967. exp_readunlock();
  968. }
  969. static struct flags {
  970. int flag;
  971. char *name[2];
  972. } expflags[] = {
  973. { NFSEXP_READONLY, {"ro", "rw"}},
  974. { NFSEXP_INSECURE_PORT, {"insecure", ""}},
  975. { NFSEXP_ROOTSQUASH, {"root_squash", "no_root_squash"}},
  976. { NFSEXP_ALLSQUASH, {"all_squash", ""}},
  977. { NFSEXP_ASYNC, {"async", "sync"}},
  978. { NFSEXP_GATHERED_WRITES, {"wdelay", "no_wdelay"}},
  979. { NFSEXP_NOHIDE, {"nohide", ""}},
  980. { NFSEXP_CROSSMOUNT, {"crossmnt", ""}},
  981. { NFSEXP_NOSUBTREECHECK, {"no_subtree_check", ""}},
  982. { NFSEXP_NOAUTHNLM, {"insecure_locks", ""}},
  983. #ifdef MSNFS
  984. { NFSEXP_MSNFS, {"msnfs", ""}},
  985. #endif
  986. { 0, {"", ""}}
  987. };
  988. static void exp_flags(struct seq_file *m, int flag, int fsid, uid_t anonu, uid_t anong)
  989. {
  990. int first = 0;
  991. struct flags *flg;
  992. for (flg = expflags; flg->flag; flg++) {
  993. int state = (flg->flag & flag)?0:1;
  994. if (*flg->name[state])
  995. seq_printf(m, "%s%s", first++?",":"", flg->name[state]);
  996. }
  997. if (flag & NFSEXP_FSID)
  998. seq_printf(m, "%sfsid=%d", first++?",":"", fsid);
  999. if (anonu != (uid_t)-2 && anonu != (0x10000-2))
  1000. seq_printf(m, "%sanonuid=%d", first++?",":"", anonu);
  1001. if (anong != (gid_t)-2 && anong != (0x10000-2))
  1002. seq_printf(m, "%sanongid=%d", first++?",":"", anong);
  1003. }
  1004. static int e_show(struct seq_file *m, void *p)
  1005. {
  1006. struct cache_head *cp = p;
  1007. struct svc_export *exp = container_of(cp, struct svc_export, h);
  1008. svc_client *clp;
  1009. if (p == (void *)1) {
  1010. seq_puts(m, "# Version 1.1\n");
  1011. seq_puts(m, "# Path Client(Flags) # IPs\n");
  1012. return 0;
  1013. }
  1014. clp = exp->ex_client;
  1015. cache_get(&exp->h);
  1016. if (cache_check(&svc_export_cache, &exp->h, NULL))
  1017. return 0;
  1018. if (cache_put(&exp->h, &svc_export_cache)) BUG();
  1019. return svc_export_show(m, &svc_export_cache, cp);
  1020. }
  1021. struct seq_operations nfs_exports_op = {
  1022. .start = e_start,
  1023. .next = e_next,
  1024. .stop = e_stop,
  1025. .show = e_show,
  1026. };
  1027. /*
  1028. * Add or modify a client.
  1029. * Change requests may involve the list of host addresses. The list of
  1030. * exports and possibly existing uid maps are left untouched.
  1031. */
  1032. int
  1033. exp_addclient(struct nfsctl_client *ncp)
  1034. {
  1035. struct auth_domain *dom;
  1036. int i, err;
  1037. /* First, consistency check. */
  1038. err = -EINVAL;
  1039. if (! exp_verify_string(ncp->cl_ident, NFSCLNT_IDMAX))
  1040. goto out;
  1041. if (ncp->cl_naddr > NFSCLNT_ADDRMAX)
  1042. goto out;
  1043. /* Lock the hashtable */
  1044. exp_writelock();
  1045. dom = unix_domain_find(ncp->cl_ident);
  1046. err = -ENOMEM;
  1047. if (!dom)
  1048. goto out_unlock;
  1049. /* Insert client into hashtable. */
  1050. for (i = 0; i < ncp->cl_naddr; i++)
  1051. auth_unix_add_addr(ncp->cl_addrlist[i], dom);
  1052. auth_unix_forget_old(dom);
  1053. auth_domain_put(dom);
  1054. err = 0;
  1055. out_unlock:
  1056. exp_writeunlock();
  1057. out:
  1058. return err;
  1059. }
  1060. /*
  1061. * Delete a client given an identifier.
  1062. */
  1063. int
  1064. exp_delclient(struct nfsctl_client *ncp)
  1065. {
  1066. int err;
  1067. struct auth_domain *dom;
  1068. err = -EINVAL;
  1069. if (!exp_verify_string(ncp->cl_ident, NFSCLNT_IDMAX))
  1070. goto out;
  1071. /* Lock the hashtable */
  1072. exp_writelock();
  1073. dom = auth_domain_find(ncp->cl_ident);
  1074. /* just make sure that no addresses work
  1075. * and that it will expire soon
  1076. */
  1077. if (dom) {
  1078. err = auth_unix_forget_old(dom);
  1079. auth_domain_put(dom);
  1080. }
  1081. exp_writeunlock();
  1082. out:
  1083. return err;
  1084. }
  1085. /*
  1086. * Verify that string is non-empty and does not exceed max length.
  1087. */
  1088. static int
  1089. exp_verify_string(char *cp, int max)
  1090. {
  1091. int i;
  1092. for (i = 0; i < max; i++)
  1093. if (!cp[i])
  1094. return i;
  1095. cp[i] = 0;
  1096. printk(KERN_NOTICE "nfsd: couldn't validate string %s\n", cp);
  1097. return 0;
  1098. }
  1099. /*
  1100. * Initialize the exports module.
  1101. */
  1102. void
  1103. nfsd_export_init(void)
  1104. {
  1105. dprintk("nfsd: initializing export module.\n");
  1106. cache_register(&svc_export_cache);
  1107. cache_register(&svc_expkey_cache);
  1108. }
  1109. /*
  1110. * Flush exports table - called when last nfsd thread is killed
  1111. */
  1112. void
  1113. nfsd_export_flush(void)
  1114. {
  1115. exp_writelock();
  1116. cache_purge(&svc_expkey_cache);
  1117. cache_purge(&svc_export_cache);
  1118. exp_writeunlock();
  1119. }
  1120. /*
  1121. * Shutdown the exports module.
  1122. */
  1123. void
  1124. nfsd_export_shutdown(void)
  1125. {
  1126. dprintk("nfsd: shutting down export module.\n");
  1127. exp_writelock();
  1128. if (cache_unregister(&svc_expkey_cache))
  1129. printk(KERN_ERR "nfsd: failed to unregister expkey cache\n");
  1130. if (cache_unregister(&svc_export_cache))
  1131. printk(KERN_ERR "nfsd: failed to unregister export cache\n");
  1132. svcauth_unix_purge();
  1133. exp_writeunlock();
  1134. dprintk("nfsd: export shutdown complete.\n");
  1135. }