super.c 17 KB

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