super.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * (C) 2001 Clemson University and The University of Chicago
  4. *
  5. * See COPYING in top-level directory.
  6. */
  7. #include "protocol.h"
  8. #include "orangefs-kernel.h"
  9. #include "orangefs-bufmap.h"
  10. #include <linux/parser.h>
  11. #include <linux/hashtable.h>
  12. #include <linux/seq_file.h>
  13. /* a cache for orangefs-inode objects (i.e. orangefs inode private data) */
  14. static struct kmem_cache *orangefs_inode_cache;
  15. /* list for storing orangefs specific superblocks in use */
  16. LIST_HEAD(orangefs_superblocks);
  17. DEFINE_SPINLOCK(orangefs_superblocks_lock);
  18. enum {
  19. Opt_intr,
  20. Opt_acl,
  21. Opt_local_lock,
  22. Opt_err
  23. };
  24. static const match_table_t tokens = {
  25. { Opt_acl, "acl" },
  26. { Opt_intr, "intr" },
  27. { Opt_local_lock, "local_lock" },
  28. { Opt_err, NULL }
  29. };
  30. uint64_t orangefs_features;
  31. static int orangefs_show_options(struct seq_file *m, struct dentry *root)
  32. {
  33. struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(root->d_sb);
  34. if (root->d_sb->s_flags & SB_POSIXACL)
  35. seq_puts(m, ",acl");
  36. if (orangefs_sb->flags & ORANGEFS_OPT_INTR)
  37. seq_puts(m, ",intr");
  38. if (orangefs_sb->flags & ORANGEFS_OPT_LOCAL_LOCK)
  39. seq_puts(m, ",local_lock");
  40. return 0;
  41. }
  42. static int parse_mount_options(struct super_block *sb, char *options,
  43. int silent)
  44. {
  45. struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(sb);
  46. substring_t args[MAX_OPT_ARGS];
  47. char *p;
  48. /*
  49. * Force any potential flags that might be set from the mount
  50. * to zero, ie, initialize to unset.
  51. */
  52. sb->s_flags &= ~SB_POSIXACL;
  53. orangefs_sb->flags &= ~ORANGEFS_OPT_INTR;
  54. orangefs_sb->flags &= ~ORANGEFS_OPT_LOCAL_LOCK;
  55. while ((p = strsep(&options, ",")) != NULL) {
  56. int token;
  57. if (!*p)
  58. continue;
  59. token = match_token(p, tokens, args);
  60. switch (token) {
  61. case Opt_acl:
  62. sb->s_flags |= SB_POSIXACL;
  63. break;
  64. case Opt_intr:
  65. orangefs_sb->flags |= ORANGEFS_OPT_INTR;
  66. break;
  67. case Opt_local_lock:
  68. orangefs_sb->flags |= ORANGEFS_OPT_LOCAL_LOCK;
  69. break;
  70. default:
  71. goto fail;
  72. }
  73. }
  74. return 0;
  75. fail:
  76. if (!silent)
  77. gossip_err("Error: mount option [%s] is not supported.\n", p);
  78. return -EINVAL;
  79. }
  80. static void orangefs_inode_cache_ctor(void *req)
  81. {
  82. struct orangefs_inode_s *orangefs_inode = req;
  83. inode_init_once(&orangefs_inode->vfs_inode);
  84. init_rwsem(&orangefs_inode->xattr_sem);
  85. }
  86. static struct inode *orangefs_alloc_inode(struct super_block *sb)
  87. {
  88. struct orangefs_inode_s *orangefs_inode;
  89. orangefs_inode = alloc_inode_sb(sb, orangefs_inode_cache, GFP_KERNEL);
  90. if (!orangefs_inode)
  91. return NULL;
  92. /*
  93. * We want to clear everything except for rw_semaphore and the
  94. * vfs_inode.
  95. */
  96. memset(&orangefs_inode->refn.khandle, 0, 16);
  97. orangefs_inode->refn.fs_id = ORANGEFS_FS_ID_NULL;
  98. orangefs_inode->last_failed_block_index_read = 0;
  99. memset(orangefs_inode->link_target, 0, sizeof(orangefs_inode->link_target));
  100. gossip_debug(GOSSIP_SUPER_DEBUG,
  101. "orangefs_alloc_inode: allocated %p\n",
  102. &orangefs_inode->vfs_inode);
  103. return &orangefs_inode->vfs_inode;
  104. }
  105. static void orangefs_free_inode(struct inode *inode)
  106. {
  107. struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
  108. struct orangefs_cached_xattr *cx;
  109. struct hlist_node *tmp;
  110. int i;
  111. hash_for_each_safe(orangefs_inode->xattr_cache, i, tmp, cx, node) {
  112. hlist_del(&cx->node);
  113. kfree(cx);
  114. }
  115. kmem_cache_free(orangefs_inode_cache, orangefs_inode);
  116. }
  117. static void orangefs_destroy_inode(struct inode *inode)
  118. {
  119. struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
  120. gossip_debug(GOSSIP_SUPER_DEBUG,
  121. "%s: deallocated %p destroying inode %pU\n",
  122. __func__, orangefs_inode, get_khandle_from_ino(inode));
  123. }
  124. static int orangefs_write_inode(struct inode *inode,
  125. struct writeback_control *wbc)
  126. {
  127. gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_write_inode\n");
  128. return orangefs_inode_setattr(inode);
  129. }
  130. /*
  131. * NOTE: information filled in here is typically reflected in the
  132. * output of the system command 'df'
  133. */
  134. static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf)
  135. {
  136. int ret = -ENOMEM;
  137. struct orangefs_kernel_op_s *new_op = NULL;
  138. int flags = 0;
  139. struct super_block *sb = NULL;
  140. sb = dentry->d_sb;
  141. gossip_debug(GOSSIP_SUPER_DEBUG,
  142. "%s: called on sb %p (fs_id is %d)\n",
  143. __func__,
  144. sb,
  145. (int)(ORANGEFS_SB(sb)->fs_id));
  146. new_op = op_alloc(ORANGEFS_VFS_OP_STATFS);
  147. if (!new_op)
  148. return ret;
  149. new_op->upcall.req.statfs.fs_id = ORANGEFS_SB(sb)->fs_id;
  150. if (ORANGEFS_SB(sb)->flags & ORANGEFS_OPT_INTR)
  151. flags = ORANGEFS_OP_INTERRUPTIBLE;
  152. ret = service_operation(new_op, "orangefs_statfs", flags);
  153. if (new_op->downcall.status < 0)
  154. goto out_op_release;
  155. gossip_debug(GOSSIP_SUPER_DEBUG,
  156. "%s: got %ld blocks available | "
  157. "%ld blocks total | %ld block size | "
  158. "%ld files total | %ld files avail\n",
  159. __func__,
  160. (long)new_op->downcall.resp.statfs.blocks_avail,
  161. (long)new_op->downcall.resp.statfs.blocks_total,
  162. (long)new_op->downcall.resp.statfs.block_size,
  163. (long)new_op->downcall.resp.statfs.files_total,
  164. (long)new_op->downcall.resp.statfs.files_avail);
  165. buf->f_type = sb->s_magic;
  166. memcpy(&buf->f_fsid, &ORANGEFS_SB(sb)->fs_id, sizeof(buf->f_fsid));
  167. buf->f_bsize = new_op->downcall.resp.statfs.block_size;
  168. buf->f_namelen = ORANGEFS_NAME_MAX;
  169. buf->f_blocks = (sector_t) new_op->downcall.resp.statfs.blocks_total;
  170. buf->f_bfree = (sector_t) new_op->downcall.resp.statfs.blocks_avail;
  171. buf->f_bavail = (sector_t) new_op->downcall.resp.statfs.blocks_avail;
  172. buf->f_files = (sector_t) new_op->downcall.resp.statfs.files_total;
  173. buf->f_ffree = (sector_t) new_op->downcall.resp.statfs.files_avail;
  174. buf->f_frsize = 0;
  175. out_op_release:
  176. op_release(new_op);
  177. gossip_debug(GOSSIP_SUPER_DEBUG, "%s: returning %d\n", __func__, ret);
  178. return ret;
  179. }
  180. /*
  181. * Remount as initiated by VFS layer. We just need to reparse the mount
  182. * options, no need to signal pvfs2-client-core about it.
  183. */
  184. static int orangefs_remount_fs(struct super_block *sb, int *flags, char *data)
  185. {
  186. gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_remount_fs: called\n");
  187. return parse_mount_options(sb, data, 1);
  188. }
  189. /*
  190. * Remount as initiated by pvfs2-client-core on restart. This is used to
  191. * repopulate mount information left from previous pvfs2-client-core.
  192. *
  193. * the idea here is that given a valid superblock, we're
  194. * re-initializing the user space client with the initial mount
  195. * information specified when the super block was first initialized.
  196. * this is very different than the first initialization/creation of a
  197. * superblock. we use the special service_priority_operation to make
  198. * sure that the mount gets ahead of any other pending operation that
  199. * is waiting for servicing. this means that the pvfs2-client won't
  200. * fail to start several times for all other pending operations before
  201. * the client regains all of the mount information from us.
  202. * NOTE: this function assumes that the request_mutex is already acquired!
  203. */
  204. int orangefs_remount(struct orangefs_sb_info_s *orangefs_sb)
  205. {
  206. struct orangefs_kernel_op_s *new_op;
  207. int ret = -EINVAL;
  208. gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_remount: called\n");
  209. new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
  210. if (!new_op)
  211. return -ENOMEM;
  212. strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
  213. orangefs_sb->devname,
  214. ORANGEFS_MAX_SERVER_ADDR_LEN);
  215. gossip_debug(GOSSIP_SUPER_DEBUG,
  216. "Attempting ORANGEFS Remount via host %s\n",
  217. new_op->upcall.req.fs_mount.orangefs_config_server);
  218. /*
  219. * we assume that the calling function has already acquired the
  220. * request_mutex to prevent other operations from bypassing
  221. * this one
  222. */
  223. ret = service_operation(new_op, "orangefs_remount",
  224. ORANGEFS_OP_PRIORITY | ORANGEFS_OP_NO_MUTEX);
  225. gossip_debug(GOSSIP_SUPER_DEBUG,
  226. "orangefs_remount: mount got return value of %d\n",
  227. ret);
  228. if (ret == 0) {
  229. /*
  230. * store the id assigned to this sb -- it's just a
  231. * short-lived mapping that the system interface uses
  232. * to map this superblock to a particular mount entry
  233. */
  234. orangefs_sb->id = new_op->downcall.resp.fs_mount.id;
  235. orangefs_sb->mount_pending = 0;
  236. }
  237. op_release(new_op);
  238. if (orangefs_userspace_version >= 20906) {
  239. new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
  240. if (!new_op)
  241. return -ENOMEM;
  242. new_op->upcall.req.features.features = 0;
  243. ret = service_operation(new_op, "orangefs_features",
  244. ORANGEFS_OP_PRIORITY | ORANGEFS_OP_NO_MUTEX);
  245. if (!ret)
  246. orangefs_features =
  247. new_op->downcall.resp.features.features;
  248. else
  249. orangefs_features = 0;
  250. op_release(new_op);
  251. } else {
  252. orangefs_features = 0;
  253. }
  254. return ret;
  255. }
  256. int fsid_key_table_initialize(void)
  257. {
  258. return 0;
  259. }
  260. void fsid_key_table_finalize(void)
  261. {
  262. }
  263. static const struct super_operations orangefs_s_ops = {
  264. .alloc_inode = orangefs_alloc_inode,
  265. .free_inode = orangefs_free_inode,
  266. .destroy_inode = orangefs_destroy_inode,
  267. .write_inode = orangefs_write_inode,
  268. .drop_inode = generic_delete_inode,
  269. .statfs = orangefs_statfs,
  270. .remount_fs = orangefs_remount_fs,
  271. .show_options = orangefs_show_options,
  272. };
  273. static struct dentry *orangefs_fh_to_dentry(struct super_block *sb,
  274. struct fid *fid,
  275. int fh_len,
  276. int fh_type)
  277. {
  278. struct orangefs_object_kref refn;
  279. if (fh_len < 5 || fh_type > 2)
  280. return NULL;
  281. ORANGEFS_khandle_from(&(refn.khandle), fid->raw, 16);
  282. refn.fs_id = (u32) fid->raw[4];
  283. gossip_debug(GOSSIP_SUPER_DEBUG,
  284. "fh_to_dentry: handle %pU, fs_id %d\n",
  285. &refn.khandle,
  286. refn.fs_id);
  287. return d_obtain_alias(orangefs_iget(sb, &refn));
  288. }
  289. static int orangefs_encode_fh(struct inode *inode,
  290. __u32 *fh,
  291. int *max_len,
  292. struct inode *parent)
  293. {
  294. int len = parent ? 10 : 5;
  295. int type = 1;
  296. struct orangefs_object_kref refn;
  297. if (*max_len < len) {
  298. gossip_err("fh buffer is too small for encoding\n");
  299. *max_len = len;
  300. type = 255;
  301. goto out;
  302. }
  303. refn = ORANGEFS_I(inode)->refn;
  304. ORANGEFS_khandle_to(&refn.khandle, fh, 16);
  305. fh[4] = refn.fs_id;
  306. gossip_debug(GOSSIP_SUPER_DEBUG,
  307. "Encoding fh: handle %pU, fsid %u\n",
  308. &refn.khandle,
  309. refn.fs_id);
  310. if (parent) {
  311. refn = ORANGEFS_I(parent)->refn;
  312. ORANGEFS_khandle_to(&refn.khandle, (char *) fh + 20, 16);
  313. fh[9] = refn.fs_id;
  314. type = 2;
  315. gossip_debug(GOSSIP_SUPER_DEBUG,
  316. "Encoding parent: handle %pU, fsid %u\n",
  317. &refn.khandle,
  318. refn.fs_id);
  319. }
  320. *max_len = len;
  321. out:
  322. return type;
  323. }
  324. static const struct export_operations orangefs_export_ops = {
  325. .encode_fh = orangefs_encode_fh,
  326. .fh_to_dentry = orangefs_fh_to_dentry,
  327. };
  328. static int orangefs_unmount(int id, __s32 fs_id, const char *devname)
  329. {
  330. struct orangefs_kernel_op_s *op;
  331. int r;
  332. op = op_alloc(ORANGEFS_VFS_OP_FS_UMOUNT);
  333. if (!op)
  334. return -ENOMEM;
  335. op->upcall.req.fs_umount.id = id;
  336. op->upcall.req.fs_umount.fs_id = fs_id;
  337. strncpy(op->upcall.req.fs_umount.orangefs_config_server,
  338. devname, ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
  339. r = service_operation(op, "orangefs_fs_umount", 0);
  340. /* Not much to do about an error here. */
  341. if (r)
  342. gossip_err("orangefs_unmount: service_operation %d\n", r);
  343. op_release(op);
  344. return r;
  345. }
  346. static int orangefs_fill_sb(struct super_block *sb,
  347. struct orangefs_fs_mount_response *fs_mount,
  348. void *data, int silent)
  349. {
  350. int ret;
  351. struct inode *root;
  352. struct dentry *root_dentry;
  353. struct orangefs_object_kref root_object;
  354. ORANGEFS_SB(sb)->sb = sb;
  355. ORANGEFS_SB(sb)->root_khandle = fs_mount->root_khandle;
  356. ORANGEFS_SB(sb)->fs_id = fs_mount->fs_id;
  357. ORANGEFS_SB(sb)->id = fs_mount->id;
  358. if (data) {
  359. ret = parse_mount_options(sb, data, silent);
  360. if (ret)
  361. return ret;
  362. }
  363. /* Hang the xattr handlers off the superblock */
  364. sb->s_xattr = orangefs_xattr_handlers;
  365. sb->s_magic = ORANGEFS_SUPER_MAGIC;
  366. sb->s_op = &orangefs_s_ops;
  367. sb->s_d_op = &orangefs_dentry_operations;
  368. sb->s_blocksize = PAGE_SIZE;
  369. sb->s_blocksize_bits = PAGE_SHIFT;
  370. sb->s_maxbytes = MAX_LFS_FILESIZE;
  371. ret = super_setup_bdi(sb);
  372. if (ret)
  373. return ret;
  374. root_object.khandle = ORANGEFS_SB(sb)->root_khandle;
  375. root_object.fs_id = ORANGEFS_SB(sb)->fs_id;
  376. gossip_debug(GOSSIP_SUPER_DEBUG,
  377. "get inode %pU, fsid %d\n",
  378. &root_object.khandle,
  379. root_object.fs_id);
  380. root = orangefs_iget(sb, &root_object);
  381. if (IS_ERR(root))
  382. return PTR_ERR(root);
  383. gossip_debug(GOSSIP_SUPER_DEBUG,
  384. "Allocated root inode [%p] with mode %x\n",
  385. root,
  386. root->i_mode);
  387. /* allocates and places root dentry in dcache */
  388. root_dentry = d_make_root(root);
  389. if (!root_dentry)
  390. return -ENOMEM;
  391. sb->s_export_op = &orangefs_export_ops;
  392. sb->s_root = root_dentry;
  393. return 0;
  394. }
  395. struct dentry *orangefs_mount(struct file_system_type *fst,
  396. int flags,
  397. const char *devname,
  398. void *data)
  399. {
  400. int ret;
  401. struct super_block *sb = ERR_PTR(-EINVAL);
  402. struct orangefs_kernel_op_s *new_op;
  403. struct dentry *d = ERR_PTR(-EINVAL);
  404. gossip_debug(GOSSIP_SUPER_DEBUG,
  405. "orangefs_mount: called with devname %s\n",
  406. devname);
  407. if (!devname) {
  408. gossip_err("ERROR: device name not specified.\n");
  409. return ERR_PTR(-EINVAL);
  410. }
  411. new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
  412. if (!new_op)
  413. return ERR_PTR(-ENOMEM);
  414. strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
  415. devname,
  416. ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
  417. gossip_debug(GOSSIP_SUPER_DEBUG,
  418. "Attempting ORANGEFS Mount via host %s\n",
  419. new_op->upcall.req.fs_mount.orangefs_config_server);
  420. ret = service_operation(new_op, "orangefs_mount", 0);
  421. gossip_debug(GOSSIP_SUPER_DEBUG,
  422. "orangefs_mount: mount got return value of %d\n", ret);
  423. if (ret)
  424. goto free_op;
  425. if (new_op->downcall.resp.fs_mount.fs_id == ORANGEFS_FS_ID_NULL) {
  426. gossip_err("ERROR: Retrieved null fs_id\n");
  427. ret = -EINVAL;
  428. goto free_op;
  429. }
  430. sb = sget(fst, NULL, set_anon_super, flags, NULL);
  431. if (IS_ERR(sb)) {
  432. d = ERR_CAST(sb);
  433. orangefs_unmount(new_op->downcall.resp.fs_mount.id,
  434. new_op->downcall.resp.fs_mount.fs_id, devname);
  435. goto free_op;
  436. }
  437. /* alloc and init our private orangefs sb info */
  438. sb->s_fs_info = kzalloc(sizeof(struct orangefs_sb_info_s), GFP_KERNEL);
  439. if (!ORANGEFS_SB(sb)) {
  440. d = ERR_PTR(-ENOMEM);
  441. goto free_sb_and_op;
  442. }
  443. ret = orangefs_fill_sb(sb,
  444. &new_op->downcall.resp.fs_mount, data,
  445. flags & SB_SILENT ? 1 : 0);
  446. if (ret) {
  447. d = ERR_PTR(ret);
  448. goto free_sb_and_op;
  449. }
  450. /*
  451. * on successful mount, store the devname and data
  452. * used
  453. */
  454. strncpy(ORANGEFS_SB(sb)->devname,
  455. devname,
  456. ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
  457. /* mount_pending must be cleared */
  458. ORANGEFS_SB(sb)->mount_pending = 0;
  459. /*
  460. * finally, add this sb to our list of known orangefs
  461. * sb's
  462. */
  463. gossip_debug(GOSSIP_SUPER_DEBUG,
  464. "Adding SB %p to orangefs superblocks\n",
  465. ORANGEFS_SB(sb));
  466. spin_lock(&orangefs_superblocks_lock);
  467. list_add_tail(&ORANGEFS_SB(sb)->list, &orangefs_superblocks);
  468. spin_unlock(&orangefs_superblocks_lock);
  469. op_release(new_op);
  470. /* Must be removed from the list now. */
  471. ORANGEFS_SB(sb)->no_list = 0;
  472. if (orangefs_userspace_version >= 20906) {
  473. new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
  474. if (!new_op)
  475. return ERR_PTR(-ENOMEM);
  476. new_op->upcall.req.features.features = 0;
  477. ret = service_operation(new_op, "orangefs_features", 0);
  478. orangefs_features = new_op->downcall.resp.features.features;
  479. op_release(new_op);
  480. } else {
  481. orangefs_features = 0;
  482. }
  483. return dget(sb->s_root);
  484. free_sb_and_op:
  485. /* Will call orangefs_kill_sb with sb not in list. */
  486. ORANGEFS_SB(sb)->no_list = 1;
  487. /* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_kill_sb. */
  488. deactivate_locked_super(sb);
  489. free_op:
  490. gossip_err("orangefs_mount: mount request failed with %d\n", ret);
  491. if (ret == -EINVAL) {
  492. gossip_err("Ensure that all orangefs-servers have the same FS configuration files\n");
  493. gossip_err("Look at pvfs2-client-core log file (typically /tmp/pvfs2-client.log) for more details\n");
  494. }
  495. op_release(new_op);
  496. return d;
  497. }
  498. void orangefs_kill_sb(struct super_block *sb)
  499. {
  500. int r;
  501. gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_kill_sb: called\n");
  502. /* provided sb cleanup */
  503. kill_anon_super(sb);
  504. if (!ORANGEFS_SB(sb)) {
  505. mutex_lock(&orangefs_request_mutex);
  506. mutex_unlock(&orangefs_request_mutex);
  507. return;
  508. }
  509. /*
  510. * issue the unmount to userspace to tell it to remove the
  511. * dynamic mount info it has for this superblock
  512. */
  513. r = orangefs_unmount(ORANGEFS_SB(sb)->id, ORANGEFS_SB(sb)->fs_id,
  514. ORANGEFS_SB(sb)->devname);
  515. if (!r)
  516. ORANGEFS_SB(sb)->mount_pending = 1;
  517. if (!ORANGEFS_SB(sb)->no_list) {
  518. /* remove the sb from our list of orangefs specific sb's */
  519. spin_lock(&orangefs_superblocks_lock);
  520. /* not list_del_init */
  521. __list_del_entry(&ORANGEFS_SB(sb)->list);
  522. ORANGEFS_SB(sb)->list.prev = NULL;
  523. spin_unlock(&orangefs_superblocks_lock);
  524. }
  525. /*
  526. * make sure that ORANGEFS_DEV_REMOUNT_ALL loop that might've seen us
  527. * gets completed before we free the dang thing.
  528. */
  529. mutex_lock(&orangefs_request_mutex);
  530. mutex_unlock(&orangefs_request_mutex);
  531. /* free the orangefs superblock private data */
  532. kfree(ORANGEFS_SB(sb));
  533. }
  534. int orangefs_inode_cache_initialize(void)
  535. {
  536. orangefs_inode_cache = kmem_cache_create_usercopy(
  537. "orangefs_inode_cache",
  538. sizeof(struct orangefs_inode_s),
  539. 0,
  540. ORANGEFS_CACHE_CREATE_FLAGS,
  541. offsetof(struct orangefs_inode_s,
  542. link_target),
  543. sizeof_field(struct orangefs_inode_s,
  544. link_target),
  545. orangefs_inode_cache_ctor);
  546. if (!orangefs_inode_cache) {
  547. gossip_err("Cannot create orangefs_inode_cache\n");
  548. return -ENOMEM;
  549. }
  550. return 0;
  551. }
  552. int orangefs_inode_cache_finalize(void)
  553. {
  554. kmem_cache_destroy(orangefs_inode_cache);
  555. return 0;
  556. }