super.c 17 KB

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