uptodate.c 17 KB

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