uptodate.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * uptodate.c
  4. *
  5. * Tracking the up-to-date-ness of a local buffer_head with respect to
  6. * the cluster.
  7. *
  8. * Copyright (C) 2002, 2004, 2005 Oracle. All rights reserved.
  9. *
  10. * Standard buffer head caching flags (uptodate, etc) are insufficient
  11. * in a clustered environment - a buffer may be marked up to date on
  12. * our local node but could have been modified by another cluster
  13. * member. As a result an additional (and performant) caching scheme
  14. * is required. A further requirement is that we consume as little
  15. * memory as possible - we never pin buffer_head structures in order
  16. * to cache them.
  17. *
  18. * We track the existence of up to date buffers on the inodes which
  19. * are associated with them. Because we don't want to pin
  20. * buffer_heads, this is only a (strong) hint and several other checks
  21. * are made in the I/O path to ensure that we don't use a stale or
  22. * invalid buffer without going to disk:
  23. * - buffer_jbd is used liberally - if a bh is in the journal on
  24. * this node then it *must* be up to date.
  25. * - the standard buffer_uptodate() macro is used to detect buffers
  26. * which may be invalid (even if we have an up to date tracking
  27. * item for them)
  28. *
  29. * For a full understanding of how this code works together, one
  30. * should read the callers in dlmglue.c, the I/O functions in
  31. * buffer_head_io.c and ocfs2_journal_access in journal.c
  32. */
  33. #include <linux/fs.h>
  34. #include <linux/types.h>
  35. #include <linux/slab.h>
  36. #include <linux/highmem.h>
  37. #include <linux/buffer_head.h>
  38. #include <linux/rbtree.h>
  39. #include <cluster/masklog.h>
  40. #include "ocfs2.h"
  41. #include "inode.h"
  42. #include "uptodate.h"
  43. #include "ocfs2_trace.h"
  44. struct ocfs2_meta_cache_item {
  45. struct rb_node c_node;
  46. sector_t c_block;
  47. };
  48. static struct kmem_cache *ocfs2_uptodate_cachep;
  49. u64 ocfs2_metadata_cache_owner(struct ocfs2_caching_info *ci)
  50. {
  51. BUG_ON(!ci || !ci->ci_ops);
  52. return ci->ci_ops->co_owner(ci);
  53. }
  54. struct super_block *ocfs2_metadata_cache_get_super(struct ocfs2_caching_info *ci)
  55. {
  56. BUG_ON(!ci || !ci->ci_ops);
  57. return ci->ci_ops->co_get_super(ci);
  58. }
  59. static void ocfs2_metadata_cache_lock(struct ocfs2_caching_info *ci)
  60. {
  61. BUG_ON(!ci || !ci->ci_ops);
  62. ci->ci_ops->co_cache_lock(ci);
  63. }
  64. static void ocfs2_metadata_cache_unlock(struct ocfs2_caching_info *ci)
  65. {
  66. BUG_ON(!ci || !ci->ci_ops);
  67. ci->ci_ops->co_cache_unlock(ci);
  68. }
  69. void ocfs2_metadata_cache_io_lock(struct ocfs2_caching_info *ci)
  70. {
  71. BUG_ON(!ci || !ci->ci_ops);
  72. ci->ci_ops->co_io_lock(ci);
  73. }
  74. void ocfs2_metadata_cache_io_unlock(struct ocfs2_caching_info *ci)
  75. {
  76. BUG_ON(!ci || !ci->ci_ops);
  77. ci->ci_ops->co_io_unlock(ci);
  78. }
  79. static void ocfs2_metadata_cache_reset(struct ocfs2_caching_info *ci,
  80. int clear)
  81. {
  82. ci->ci_flags |= OCFS2_CACHE_FL_INLINE;
  83. ci->ci_num_cached = 0;
  84. if (clear) {
  85. ci->ci_created_trans = 0;
  86. ci->ci_last_trans = 0;
  87. }
  88. }
  89. void ocfs2_metadata_cache_init(struct ocfs2_caching_info *ci,
  90. const struct ocfs2_caching_operations *ops)
  91. {
  92. BUG_ON(!ops);
  93. ci->ci_ops = ops;
  94. ocfs2_metadata_cache_reset(ci, 1);
  95. }
  96. void ocfs2_metadata_cache_exit(struct ocfs2_caching_info *ci)
  97. {
  98. ocfs2_metadata_cache_purge(ci);
  99. ocfs2_metadata_cache_reset(ci, 1);
  100. }
  101. /* No lock taken here as 'root' is not expected to be visible to other
  102. * processes. */
  103. static unsigned int ocfs2_purge_copied_metadata_tree(struct rb_root *root)
  104. {
  105. unsigned int purged = 0;
  106. struct rb_node *node;
  107. struct ocfs2_meta_cache_item *item;
  108. while ((node = rb_last(root)) != NULL) {
  109. item = rb_entry(node, struct ocfs2_meta_cache_item, c_node);
  110. trace_ocfs2_purge_copied_metadata_tree(
  111. (unsigned long long) item->c_block);
  112. rb_erase(&item->c_node, root);
  113. kmem_cache_free(ocfs2_uptodate_cachep, item);
  114. purged++;
  115. }
  116. return purged;
  117. }
  118. /* Called from locking and called from ocfs2_clear_inode. Dump the
  119. * cache for a given inode.
  120. *
  121. * This function is a few more lines longer than necessary due to some
  122. * accounting done here, but I think it's worth tracking down those
  123. * bugs sooner -- Mark */
  124. void ocfs2_metadata_cache_purge(struct ocfs2_caching_info *ci)
  125. {
  126. unsigned int tree, to_purge, purged;
  127. struct rb_root root = RB_ROOT;
  128. BUG_ON(!ci || !ci->ci_ops);
  129. ocfs2_metadata_cache_lock(ci);
  130. tree = !(ci->ci_flags & OCFS2_CACHE_FL_INLINE);
  131. to_purge = ci->ci_num_cached;
  132. trace_ocfs2_metadata_cache_purge(
  133. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  134. to_purge, tree);
  135. /* If we're a tree, save off the root so that we can safely
  136. * initialize the cache. We do the work to free tree members
  137. * without the spinlock. */
  138. if (tree)
  139. root = ci->ci_cache.ci_tree;
  140. ocfs2_metadata_cache_reset(ci, 0);
  141. ocfs2_metadata_cache_unlock(ci);
  142. purged = ocfs2_purge_copied_metadata_tree(&root);
  143. /* If possible, track the number wiped so that we can more
  144. * easily detect counting errors. Unfortunately, this is only
  145. * meaningful for trees. */
  146. if (tree && purged != to_purge)
  147. mlog(ML_ERROR, "Owner %llu, count = %u, purged = %u\n",
  148. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  149. to_purge, purged);
  150. }
  151. /* Returns the index in the cache array, -1 if not found.
  152. * Requires ip_lock. */
  153. static int ocfs2_search_cache_array(struct ocfs2_caching_info *ci,
  154. sector_t item)
  155. {
  156. int i;
  157. for (i = 0; i < ci->ci_num_cached; i++) {
  158. if (item == ci->ci_cache.ci_array[i])
  159. return i;
  160. }
  161. return -1;
  162. }
  163. /* Returns the cache item if found, otherwise NULL.
  164. * Requires ip_lock. */
  165. static struct ocfs2_meta_cache_item *
  166. ocfs2_search_cache_tree(struct ocfs2_caching_info *ci,
  167. sector_t block)
  168. {
  169. struct rb_node * n = ci->ci_cache.ci_tree.rb_node;
  170. struct ocfs2_meta_cache_item *item = NULL;
  171. while (n) {
  172. item = rb_entry(n, struct ocfs2_meta_cache_item, c_node);
  173. if (block < item->c_block)
  174. n = n->rb_left;
  175. else if (block > item->c_block)
  176. n = n->rb_right;
  177. else
  178. return item;
  179. }
  180. return NULL;
  181. }
  182. static int ocfs2_buffer_cached(struct ocfs2_caching_info *ci,
  183. struct buffer_head *bh)
  184. {
  185. int index = -1;
  186. struct ocfs2_meta_cache_item *item = NULL;
  187. ocfs2_metadata_cache_lock(ci);
  188. trace_ocfs2_buffer_cached_begin(
  189. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  190. (unsigned long long) bh->b_blocknr,
  191. !!(ci->ci_flags & OCFS2_CACHE_FL_INLINE));
  192. if (ci->ci_flags & OCFS2_CACHE_FL_INLINE)
  193. index = ocfs2_search_cache_array(ci, bh->b_blocknr);
  194. else
  195. item = ocfs2_search_cache_tree(ci, bh->b_blocknr);
  196. ocfs2_metadata_cache_unlock(ci);
  197. trace_ocfs2_buffer_cached_end(index, item);
  198. return (index != -1) || (item != NULL);
  199. }
  200. /* Warning: even if it returns true, this does *not* guarantee that
  201. * the block is stored in our inode metadata cache.
  202. *
  203. * This can be called under lock_buffer()
  204. */
  205. int ocfs2_buffer_uptodate(struct ocfs2_caching_info *ci,
  206. struct buffer_head *bh)
  207. {
  208. /* Doesn't matter if the bh is in our cache or not -- if it's
  209. * not marked uptodate then we know it can't have correct
  210. * data. */
  211. if (!buffer_uptodate(bh))
  212. return 0;
  213. /* OCFS2 does not allow multiple nodes to be changing the same
  214. * block at the same time. */
  215. if (buffer_jbd(bh))
  216. return 1;
  217. /* Ok, locally the buffer is marked as up to date, now search
  218. * our cache to see if we can trust that. */
  219. return ocfs2_buffer_cached(ci, bh);
  220. }
  221. /*
  222. * Determine whether a buffer is currently out on a read-ahead request.
  223. * ci_io_sem should be held to serialize submitters with the logic here.
  224. */
  225. int ocfs2_buffer_read_ahead(struct ocfs2_caching_info *ci,
  226. struct buffer_head *bh)
  227. {
  228. return buffer_locked(bh) && ocfs2_buffer_cached(ci, bh);
  229. }
  230. /* Requires ip_lock */
  231. static void ocfs2_append_cache_array(struct ocfs2_caching_info *ci,
  232. sector_t block)
  233. {
  234. BUG_ON(ci->ci_num_cached >= OCFS2_CACHE_INFO_MAX_ARRAY);
  235. trace_ocfs2_append_cache_array(
  236. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  237. (unsigned long long)block, ci->ci_num_cached);
  238. ci->ci_cache.ci_array[ci->ci_num_cached] = block;
  239. ci->ci_num_cached++;
  240. }
  241. /* By now the caller should have checked that the item does *not*
  242. * exist in the tree.
  243. * Requires ip_lock. */
  244. static void __ocfs2_insert_cache_tree(struct ocfs2_caching_info *ci,
  245. struct ocfs2_meta_cache_item *new)
  246. {
  247. sector_t block = new->c_block;
  248. struct rb_node *parent = NULL;
  249. struct rb_node **p = &ci->ci_cache.ci_tree.rb_node;
  250. struct ocfs2_meta_cache_item *tmp;
  251. trace_ocfs2_insert_cache_tree(
  252. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  253. (unsigned long long)block, ci->ci_num_cached);
  254. while(*p) {
  255. parent = *p;
  256. tmp = rb_entry(parent, struct ocfs2_meta_cache_item, c_node);
  257. if (block < tmp->c_block)
  258. p = &(*p)->rb_left;
  259. else if (block > tmp->c_block)
  260. p = &(*p)->rb_right;
  261. else {
  262. /* This should never happen! */
  263. mlog(ML_ERROR, "Duplicate block %llu cached!\n",
  264. (unsigned long long) block);
  265. BUG();
  266. }
  267. }
  268. rb_link_node(&new->c_node, parent, p);
  269. rb_insert_color(&new->c_node, &ci->ci_cache.ci_tree);
  270. ci->ci_num_cached++;
  271. }
  272. /* co_cache_lock() must be held */
  273. static inline int ocfs2_insert_can_use_array(struct ocfs2_caching_info *ci)
  274. {
  275. return (ci->ci_flags & OCFS2_CACHE_FL_INLINE) &&
  276. (ci->ci_num_cached < OCFS2_CACHE_INFO_MAX_ARRAY);
  277. }
  278. /* tree should be exactly OCFS2_CACHE_INFO_MAX_ARRAY wide. NULL the
  279. * pointers in tree after we use them - this allows caller to detect
  280. * when to free in case of error.
  281. *
  282. * The co_cache_lock() must be held. */
  283. static void ocfs2_expand_cache(struct ocfs2_caching_info *ci,
  284. struct ocfs2_meta_cache_item **tree)
  285. {
  286. int i;
  287. mlog_bug_on_msg(ci->ci_num_cached != OCFS2_CACHE_INFO_MAX_ARRAY,
  288. "Owner %llu, num cached = %u, should be %u\n",
  289. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  290. ci->ci_num_cached, OCFS2_CACHE_INFO_MAX_ARRAY);
  291. mlog_bug_on_msg(!(ci->ci_flags & OCFS2_CACHE_FL_INLINE),
  292. "Owner %llu not marked as inline anymore!\n",
  293. (unsigned long long)ocfs2_metadata_cache_owner(ci));
  294. /* Be careful to initialize the tree members *first* because
  295. * once the ci_tree is used, the array is junk... */
  296. for (i = 0; i < OCFS2_CACHE_INFO_MAX_ARRAY; i++)
  297. tree[i]->c_block = ci->ci_cache.ci_array[i];
  298. ci->ci_flags &= ~OCFS2_CACHE_FL_INLINE;
  299. ci->ci_cache.ci_tree = RB_ROOT;
  300. /* this will be set again by __ocfs2_insert_cache_tree */
  301. ci->ci_num_cached = 0;
  302. for (i = 0; i < OCFS2_CACHE_INFO_MAX_ARRAY; i++) {
  303. __ocfs2_insert_cache_tree(ci, tree[i]);
  304. tree[i] = NULL;
  305. }
  306. trace_ocfs2_expand_cache(
  307. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  308. ci->ci_flags, ci->ci_num_cached);
  309. }
  310. /* Slow path function - memory allocation is necessary. See the
  311. * comment above ocfs2_set_buffer_uptodate for more information. */
  312. static void __ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci,
  313. sector_t block,
  314. int expand_tree)
  315. {
  316. int i;
  317. struct ocfs2_meta_cache_item *new = NULL;
  318. struct ocfs2_meta_cache_item *tree[OCFS2_CACHE_INFO_MAX_ARRAY] =
  319. { NULL, };
  320. trace_ocfs2_set_buffer_uptodate(
  321. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  322. (unsigned long long)block, expand_tree);
  323. new = kmem_cache_alloc(ocfs2_uptodate_cachep, GFP_NOFS);
  324. if (!new) {
  325. mlog_errno(-ENOMEM);
  326. return;
  327. }
  328. new->c_block = block;
  329. if (expand_tree) {
  330. /* Do *not* allocate an array here - the removal code
  331. * has no way of tracking that. */
  332. for (i = 0; i < OCFS2_CACHE_INFO_MAX_ARRAY; i++) {
  333. tree[i] = kmem_cache_alloc(ocfs2_uptodate_cachep,
  334. GFP_NOFS);
  335. if (!tree[i]) {
  336. mlog_errno(-ENOMEM);
  337. goto out_free;
  338. }
  339. /* These are initialized in ocfs2_expand_cache! */
  340. }
  341. }
  342. ocfs2_metadata_cache_lock(ci);
  343. if (ocfs2_insert_can_use_array(ci)) {
  344. /* Ok, items were removed from the cache in between
  345. * locks. Detect this and revert back to the fast path */
  346. ocfs2_append_cache_array(ci, block);
  347. ocfs2_metadata_cache_unlock(ci);
  348. goto out_free;
  349. }
  350. if (expand_tree)
  351. ocfs2_expand_cache(ci, tree);
  352. __ocfs2_insert_cache_tree(ci, new);
  353. ocfs2_metadata_cache_unlock(ci);
  354. new = NULL;
  355. out_free:
  356. if (new)
  357. kmem_cache_free(ocfs2_uptodate_cachep, new);
  358. /* If these were used, then ocfs2_expand_cache re-set them to
  359. * NULL for us. */
  360. if (tree[0]) {
  361. for (i = 0; i < OCFS2_CACHE_INFO_MAX_ARRAY; i++)
  362. if (tree[i])
  363. kmem_cache_free(ocfs2_uptodate_cachep,
  364. tree[i]);
  365. }
  366. }
  367. /* Item insertion is guarded by co_io_lock(), so the insertion path takes
  368. * advantage of this by not rechecking for a duplicate insert during
  369. * the slow case. Additionally, if the cache needs to be bumped up to
  370. * a tree, the code will not recheck after acquiring the lock --
  371. * multiple paths cannot be expanding to a tree at the same time.
  372. *
  373. * The slow path takes into account that items can be removed
  374. * (including the whole tree wiped and reset) when this process it out
  375. * allocating memory. In those cases, it reverts back to the fast
  376. * path.
  377. *
  378. * Note that this function may actually fail to insert the block if
  379. * memory cannot be allocated. This is not fatal however (but may
  380. * result in a performance penalty)
  381. *
  382. * Readahead buffers can be passed in here before the I/O request is
  383. * completed.
  384. */
  385. void ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci,
  386. struct buffer_head *bh)
  387. {
  388. int expand;
  389. /* The block may very well exist in our cache already, so avoid
  390. * doing any more work in that case. */
  391. if (ocfs2_buffer_cached(ci, bh))
  392. return;
  393. trace_ocfs2_set_buffer_uptodate_begin(
  394. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  395. (unsigned long long)bh->b_blocknr);
  396. /* No need to recheck under spinlock - insertion is guarded by
  397. * co_io_lock() */
  398. ocfs2_metadata_cache_lock(ci);
  399. if (ocfs2_insert_can_use_array(ci)) {
  400. /* Fast case - it's an array and there's a free
  401. * spot. */
  402. ocfs2_append_cache_array(ci, bh->b_blocknr);
  403. ocfs2_metadata_cache_unlock(ci);
  404. return;
  405. }
  406. expand = 0;
  407. if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) {
  408. /* We need to bump things up to a tree. */
  409. expand = 1;
  410. }
  411. ocfs2_metadata_cache_unlock(ci);
  412. __ocfs2_set_buffer_uptodate(ci, bh->b_blocknr, expand);
  413. }
  414. /* Called against a newly allocated buffer. Most likely nobody should
  415. * be able to read this sort of metadata while it's still being
  416. * allocated, but this is careful to take co_io_lock() anyway. */
  417. void ocfs2_set_new_buffer_uptodate(struct ocfs2_caching_info *ci,
  418. struct buffer_head *bh)
  419. {
  420. /* This should definitely *not* exist in our cache */
  421. BUG_ON(ocfs2_buffer_cached(ci, bh));
  422. set_buffer_uptodate(bh);
  423. ocfs2_metadata_cache_io_lock(ci);
  424. ocfs2_set_buffer_uptodate(ci, bh);
  425. ocfs2_metadata_cache_io_unlock(ci);
  426. }
  427. /* Requires ip_lock. */
  428. static void ocfs2_remove_metadata_array(struct ocfs2_caching_info *ci,
  429. int index)
  430. {
  431. sector_t *array = ci->ci_cache.ci_array;
  432. int bytes;
  433. BUG_ON(index < 0 || index >= OCFS2_CACHE_INFO_MAX_ARRAY);
  434. BUG_ON(index >= ci->ci_num_cached);
  435. BUG_ON(!ci->ci_num_cached);
  436. trace_ocfs2_remove_metadata_array(
  437. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  438. index, ci->ci_num_cached);
  439. ci->ci_num_cached--;
  440. /* don't need to copy if the array is now empty, or if we
  441. * removed at the tail */
  442. if (ci->ci_num_cached && index < ci->ci_num_cached) {
  443. bytes = sizeof(sector_t) * (ci->ci_num_cached - index);
  444. memmove(&array[index], &array[index + 1], bytes);
  445. }
  446. }
  447. /* Requires ip_lock. */
  448. static void ocfs2_remove_metadata_tree(struct ocfs2_caching_info *ci,
  449. struct ocfs2_meta_cache_item *item)
  450. {
  451. trace_ocfs2_remove_metadata_tree(
  452. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  453. (unsigned long long)item->c_block);
  454. rb_erase(&item->c_node, &ci->ci_cache.ci_tree);
  455. ci->ci_num_cached--;
  456. }
  457. static void ocfs2_remove_block_from_cache(struct ocfs2_caching_info *ci,
  458. sector_t block)
  459. {
  460. int index;
  461. struct ocfs2_meta_cache_item *item = NULL;
  462. ocfs2_metadata_cache_lock(ci);
  463. trace_ocfs2_remove_block_from_cache(
  464. (unsigned long long)ocfs2_metadata_cache_owner(ci),
  465. (unsigned long long) block, ci->ci_num_cached,
  466. ci->ci_flags);
  467. if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) {
  468. index = ocfs2_search_cache_array(ci, block);
  469. if (index != -1)
  470. ocfs2_remove_metadata_array(ci, index);
  471. } else {
  472. item = ocfs2_search_cache_tree(ci, block);
  473. if (item)
  474. ocfs2_remove_metadata_tree(ci, item);
  475. }
  476. ocfs2_metadata_cache_unlock(ci);
  477. if (item)
  478. kmem_cache_free(ocfs2_uptodate_cachep, item);
  479. }
  480. /*
  481. * Called when we remove a chunk of metadata from an inode. We don't
  482. * bother reverting things to an inlined array in the case of a remove
  483. * which moves us back under the limit.
  484. */
  485. void ocfs2_remove_from_cache(struct ocfs2_caching_info *ci,
  486. struct buffer_head *bh)
  487. {
  488. sector_t block = bh->b_blocknr;
  489. ocfs2_remove_block_from_cache(ci, block);
  490. }
  491. /* Called when we remove xattr clusters from an inode. */
  492. void ocfs2_remove_xattr_clusters_from_cache(struct ocfs2_caching_info *ci,
  493. sector_t block,
  494. u32 c_len)
  495. {
  496. struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
  497. unsigned int i, b_len = ocfs2_clusters_to_blocks(sb, 1) * c_len;
  498. for (i = 0; i < b_len; i++, block++)
  499. ocfs2_remove_block_from_cache(ci, block);
  500. }
  501. int __init init_ocfs2_uptodate_cache(void)
  502. {
  503. ocfs2_uptodate_cachep = kmem_cache_create("ocfs2_uptodate",
  504. sizeof(struct ocfs2_meta_cache_item),
  505. 0, SLAB_HWCACHE_ALIGN, NULL);
  506. if (!ocfs2_uptodate_cachep)
  507. return -ENOMEM;
  508. return 0;
  509. }
  510. void exit_ocfs2_uptodate_cache(void)
  511. {
  512. kmem_cache_destroy(ocfs2_uptodate_cachep);
  513. }