v9fs.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. /*
  2. * linux/fs/9p/v9fs.c
  3. *
  4. * This file contains functions assisting in mapping VFS to 9P2000
  5. *
  6. * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com>
  7. * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to:
  20. * Free Software Foundation
  21. * 51 Franklin Street, Fifth Floor
  22. * Boston, MA 02111-1301 USA
  23. *
  24. */
  25. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  26. #include <linux/module.h>
  27. #include <linux/errno.h>
  28. #include <linux/fs.h>
  29. #include <linux/sched.h>
  30. #include <linux/parser.h>
  31. #include <linux/idr.h>
  32. #include <linux/slab.h>
  33. #include <net/9p/9p.h>
  34. #include <net/9p/client.h>
  35. #include <net/9p/transport.h>
  36. #include "v9fs.h"
  37. #include "v9fs_vfs.h"
  38. #include "cache.h"
  39. static DEFINE_SPINLOCK(v9fs_sessionlist_lock);
  40. static LIST_HEAD(v9fs_sessionlist);
  41. struct kmem_cache *v9fs_inode_cache;
  42. /*
  43. * Option Parsing (code inspired by NFS code)
  44. * NOTE: each transport will parse its own options
  45. */
  46. enum {
  47. /* Options that take integer arguments */
  48. Opt_debug, Opt_dfltuid, Opt_dfltgid, Opt_afid,
  49. /* String options */
  50. Opt_uname, Opt_remotename, Opt_cache, Opt_cachetag,
  51. /* Options that take no arguments */
  52. Opt_nodevmap,
  53. /* Cache options */
  54. Opt_cache_loose, Opt_fscache, Opt_mmap,
  55. /* Access options */
  56. Opt_access, Opt_posixacl,
  57. /* Lock timeout option */
  58. Opt_locktimeout,
  59. /* Error token */
  60. Opt_err
  61. };
  62. static const match_table_t tokens = {
  63. {Opt_debug, "debug=%x"},
  64. {Opt_dfltuid, "dfltuid=%u"},
  65. {Opt_dfltgid, "dfltgid=%u"},
  66. {Opt_afid, "afid=%u"},
  67. {Opt_uname, "uname=%s"},
  68. {Opt_remotename, "aname=%s"},
  69. {Opt_nodevmap, "nodevmap"},
  70. {Opt_cache, "cache=%s"},
  71. {Opt_cache_loose, "loose"},
  72. {Opt_fscache, "fscache"},
  73. {Opt_mmap, "mmap"},
  74. {Opt_cachetag, "cachetag=%s"},
  75. {Opt_access, "access=%s"},
  76. {Opt_posixacl, "posixacl"},
  77. {Opt_locktimeout, "locktimeout=%u"},
  78. {Opt_err, NULL}
  79. };
  80. /* Interpret mount options for cache mode */
  81. static int get_cache_mode(char *s)
  82. {
  83. int version = -EINVAL;
  84. if (!strcmp(s, "loose")) {
  85. version = CACHE_LOOSE;
  86. p9_debug(P9_DEBUG_9P, "Cache mode: loose\n");
  87. } else if (!strcmp(s, "fscache")) {
  88. version = CACHE_FSCACHE;
  89. p9_debug(P9_DEBUG_9P, "Cache mode: fscache\n");
  90. } else if (!strcmp(s, "mmap")) {
  91. version = CACHE_MMAP;
  92. p9_debug(P9_DEBUG_9P, "Cache mode: mmap\n");
  93. } else if (!strcmp(s, "none")) {
  94. version = CACHE_NONE;
  95. p9_debug(P9_DEBUG_9P, "Cache mode: none\n");
  96. } else
  97. pr_info("Unknown Cache mode %s\n", s);
  98. return version;
  99. }
  100. /**
  101. * v9fs_parse_options - parse mount options into session structure
  102. * @v9ses: existing v9fs session information
  103. *
  104. * Return 0 upon success, -ERRNO upon failure.
  105. */
  106. static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
  107. {
  108. char *options, *tmp_options;
  109. substring_t args[MAX_OPT_ARGS];
  110. char *p;
  111. int option = 0;
  112. char *s, *e;
  113. int ret = 0;
  114. /* setup defaults */
  115. v9ses->afid = ~0;
  116. v9ses->debug = 0;
  117. v9ses->cache = CACHE_NONE;
  118. #ifdef CONFIG_9P_FSCACHE
  119. v9ses->cachetag = NULL;
  120. #endif
  121. v9ses->session_lock_timeout = P9_LOCK_TIMEOUT;
  122. if (!opts)
  123. return 0;
  124. tmp_options = kstrdup(opts, GFP_KERNEL);
  125. if (!tmp_options) {
  126. ret = -ENOMEM;
  127. goto fail_option_alloc;
  128. }
  129. options = tmp_options;
  130. while ((p = strsep(&options, ",")) != NULL) {
  131. int token, r;
  132. if (!*p)
  133. continue;
  134. token = match_token(p, tokens, args);
  135. switch (token) {
  136. case Opt_debug:
  137. r = match_int(&args[0], &option);
  138. if (r < 0) {
  139. p9_debug(P9_DEBUG_ERROR,
  140. "integer field, but no integer?\n");
  141. ret = r;
  142. continue;
  143. }
  144. v9ses->debug = option;
  145. #ifdef CONFIG_NET_9P_DEBUG
  146. p9_debug_level = option;
  147. #endif
  148. break;
  149. case Opt_dfltuid:
  150. r = match_int(&args[0], &option);
  151. if (r < 0) {
  152. p9_debug(P9_DEBUG_ERROR,
  153. "integer field, but no integer?\n");
  154. ret = r;
  155. continue;
  156. }
  157. v9ses->dfltuid = make_kuid(current_user_ns(), option);
  158. if (!uid_valid(v9ses->dfltuid)) {
  159. p9_debug(P9_DEBUG_ERROR,
  160. "uid field, but not a uid?\n");
  161. ret = -EINVAL;
  162. continue;
  163. }
  164. break;
  165. case Opt_dfltgid:
  166. r = match_int(&args[0], &option);
  167. if (r < 0) {
  168. p9_debug(P9_DEBUG_ERROR,
  169. "integer field, but no integer?\n");
  170. ret = r;
  171. continue;
  172. }
  173. v9ses->dfltgid = make_kgid(current_user_ns(), option);
  174. if (!gid_valid(v9ses->dfltgid)) {
  175. p9_debug(P9_DEBUG_ERROR,
  176. "gid field, but not a gid?\n");
  177. ret = -EINVAL;
  178. continue;
  179. }
  180. break;
  181. case Opt_afid:
  182. r = match_int(&args[0], &option);
  183. if (r < 0) {
  184. p9_debug(P9_DEBUG_ERROR,
  185. "integer field, but no integer?\n");
  186. ret = r;
  187. continue;
  188. }
  189. v9ses->afid = option;
  190. break;
  191. case Opt_uname:
  192. kfree(v9ses->uname);
  193. v9ses->uname = match_strdup(&args[0]);
  194. if (!v9ses->uname) {
  195. ret = -ENOMEM;
  196. goto free_and_return;
  197. }
  198. break;
  199. case Opt_remotename:
  200. kfree(v9ses->aname);
  201. v9ses->aname = match_strdup(&args[0]);
  202. if (!v9ses->aname) {
  203. ret = -ENOMEM;
  204. goto free_and_return;
  205. }
  206. break;
  207. case Opt_nodevmap:
  208. v9ses->nodev = 1;
  209. break;
  210. case Opt_cache_loose:
  211. v9ses->cache = CACHE_LOOSE;
  212. break;
  213. case Opt_fscache:
  214. v9ses->cache = CACHE_FSCACHE;
  215. break;
  216. case Opt_mmap:
  217. v9ses->cache = CACHE_MMAP;
  218. break;
  219. case Opt_cachetag:
  220. #ifdef CONFIG_9P_FSCACHE
  221. v9ses->cachetag = match_strdup(&args[0]);
  222. #endif
  223. break;
  224. case Opt_cache:
  225. s = match_strdup(&args[0]);
  226. if (!s) {
  227. ret = -ENOMEM;
  228. p9_debug(P9_DEBUG_ERROR,
  229. "problem allocating copy of cache arg\n");
  230. goto free_and_return;
  231. }
  232. ret = get_cache_mode(s);
  233. if (ret == -EINVAL) {
  234. kfree(s);
  235. goto free_and_return;
  236. }
  237. v9ses->cache = ret;
  238. kfree(s);
  239. break;
  240. case Opt_access:
  241. s = match_strdup(&args[0]);
  242. if (!s) {
  243. ret = -ENOMEM;
  244. p9_debug(P9_DEBUG_ERROR,
  245. "problem allocating copy of access arg\n");
  246. goto free_and_return;
  247. }
  248. v9ses->flags &= ~V9FS_ACCESS_MASK;
  249. if (strcmp(s, "user") == 0)
  250. v9ses->flags |= V9FS_ACCESS_USER;
  251. else if (strcmp(s, "any") == 0)
  252. v9ses->flags |= V9FS_ACCESS_ANY;
  253. else if (strcmp(s, "client") == 0) {
  254. v9ses->flags |= V9FS_ACCESS_CLIENT;
  255. } else {
  256. uid_t uid;
  257. v9ses->flags |= V9FS_ACCESS_SINGLE;
  258. uid = simple_strtoul(s, &e, 10);
  259. if (*e != '\0') {
  260. ret = -EINVAL;
  261. pr_info("Unknown access argument %s\n",
  262. s);
  263. kfree(s);
  264. goto free_and_return;
  265. }
  266. v9ses->uid = make_kuid(current_user_ns(), uid);
  267. if (!uid_valid(v9ses->uid)) {
  268. ret = -EINVAL;
  269. pr_info("Uknown uid %s\n", s);
  270. kfree(s);
  271. goto free_and_return;
  272. }
  273. }
  274. kfree(s);
  275. break;
  276. case Opt_posixacl:
  277. #ifdef CONFIG_9P_FS_POSIX_ACL
  278. v9ses->flags |= V9FS_POSIX_ACL;
  279. #else
  280. p9_debug(P9_DEBUG_ERROR,
  281. "Not defined CONFIG_9P_FS_POSIX_ACL. Ignoring posixacl option\n");
  282. #endif
  283. break;
  284. case Opt_locktimeout:
  285. r = match_int(&args[0], &option);
  286. if (r < 0) {
  287. p9_debug(P9_DEBUG_ERROR,
  288. "integer field, but no integer?\n");
  289. ret = r;
  290. continue;
  291. }
  292. if (option < 1) {
  293. p9_debug(P9_DEBUG_ERROR,
  294. "locktimeout must be a greater than zero integer.\n");
  295. ret = -EINVAL;
  296. continue;
  297. }
  298. v9ses->session_lock_timeout = (long)option * HZ;
  299. break;
  300. default:
  301. continue;
  302. }
  303. }
  304. free_and_return:
  305. kfree(tmp_options);
  306. fail_option_alloc:
  307. return ret;
  308. }
  309. /**
  310. * v9fs_session_init - initialize session
  311. * @v9ses: session information structure
  312. * @dev_name: device being mounted
  313. * @data: options
  314. *
  315. */
  316. struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
  317. const char *dev_name, char *data)
  318. {
  319. struct p9_fid *fid;
  320. int rc = -ENOMEM;
  321. v9ses->uname = kstrdup(V9FS_DEFUSER, GFP_KERNEL);
  322. if (!v9ses->uname)
  323. goto err_names;
  324. v9ses->aname = kstrdup(V9FS_DEFANAME, GFP_KERNEL);
  325. if (!v9ses->aname)
  326. goto err_names;
  327. init_rwsem(&v9ses->rename_sem);
  328. rc = bdi_setup_and_register(&v9ses->bdi, "9p");
  329. if (rc)
  330. goto err_names;
  331. v9ses->uid = INVALID_UID;
  332. v9ses->dfltuid = V9FS_DEFUID;
  333. v9ses->dfltgid = V9FS_DEFGID;
  334. v9ses->clnt = p9_client_create(dev_name, data);
  335. if (IS_ERR(v9ses->clnt)) {
  336. rc = PTR_ERR(v9ses->clnt);
  337. p9_debug(P9_DEBUG_ERROR, "problem initializing 9p client\n");
  338. goto err_bdi;
  339. }
  340. v9ses->flags = V9FS_ACCESS_USER;
  341. if (p9_is_proto_dotl(v9ses->clnt)) {
  342. v9ses->flags = V9FS_ACCESS_CLIENT;
  343. v9ses->flags |= V9FS_PROTO_2000L;
  344. } else if (p9_is_proto_dotu(v9ses->clnt)) {
  345. v9ses->flags |= V9FS_PROTO_2000U;
  346. }
  347. rc = v9fs_parse_options(v9ses, data);
  348. if (rc < 0)
  349. goto err_clnt;
  350. v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ;
  351. if (!v9fs_proto_dotl(v9ses) &&
  352. ((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_CLIENT)) {
  353. /*
  354. * We support ACCESS_CLIENT only for dotl.
  355. * Fall back to ACCESS_USER
  356. */
  357. v9ses->flags &= ~V9FS_ACCESS_MASK;
  358. v9ses->flags |= V9FS_ACCESS_USER;
  359. }
  360. /*FIXME !! */
  361. /* for legacy mode, fall back to V9FS_ACCESS_ANY */
  362. if (!(v9fs_proto_dotu(v9ses) || v9fs_proto_dotl(v9ses)) &&
  363. ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) {
  364. v9ses->flags &= ~V9FS_ACCESS_MASK;
  365. v9ses->flags |= V9FS_ACCESS_ANY;
  366. v9ses->uid = INVALID_UID;
  367. }
  368. if (!v9fs_proto_dotl(v9ses) ||
  369. !((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_CLIENT)) {
  370. /*
  371. * We support ACL checks on clinet only if the protocol is
  372. * 9P2000.L and access is V9FS_ACCESS_CLIENT.
  373. */
  374. v9ses->flags &= ~V9FS_ACL_MASK;
  375. }
  376. fid = p9_client_attach(v9ses->clnt, NULL, v9ses->uname, INVALID_UID,
  377. v9ses->aname);
  378. if (IS_ERR(fid)) {
  379. rc = PTR_ERR(fid);
  380. p9_debug(P9_DEBUG_ERROR, "cannot attach\n");
  381. goto err_clnt;
  382. }
  383. if ((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_SINGLE)
  384. fid->uid = v9ses->uid;
  385. else
  386. fid->uid = INVALID_UID;
  387. #ifdef CONFIG_9P_FSCACHE
  388. /* register the session for caching */
  389. v9fs_cache_session_get_cookie(v9ses);
  390. #endif
  391. spin_lock(&v9fs_sessionlist_lock);
  392. list_add(&v9ses->slist, &v9fs_sessionlist);
  393. spin_unlock(&v9fs_sessionlist_lock);
  394. return fid;
  395. err_clnt:
  396. p9_client_destroy(v9ses->clnt);
  397. err_bdi:
  398. bdi_destroy(&v9ses->bdi);
  399. err_names:
  400. kfree(v9ses->uname);
  401. kfree(v9ses->aname);
  402. return ERR_PTR(rc);
  403. }
  404. /**
  405. * v9fs_session_close - shutdown a session
  406. * @v9ses: session information structure
  407. *
  408. */
  409. void v9fs_session_close(struct v9fs_session_info *v9ses)
  410. {
  411. if (v9ses->clnt) {
  412. p9_client_destroy(v9ses->clnt);
  413. v9ses->clnt = NULL;
  414. }
  415. #ifdef CONFIG_9P_FSCACHE
  416. if (v9ses->fscache) {
  417. v9fs_cache_session_put_cookie(v9ses);
  418. kfree(v9ses->cachetag);
  419. }
  420. #endif
  421. kfree(v9ses->uname);
  422. kfree(v9ses->aname);
  423. bdi_destroy(&v9ses->bdi);
  424. spin_lock(&v9fs_sessionlist_lock);
  425. list_del(&v9ses->slist);
  426. spin_unlock(&v9fs_sessionlist_lock);
  427. }
  428. /**
  429. * v9fs_session_cancel - terminate a session
  430. * @v9ses: session to terminate
  431. *
  432. * mark transport as disconnected and cancel all pending requests.
  433. */
  434. void v9fs_session_cancel(struct v9fs_session_info *v9ses) {
  435. p9_debug(P9_DEBUG_ERROR, "cancel session %p\n", v9ses);
  436. p9_client_disconnect(v9ses->clnt);
  437. }
  438. /**
  439. * v9fs_session_begin_cancel - Begin terminate of a session
  440. * @v9ses: session to terminate
  441. *
  442. * After this call we don't allow any request other than clunk.
  443. */
  444. void v9fs_session_begin_cancel(struct v9fs_session_info *v9ses)
  445. {
  446. p9_debug(P9_DEBUG_ERROR, "begin cancel session %p\n", v9ses);
  447. p9_client_begin_disconnect(v9ses->clnt);
  448. }
  449. extern int v9fs_error_init(void);
  450. static struct kobject *v9fs_kobj;
  451. #ifdef CONFIG_9P_FSCACHE
  452. /**
  453. * caches_show - list caches associated with a session
  454. *
  455. * Returns the size of buffer written.
  456. */
  457. static ssize_t caches_show(struct kobject *kobj,
  458. struct kobj_attribute *attr,
  459. char *buf)
  460. {
  461. ssize_t n = 0, count = 0, limit = PAGE_SIZE;
  462. struct v9fs_session_info *v9ses;
  463. spin_lock(&v9fs_sessionlist_lock);
  464. list_for_each_entry(v9ses, &v9fs_sessionlist, slist) {
  465. if (v9ses->cachetag) {
  466. n = snprintf(buf, limit, "%s\n", v9ses->cachetag);
  467. if (n < 0) {
  468. count = n;
  469. break;
  470. }
  471. count += n;
  472. limit -= n;
  473. }
  474. }
  475. spin_unlock(&v9fs_sessionlist_lock);
  476. return count;
  477. }
  478. static struct kobj_attribute v9fs_attr_cache = __ATTR_RO(caches);
  479. #endif /* CONFIG_9P_FSCACHE */
  480. static struct attribute *v9fs_attrs[] = {
  481. #ifdef CONFIG_9P_FSCACHE
  482. &v9fs_attr_cache.attr,
  483. #endif
  484. NULL,
  485. };
  486. static struct attribute_group v9fs_attr_group = {
  487. .attrs = v9fs_attrs,
  488. };
  489. /**
  490. * v9fs_sysfs_init - Initialize the v9fs sysfs interface
  491. *
  492. */
  493. static int __init v9fs_sysfs_init(void)
  494. {
  495. v9fs_kobj = kobject_create_and_add("9p", fs_kobj);
  496. if (!v9fs_kobj)
  497. return -ENOMEM;
  498. if (sysfs_create_group(v9fs_kobj, &v9fs_attr_group)) {
  499. kobject_put(v9fs_kobj);
  500. return -ENOMEM;
  501. }
  502. return 0;
  503. }
  504. /**
  505. * v9fs_sysfs_cleanup - Unregister the v9fs sysfs interface
  506. *
  507. */
  508. static void v9fs_sysfs_cleanup(void)
  509. {
  510. sysfs_remove_group(v9fs_kobj, &v9fs_attr_group);
  511. kobject_put(v9fs_kobj);
  512. }
  513. static void v9fs_inode_init_once(void *foo)
  514. {
  515. struct v9fs_inode *v9inode = (struct v9fs_inode *)foo;
  516. #ifdef CONFIG_9P_FSCACHE
  517. v9inode->fscache = NULL;
  518. #endif
  519. memset(&v9inode->qid, 0, sizeof(v9inode->qid));
  520. inode_init_once(&v9inode->vfs_inode);
  521. }
  522. /**
  523. * v9fs_init_inode_cache - initialize a cache for 9P
  524. * Returns 0 on success.
  525. */
  526. static int v9fs_init_inode_cache(void)
  527. {
  528. v9fs_inode_cache = kmem_cache_create("v9fs_inode_cache",
  529. sizeof(struct v9fs_inode),
  530. 0, (SLAB_RECLAIM_ACCOUNT|
  531. SLAB_MEM_SPREAD),
  532. v9fs_inode_init_once);
  533. if (!v9fs_inode_cache)
  534. return -ENOMEM;
  535. return 0;
  536. }
  537. /**
  538. * v9fs_destroy_inode_cache - destroy the cache of 9P inode
  539. *
  540. */
  541. static void v9fs_destroy_inode_cache(void)
  542. {
  543. /*
  544. * Make sure all delayed rcu free inodes are flushed before we
  545. * destroy cache.
  546. */
  547. rcu_barrier();
  548. kmem_cache_destroy(v9fs_inode_cache);
  549. }
  550. static int v9fs_cache_register(void)
  551. {
  552. int ret;
  553. ret = v9fs_init_inode_cache();
  554. if (ret < 0)
  555. return ret;
  556. #ifdef CONFIG_9P_FSCACHE
  557. ret = fscache_register_netfs(&v9fs_cache_netfs);
  558. if (ret < 0)
  559. v9fs_destroy_inode_cache();
  560. #endif
  561. return ret;
  562. }
  563. static void v9fs_cache_unregister(void)
  564. {
  565. v9fs_destroy_inode_cache();
  566. #ifdef CONFIG_9P_FSCACHE
  567. fscache_unregister_netfs(&v9fs_cache_netfs);
  568. #endif
  569. }
  570. /**
  571. * init_v9fs - Initialize module
  572. *
  573. */
  574. static int __init init_v9fs(void)
  575. {
  576. int err;
  577. pr_info("Installing v9fs 9p2000 file system support\n");
  578. /* TODO: Setup list of registered trasnport modules */
  579. err = v9fs_cache_register();
  580. if (err < 0) {
  581. pr_err("Failed to register v9fs for caching\n");
  582. return err;
  583. }
  584. err = v9fs_sysfs_init();
  585. if (err < 0) {
  586. pr_err("Failed to register with sysfs\n");
  587. goto out_cache;
  588. }
  589. err = register_filesystem(&v9fs_fs_type);
  590. if (err < 0) {
  591. pr_err("Failed to register filesystem\n");
  592. goto out_sysfs_cleanup;
  593. }
  594. return 0;
  595. out_sysfs_cleanup:
  596. v9fs_sysfs_cleanup();
  597. out_cache:
  598. v9fs_cache_unregister();
  599. return err;
  600. }
  601. /**
  602. * exit_v9fs - shutdown module
  603. *
  604. */
  605. static void __exit exit_v9fs(void)
  606. {
  607. v9fs_sysfs_cleanup();
  608. v9fs_cache_unregister();
  609. unregister_filesystem(&v9fs_fs_type);
  610. }
  611. module_init(init_v9fs)
  612. module_exit(exit_v9fs)
  613. MODULE_AUTHOR("Latchesar Ionkov <lucho@ionkov.net>");
  614. MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>");
  615. MODULE_AUTHOR("Ron Minnich <rminnich@lanl.gov>");
  616. MODULE_LICENSE("GPL");