super.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /*
  2. * (C) 2001 Clemson University and The University of Chicago
  3. *
  4. * See COPYING in top-level directory.
  5. */
  6. #include "protocol.h"
  7. #include "orangefs-kernel.h"
  8. #include "orangefs-bufmap.h"
  9. #include <linux/parser.h>
  10. /* a cache for orangefs-inode objects (i.e. orangefs inode private data) */
  11. static struct kmem_cache *orangefs_inode_cache;
  12. /* list for storing orangefs specific superblocks in use */
  13. LIST_HEAD(orangefs_superblocks);
  14. DEFINE_SPINLOCK(orangefs_superblocks_lock);
  15. enum {
  16. Opt_intr,
  17. Opt_acl,
  18. Opt_local_lock,
  19. Opt_err
  20. };
  21. static const match_table_t tokens = {
  22. { Opt_acl, "acl" },
  23. { Opt_intr, "intr" },
  24. { Opt_local_lock, "local_lock" },
  25. { Opt_err, NULL }
  26. };
  27. uint64_t orangefs_features;
  28. static int orangefs_show_options(struct seq_file *m, struct dentry *root)
  29. {
  30. struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(root->d_sb);
  31. if (root->d_sb->s_flags & MS_POSIXACL)
  32. seq_puts(m, ",acl");
  33. if (orangefs_sb->flags & ORANGEFS_OPT_INTR)
  34. seq_puts(m, ",intr");
  35. if (orangefs_sb->flags & ORANGEFS_OPT_LOCAL_LOCK)
  36. seq_puts(m, ",local_lock");
  37. return 0;
  38. }
  39. static int parse_mount_options(struct super_block *sb, char *options,
  40. int silent)
  41. {
  42. struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(sb);
  43. substring_t args[MAX_OPT_ARGS];
  44. char *p;
  45. /*
  46. * Force any potential flags that might be set from the mount
  47. * to zero, ie, initialize to unset.
  48. */
  49. sb->s_flags &= ~MS_POSIXACL;
  50. orangefs_sb->flags &= ~ORANGEFS_OPT_INTR;
  51. orangefs_sb->flags &= ~ORANGEFS_OPT_LOCAL_LOCK;
  52. while ((p = strsep(&options, ",")) != NULL) {
  53. int token;
  54. if (!*p)
  55. continue;
  56. token = match_token(p, tokens, args);
  57. switch (token) {
  58. case Opt_acl:
  59. sb->s_flags |= MS_POSIXACL;
  60. break;
  61. case Opt_intr:
  62. orangefs_sb->flags |= ORANGEFS_OPT_INTR;
  63. break;
  64. case Opt_local_lock:
  65. orangefs_sb->flags |= ORANGEFS_OPT_LOCAL_LOCK;
  66. break;
  67. default:
  68. goto fail;
  69. }
  70. }
  71. return 0;
  72. fail:
  73. if (!silent)
  74. gossip_err("Error: mount option [%s] is not supported.\n", p);
  75. return -EINVAL;
  76. }
  77. static void orangefs_inode_cache_ctor(void *req)
  78. {
  79. struct orangefs_inode_s *orangefs_inode = req;
  80. inode_init_once(&orangefs_inode->vfs_inode);
  81. init_rwsem(&orangefs_inode->xattr_sem);
  82. orangefs_inode->vfs_inode.i_version = 1;
  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. orangefs_inode->pinode_flags = 0;
  99. gossip_debug(GOSSIP_SUPER_DEBUG,
  100. "orangefs_alloc_inode: allocated %p\n",
  101. &orangefs_inode->vfs_inode);
  102. return &orangefs_inode->vfs_inode;
  103. }
  104. static void orangefs_i_callback(struct rcu_head *head)
  105. {
  106. struct inode *inode = container_of(head, struct inode, i_rcu);
  107. struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
  108. kmem_cache_free(orangefs_inode_cache, orangefs_inode);
  109. }
  110. static void orangefs_destroy_inode(struct inode *inode)
  111. {
  112. struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
  113. gossip_debug(GOSSIP_SUPER_DEBUG,
  114. "%s: deallocated %p destroying inode %pU\n",
  115. __func__, orangefs_inode, get_khandle_from_ino(inode));
  116. call_rcu(&inode->i_rcu, orangefs_i_callback);
  117. }
  118. /*
  119. * NOTE: information filled in here is typically reflected in the
  120. * output of the system command 'df'
  121. */
  122. static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf)
  123. {
  124. int ret = -ENOMEM;
  125. struct orangefs_kernel_op_s *new_op = NULL;
  126. int flags = 0;
  127. struct super_block *sb = NULL;
  128. sb = dentry->d_sb;
  129. gossip_debug(GOSSIP_SUPER_DEBUG,
  130. "orangefs_statfs: called on sb %p (fs_id is %d)\n",
  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, "orangefs_statfs: returning %d\n", 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. /* Called whenever the VFS dirties the inode in response to atime updates */
  251. static void orangefs_dirty_inode(struct inode *inode, int flags)
  252. {
  253. struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
  254. gossip_debug(GOSSIP_SUPER_DEBUG,
  255. "orangefs_dirty_inode: %pU\n",
  256. get_khandle_from_ino(inode));
  257. SetAtimeFlag(orangefs_inode);
  258. }
  259. static const struct super_operations orangefs_s_ops = {
  260. .alloc_inode = orangefs_alloc_inode,
  261. .destroy_inode = orangefs_destroy_inode,
  262. .dirty_inode = orangefs_dirty_inode,
  263. .drop_inode = generic_delete_inode,
  264. .statfs = orangefs_statfs,
  265. .remount_fs = orangefs_remount_fs,
  266. .show_options = orangefs_show_options,
  267. };
  268. static struct dentry *orangefs_fh_to_dentry(struct super_block *sb,
  269. struct fid *fid,
  270. int fh_len,
  271. int fh_type)
  272. {
  273. struct orangefs_object_kref refn;
  274. if (fh_len < 5 || fh_type > 2)
  275. return NULL;
  276. ORANGEFS_khandle_from(&(refn.khandle), fid->raw, 16);
  277. refn.fs_id = (u32) fid->raw[4];
  278. gossip_debug(GOSSIP_SUPER_DEBUG,
  279. "fh_to_dentry: handle %pU, fs_id %d\n",
  280. &refn.khandle,
  281. refn.fs_id);
  282. return d_obtain_alias(orangefs_iget(sb, &refn));
  283. }
  284. static int orangefs_encode_fh(struct inode *inode,
  285. __u32 *fh,
  286. int *max_len,
  287. struct inode *parent)
  288. {
  289. int len = parent ? 10 : 5;
  290. int type = 1;
  291. struct orangefs_object_kref refn;
  292. if (*max_len < len) {
  293. gossip_lerr("fh buffer is too small for encoding\n");
  294. *max_len = len;
  295. type = 255;
  296. goto out;
  297. }
  298. refn = ORANGEFS_I(inode)->refn;
  299. ORANGEFS_khandle_to(&refn.khandle, fh, 16);
  300. fh[4] = refn.fs_id;
  301. gossip_debug(GOSSIP_SUPER_DEBUG,
  302. "Encoding fh: handle %pU, fsid %u\n",
  303. &refn.khandle,
  304. refn.fs_id);
  305. if (parent) {
  306. refn = ORANGEFS_I(parent)->refn;
  307. ORANGEFS_khandle_to(&refn.khandle, (char *) fh + 20, 16);
  308. fh[9] = refn.fs_id;
  309. type = 2;
  310. gossip_debug(GOSSIP_SUPER_DEBUG,
  311. "Encoding parent: handle %pU, fsid %u\n",
  312. &refn.khandle,
  313. refn.fs_id);
  314. }
  315. *max_len = len;
  316. out:
  317. return type;
  318. }
  319. static const struct export_operations orangefs_export_ops = {
  320. .encode_fh = orangefs_encode_fh,
  321. .fh_to_dentry = orangefs_fh_to_dentry,
  322. };
  323. static int orangefs_unmount(int id, __s32 fs_id, const char *devname)
  324. {
  325. struct orangefs_kernel_op_s *op;
  326. int r;
  327. op = op_alloc(ORANGEFS_VFS_OP_FS_UMOUNT);
  328. if (!op)
  329. return -ENOMEM;
  330. op->upcall.req.fs_umount.id = id;
  331. op->upcall.req.fs_umount.fs_id = fs_id;
  332. strncpy(op->upcall.req.fs_umount.orangefs_config_server,
  333. devname, ORANGEFS_MAX_SERVER_ADDR_LEN);
  334. r = service_operation(op, "orangefs_fs_umount", 0);
  335. /* Not much to do about an error here. */
  336. if (r)
  337. gossip_err("orangefs_unmount: service_operation %d\n", r);
  338. op_release(op);
  339. return r;
  340. }
  341. static int orangefs_fill_sb(struct super_block *sb,
  342. struct orangefs_fs_mount_response *fs_mount,
  343. void *data, int silent)
  344. {
  345. int ret = -EINVAL;
  346. struct inode *root = NULL;
  347. struct dentry *root_dentry = NULL;
  348. struct orangefs_object_kref root_object;
  349. /* alloc and init our private orangefs sb info */
  350. sb->s_fs_info = kzalloc(sizeof(struct orangefs_sb_info_s), GFP_KERNEL);
  351. if (!ORANGEFS_SB(sb))
  352. return -ENOMEM;
  353. ORANGEFS_SB(sb)->sb = sb;
  354. ORANGEFS_SB(sb)->root_khandle = fs_mount->root_khandle;
  355. ORANGEFS_SB(sb)->fs_id = fs_mount->fs_id;
  356. ORANGEFS_SB(sb)->id = fs_mount->id;
  357. if (data) {
  358. ret = parse_mount_options(sb, data, silent);
  359. if (ret)
  360. return ret;
  361. }
  362. /* Hang the xattr handlers off the superblock */
  363. sb->s_xattr = orangefs_xattr_handlers;
  364. sb->s_magic = ORANGEFS_SUPER_MAGIC;
  365. sb->s_op = &orangefs_s_ops;
  366. sb->s_d_op = &orangefs_dentry_operations;
  367. sb->s_blocksize = orangefs_bufmap_size_query();
  368. sb->s_blocksize_bits = orangefs_bufmap_shift_query();
  369. sb->s_maxbytes = MAX_LFS_FILESIZE;
  370. root_object.khandle = ORANGEFS_SB(sb)->root_khandle;
  371. root_object.fs_id = ORANGEFS_SB(sb)->fs_id;
  372. gossip_debug(GOSSIP_SUPER_DEBUG,
  373. "get inode %pU, fsid %d\n",
  374. &root_object.khandle,
  375. root_object.fs_id);
  376. root = orangefs_iget(sb, &root_object);
  377. if (IS_ERR(root))
  378. return PTR_ERR(root);
  379. gossip_debug(GOSSIP_SUPER_DEBUG,
  380. "Allocated root inode [%p] with mode %x\n",
  381. root,
  382. root->i_mode);
  383. /* allocates and places root dentry in dcache */
  384. root_dentry = d_make_root(root);
  385. if (!root_dentry)
  386. return -ENOMEM;
  387. sb->s_export_op = &orangefs_export_ops;
  388. sb->s_root = root_dentry;
  389. return 0;
  390. }
  391. struct dentry *orangefs_mount(struct file_system_type *fst,
  392. int flags,
  393. const char *devname,
  394. void *data)
  395. {
  396. int ret = -EINVAL;
  397. struct super_block *sb = ERR_PTR(-EINVAL);
  398. struct orangefs_kernel_op_s *new_op;
  399. struct dentry *d = ERR_PTR(-EINVAL);
  400. gossip_debug(GOSSIP_SUPER_DEBUG,
  401. "orangefs_mount: called with devname %s\n",
  402. devname);
  403. if (!devname) {
  404. gossip_err("ERROR: device name not specified.\n");
  405. return ERR_PTR(-EINVAL);
  406. }
  407. new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
  408. if (!new_op)
  409. return ERR_PTR(-ENOMEM);
  410. strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
  411. devname,
  412. ORANGEFS_MAX_SERVER_ADDR_LEN);
  413. gossip_debug(GOSSIP_SUPER_DEBUG,
  414. "Attempting ORANGEFS Mount via host %s\n",
  415. new_op->upcall.req.fs_mount.orangefs_config_server);
  416. ret = service_operation(new_op, "orangefs_mount", 0);
  417. gossip_debug(GOSSIP_SUPER_DEBUG,
  418. "orangefs_mount: mount got return value of %d\n", ret);
  419. if (ret)
  420. goto free_op;
  421. if (new_op->downcall.resp.fs_mount.fs_id == ORANGEFS_FS_ID_NULL) {
  422. gossip_err("ERROR: Retrieved null fs_id\n");
  423. ret = -EINVAL;
  424. goto free_op;
  425. }
  426. sb = sget(fst, NULL, set_anon_super, flags, NULL);
  427. if (IS_ERR(sb)) {
  428. d = ERR_CAST(sb);
  429. orangefs_unmount(new_op->downcall.resp.fs_mount.id,
  430. new_op->downcall.resp.fs_mount.fs_id, devname);
  431. goto free_op;
  432. }
  433. ret = orangefs_fill_sb(sb,
  434. &new_op->downcall.resp.fs_mount, data,
  435. flags & MS_SILENT ? 1 : 0);
  436. if (ret) {
  437. d = ERR_PTR(ret);
  438. goto free_sb_and_op;
  439. }
  440. /*
  441. * on successful mount, store the devname and data
  442. * used
  443. */
  444. strncpy(ORANGEFS_SB(sb)->devname,
  445. devname,
  446. ORANGEFS_MAX_SERVER_ADDR_LEN);
  447. /* mount_pending must be cleared */
  448. ORANGEFS_SB(sb)->mount_pending = 0;
  449. /*
  450. * finally, add this sb to our list of known orangefs
  451. * sb's
  452. */
  453. gossip_debug(GOSSIP_SUPER_DEBUG,
  454. "Adding SB %p to orangefs superblocks\n",
  455. ORANGEFS_SB(sb));
  456. spin_lock(&orangefs_superblocks_lock);
  457. list_add_tail(&ORANGEFS_SB(sb)->list, &orangefs_superblocks);
  458. spin_unlock(&orangefs_superblocks_lock);
  459. op_release(new_op);
  460. /* Must be removed from the list now. */
  461. ORANGEFS_SB(sb)->no_list = 0;
  462. if (orangefs_userspace_version >= 20906) {
  463. new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
  464. if (!new_op)
  465. return ERR_PTR(-ENOMEM);
  466. new_op->upcall.req.features.features = 0;
  467. ret = service_operation(new_op, "orangefs_features", 0);
  468. orangefs_features = new_op->downcall.resp.features.features;
  469. op_release(new_op);
  470. } else {
  471. orangefs_features = 0;
  472. }
  473. return dget(sb->s_root);
  474. free_sb_and_op:
  475. /* Will call orangefs_kill_sb with sb not in list. */
  476. ORANGEFS_SB(sb)->no_list = 1;
  477. /* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_kill_sb. */
  478. deactivate_locked_super(sb);
  479. free_op:
  480. gossip_err("orangefs_mount: mount request failed with %d\n", ret);
  481. if (ret == -EINVAL) {
  482. gossip_err("Ensure that all orangefs-servers have the same FS configuration files\n");
  483. gossip_err("Look at pvfs2-client-core log file (typically /tmp/pvfs2-client.log) for more details\n");
  484. }
  485. op_release(new_op);
  486. return d;
  487. }
  488. void orangefs_kill_sb(struct super_block *sb)
  489. {
  490. int r;
  491. gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_kill_sb: called\n");
  492. /* provided sb cleanup */
  493. kill_anon_super(sb);
  494. /*
  495. * issue the unmount to userspace to tell it to remove the
  496. * dynamic mount info it has for this superblock
  497. */
  498. r = orangefs_unmount(ORANGEFS_SB(sb)->id, ORANGEFS_SB(sb)->fs_id,
  499. ORANGEFS_SB(sb)->devname);
  500. if (!r)
  501. ORANGEFS_SB(sb)->mount_pending = 1;
  502. if (!ORANGEFS_SB(sb)->no_list) {
  503. /* remove the sb from our list of orangefs specific sb's */
  504. spin_lock(&orangefs_superblocks_lock);
  505. /* not list_del_init */
  506. __list_del_entry(&ORANGEFS_SB(sb)->list);
  507. ORANGEFS_SB(sb)->list.prev = NULL;
  508. spin_unlock(&orangefs_superblocks_lock);
  509. }
  510. /*
  511. * make sure that ORANGEFS_DEV_REMOUNT_ALL loop that might've seen us
  512. * gets completed before we free the dang thing.
  513. */
  514. mutex_lock(&orangefs_request_mutex);
  515. mutex_unlock(&orangefs_request_mutex);
  516. /* free the orangefs superblock private data */
  517. kfree(ORANGEFS_SB(sb));
  518. }
  519. int orangefs_inode_cache_initialize(void)
  520. {
  521. orangefs_inode_cache = kmem_cache_create("orangefs_inode_cache",
  522. sizeof(struct orangefs_inode_s),
  523. 0,
  524. ORANGEFS_CACHE_CREATE_FLAGS,
  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. }