mbcache.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * linux/fs/mbcache.c
  3. * (C) 2001-2002 Andreas Gruenbacher, <a.gruenbacher@computer.org>
  4. */
  5. /*
  6. * Filesystem Meta Information Block Cache (mbcache)
  7. *
  8. * The mbcache caches blocks of block devices that need to be located
  9. * by their device/block number, as well as by other criteria (such
  10. * as the block's contents).
  11. *
  12. * There can only be one cache entry in a cache per device and block number.
  13. * Additional indexes need not be unique in this sense. The number of
  14. * additional indexes (=other criteria) can be hardwired at compile time
  15. * or specified at cache create time.
  16. *
  17. * Each cache entry is of fixed size. An entry may be `valid' or `invalid'
  18. * in the cache. A valid entry is in the main hash tables of the cache,
  19. * and may also be in the lru list. An invalid entry is not in any hashes
  20. * or lists.
  21. *
  22. * A valid cache entry is only in the lru list if no handles refer to it.
  23. * Invalid cache entries will be freed when the last handle to the cache
  24. * entry is released. Entries that cannot be freed immediately are put
  25. * back on the lru list.
  26. */
  27. #include <linux/kernel.h>
  28. #include <linux/module.h>
  29. #include <linux/hash.h>
  30. #include <linux/fs.h>
  31. #include <linux/mm.h>
  32. #include <linux/slab.h>
  33. #include <linux/sched.h>
  34. #include <linux/init.h>
  35. #include <linux/mbcache.h>
  36. #ifdef MB_CACHE_DEBUG
  37. # define mb_debug(f...) do { \
  38. printk(KERN_DEBUG f); \
  39. printk("\n"); \
  40. } while (0)
  41. #define mb_assert(c) do { if (!(c)) \
  42. printk(KERN_ERR "assertion " #c " failed\n"); \
  43. } while(0)
  44. #else
  45. # define mb_debug(f...) do { } while(0)
  46. # define mb_assert(c) do { } while(0)
  47. #endif
  48. #define mb_error(f...) do { \
  49. printk(KERN_ERR f); \
  50. printk("\n"); \
  51. } while(0)
  52. #define MB_CACHE_WRITER ((unsigned short)~0U >> 1)
  53. static DECLARE_WAIT_QUEUE_HEAD(mb_cache_queue);
  54. MODULE_AUTHOR("Andreas Gruenbacher <a.gruenbacher@computer.org>");
  55. MODULE_DESCRIPTION("Meta block cache (for extended attributes)");
  56. MODULE_LICENSE("GPL");
  57. EXPORT_SYMBOL(mb_cache_create);
  58. EXPORT_SYMBOL(mb_cache_shrink);
  59. EXPORT_SYMBOL(mb_cache_destroy);
  60. EXPORT_SYMBOL(mb_cache_entry_alloc);
  61. EXPORT_SYMBOL(mb_cache_entry_insert);
  62. EXPORT_SYMBOL(mb_cache_entry_release);
  63. EXPORT_SYMBOL(mb_cache_entry_free);
  64. EXPORT_SYMBOL(mb_cache_entry_get);
  65. #if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
  66. EXPORT_SYMBOL(mb_cache_entry_find_first);
  67. EXPORT_SYMBOL(mb_cache_entry_find_next);
  68. #endif
  69. struct mb_cache {
  70. struct list_head c_cache_list;
  71. const char *c_name;
  72. atomic_t c_entry_count;
  73. int c_max_entries;
  74. int c_bucket_bits;
  75. struct kmem_cache *c_entry_cache;
  76. struct list_head *c_block_hash;
  77. struct list_head *c_index_hash;
  78. };
  79. /*
  80. * Global data: list of all mbcache's, lru list, and a spinlock for
  81. * accessing cache data structures on SMP machines. The lru list is
  82. * global across all mbcaches.
  83. */
  84. static LIST_HEAD(mb_cache_list);
  85. static LIST_HEAD(mb_cache_lru_list);
  86. static DEFINE_SPINLOCK(mb_cache_spinlock);
  87. /*
  88. * What the mbcache registers as to get shrunk dynamically.
  89. */
  90. static int mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask);
  91. static struct shrinker mb_cache_shrinker = {
  92. .shrink = mb_cache_shrink_fn,
  93. .seeks = DEFAULT_SEEKS,
  94. };
  95. static inline int
  96. __mb_cache_entry_is_hashed(struct mb_cache_entry *ce)
  97. {
  98. return !list_empty(&ce->e_block_list);
  99. }
  100. static void
  101. __mb_cache_entry_unhash(struct mb_cache_entry *ce)
  102. {
  103. if (__mb_cache_entry_is_hashed(ce)) {
  104. list_del_init(&ce->e_block_list);
  105. list_del(&ce->e_index.o_list);
  106. }
  107. }
  108. static void
  109. __mb_cache_entry_forget(struct mb_cache_entry *ce, gfp_t gfp_mask)
  110. {
  111. struct mb_cache *cache = ce->e_cache;
  112. mb_assert(!(ce->e_used || ce->e_queued));
  113. kmem_cache_free(cache->c_entry_cache, ce);
  114. atomic_dec(&cache->c_entry_count);
  115. }
  116. static void
  117. __mb_cache_entry_release_unlock(struct mb_cache_entry *ce)
  118. __releases(mb_cache_spinlock)
  119. {
  120. /* Wake up all processes queuing for this cache entry. */
  121. if (ce->e_queued)
  122. wake_up_all(&mb_cache_queue);
  123. if (ce->e_used >= MB_CACHE_WRITER)
  124. ce->e_used -= MB_CACHE_WRITER;
  125. ce->e_used--;
  126. if (!(ce->e_used || ce->e_queued)) {
  127. if (!__mb_cache_entry_is_hashed(ce))
  128. goto forget;
  129. mb_assert(list_empty(&ce->e_lru_list));
  130. list_add_tail(&ce->e_lru_list, &mb_cache_lru_list);
  131. }
  132. spin_unlock(&mb_cache_spinlock);
  133. return;
  134. forget:
  135. spin_unlock(&mb_cache_spinlock);
  136. __mb_cache_entry_forget(ce, GFP_KERNEL);
  137. }
  138. /*
  139. * mb_cache_shrink_fn() memory pressure callback
  140. *
  141. * This function is called by the kernel memory management when memory
  142. * gets low.
  143. *
  144. * @shrink: (ignored)
  145. * @nr_to_scan: Number of objects to scan
  146. * @gfp_mask: (ignored)
  147. *
  148. * Returns the number of objects which are present in the cache.
  149. */
  150. static int
  151. mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
  152. {
  153. LIST_HEAD(free_list);
  154. struct mb_cache *cache;
  155. struct mb_cache_entry *entry, *tmp;
  156. int count = 0;
  157. mb_debug("trying to free %d entries", nr_to_scan);
  158. spin_lock(&mb_cache_spinlock);
  159. while (nr_to_scan-- && !list_empty(&mb_cache_lru_list)) {
  160. struct mb_cache_entry *ce =
  161. list_entry(mb_cache_lru_list.next,
  162. struct mb_cache_entry, e_lru_list);
  163. list_move_tail(&ce->e_lru_list, &free_list);
  164. __mb_cache_entry_unhash(ce);
  165. }
  166. list_for_each_entry(cache, &mb_cache_list, c_cache_list) {
  167. mb_debug("cache %s (%d)", cache->c_name,
  168. atomic_read(&cache->c_entry_count));
  169. count += atomic_read(&cache->c_entry_count);
  170. }
  171. spin_unlock(&mb_cache_spinlock);
  172. list_for_each_entry_safe(entry, tmp, &free_list, e_lru_list) {
  173. __mb_cache_entry_forget(entry, gfp_mask);
  174. }
  175. return (count / 100) * sysctl_vfs_cache_pressure;
  176. }
  177. /*
  178. * mb_cache_create() create a new cache
  179. *
  180. * All entries in one cache are equal size. Cache entries may be from
  181. * multiple devices. If this is the first mbcache created, registers
  182. * the cache with kernel memory management. Returns NULL if no more
  183. * memory was available.
  184. *
  185. * @name: name of the cache (informal)
  186. * @bucket_bits: log2(number of hash buckets)
  187. */
  188. struct mb_cache *
  189. mb_cache_create(const char *name, int bucket_bits)
  190. {
  191. int n, bucket_count = 1 << bucket_bits;
  192. struct mb_cache *cache = NULL;
  193. cache = kmalloc(sizeof(struct mb_cache), GFP_KERNEL);
  194. if (!cache)
  195. return NULL;
  196. cache->c_name = name;
  197. atomic_set(&cache->c_entry_count, 0);
  198. cache->c_bucket_bits = bucket_bits;
  199. cache->c_block_hash = kmalloc(bucket_count * sizeof(struct list_head),
  200. GFP_KERNEL);
  201. if (!cache->c_block_hash)
  202. goto fail;
  203. for (n=0; n<bucket_count; n++)
  204. INIT_LIST_HEAD(&cache->c_block_hash[n]);
  205. cache->c_index_hash = kmalloc(bucket_count * sizeof(struct list_head),
  206. GFP_KERNEL);
  207. if (!cache->c_index_hash)
  208. goto fail;
  209. for (n=0; n<bucket_count; n++)
  210. INIT_LIST_HEAD(&cache->c_index_hash[n]);
  211. cache->c_entry_cache = kmem_cache_create(name,
  212. sizeof(struct mb_cache_entry), 0,
  213. SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL);
  214. if (!cache->c_entry_cache)
  215. goto fail2;
  216. /*
  217. * Set an upper limit on the number of cache entries so that the hash
  218. * chains won't grow too long.
  219. */
  220. cache->c_max_entries = bucket_count << 4;
  221. spin_lock(&mb_cache_spinlock);
  222. list_add(&cache->c_cache_list, &mb_cache_list);
  223. spin_unlock(&mb_cache_spinlock);
  224. return cache;
  225. fail2:
  226. kfree(cache->c_index_hash);
  227. fail:
  228. kfree(cache->c_block_hash);
  229. kfree(cache);
  230. return NULL;
  231. }
  232. /*
  233. * mb_cache_shrink()
  234. *
  235. * Removes all cache entries of a device from the cache. All cache entries
  236. * currently in use cannot be freed, and thus remain in the cache. All others
  237. * are freed.
  238. *
  239. * @bdev: which device's cache entries to shrink
  240. */
  241. void
  242. mb_cache_shrink(struct block_device *bdev)
  243. {
  244. LIST_HEAD(free_list);
  245. struct list_head *l, *ltmp;
  246. spin_lock(&mb_cache_spinlock);
  247. list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
  248. struct mb_cache_entry *ce =
  249. list_entry(l, struct mb_cache_entry, e_lru_list);
  250. if (ce->e_bdev == bdev) {
  251. list_move_tail(&ce->e_lru_list, &free_list);
  252. __mb_cache_entry_unhash(ce);
  253. }
  254. }
  255. spin_unlock(&mb_cache_spinlock);
  256. list_for_each_safe(l, ltmp, &free_list) {
  257. __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
  258. e_lru_list), GFP_KERNEL);
  259. }
  260. }
  261. /*
  262. * mb_cache_destroy()
  263. *
  264. * Shrinks the cache to its minimum possible size (hopefully 0 entries),
  265. * and then destroys it. If this was the last mbcache, un-registers the
  266. * mbcache from kernel memory management.
  267. */
  268. void
  269. mb_cache_destroy(struct mb_cache *cache)
  270. {
  271. LIST_HEAD(free_list);
  272. struct list_head *l, *ltmp;
  273. spin_lock(&mb_cache_spinlock);
  274. list_for_each_safe(l, ltmp, &mb_cache_lru_list) {
  275. struct mb_cache_entry *ce =
  276. list_entry(l, struct mb_cache_entry, e_lru_list);
  277. if (ce->e_cache == cache) {
  278. list_move_tail(&ce->e_lru_list, &free_list);
  279. __mb_cache_entry_unhash(ce);
  280. }
  281. }
  282. list_del(&cache->c_cache_list);
  283. spin_unlock(&mb_cache_spinlock);
  284. list_for_each_safe(l, ltmp, &free_list) {
  285. __mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
  286. e_lru_list), GFP_KERNEL);
  287. }
  288. if (atomic_read(&cache->c_entry_count) > 0) {
  289. mb_error("cache %s: %d orphaned entries",
  290. cache->c_name,
  291. atomic_read(&cache->c_entry_count));
  292. }
  293. kmem_cache_destroy(cache->c_entry_cache);
  294. kfree(cache->c_index_hash);
  295. kfree(cache->c_block_hash);
  296. kfree(cache);
  297. }
  298. /*
  299. * mb_cache_entry_alloc()
  300. *
  301. * Allocates a new cache entry. The new entry will not be valid initially,
  302. * and thus cannot be looked up yet. It should be filled with data, and
  303. * then inserted into the cache using mb_cache_entry_insert(). Returns NULL
  304. * if no more memory was available.
  305. */
  306. struct mb_cache_entry *
  307. mb_cache_entry_alloc(struct mb_cache *cache, gfp_t gfp_flags)
  308. {
  309. struct mb_cache_entry *ce = NULL;
  310. if (atomic_read(&cache->c_entry_count) >= cache->c_max_entries) {
  311. spin_lock(&mb_cache_spinlock);
  312. if (!list_empty(&mb_cache_lru_list)) {
  313. ce = list_entry(mb_cache_lru_list.next,
  314. struct mb_cache_entry, e_lru_list);
  315. list_del_init(&ce->e_lru_list);
  316. __mb_cache_entry_unhash(ce);
  317. }
  318. spin_unlock(&mb_cache_spinlock);
  319. }
  320. if (!ce) {
  321. ce = kmem_cache_alloc(cache->c_entry_cache, gfp_flags);
  322. if (!ce)
  323. return NULL;
  324. atomic_inc(&cache->c_entry_count);
  325. INIT_LIST_HEAD(&ce->e_lru_list);
  326. INIT_LIST_HEAD(&ce->e_block_list);
  327. ce->e_cache = cache;
  328. ce->e_queued = 0;
  329. }
  330. ce->e_used = 1 + MB_CACHE_WRITER;
  331. return ce;
  332. }
  333. /*
  334. * mb_cache_entry_insert()
  335. *
  336. * Inserts an entry that was allocated using mb_cache_entry_alloc() into
  337. * the cache. After this, the cache entry can be looked up, but is not yet
  338. * in the lru list as the caller still holds a handle to it. Returns 0 on
  339. * success, or -EBUSY if a cache entry for that device + inode exists
  340. * already (this may happen after a failed lookup, but when another process
  341. * has inserted the same cache entry in the meantime).
  342. *
  343. * @bdev: device the cache entry belongs to
  344. * @block: block number
  345. * @key: lookup key
  346. */
  347. int
  348. mb_cache_entry_insert(struct mb_cache_entry *ce, struct block_device *bdev,
  349. sector_t block, unsigned int key)
  350. {
  351. struct mb_cache *cache = ce->e_cache;
  352. unsigned int bucket;
  353. struct list_head *l;
  354. int error = -EBUSY;
  355. bucket = hash_long((unsigned long)bdev + (block & 0xffffffff),
  356. cache->c_bucket_bits);
  357. spin_lock(&mb_cache_spinlock);
  358. list_for_each_prev(l, &cache->c_block_hash[bucket]) {
  359. struct mb_cache_entry *ce =
  360. list_entry(l, struct mb_cache_entry, e_block_list);
  361. if (ce->e_bdev == bdev && ce->e_block == block)
  362. goto out;
  363. }
  364. __mb_cache_entry_unhash(ce);
  365. ce->e_bdev = bdev;
  366. ce->e_block = block;
  367. list_add(&ce->e_block_list, &cache->c_block_hash[bucket]);
  368. ce->e_index.o_key = key;
  369. bucket = hash_long(key, cache->c_bucket_bits);
  370. list_add(&ce->e_index.o_list, &cache->c_index_hash[bucket]);
  371. error = 0;
  372. out:
  373. spin_unlock(&mb_cache_spinlock);
  374. return error;
  375. }
  376. /*
  377. * mb_cache_entry_release()
  378. *
  379. * Release a handle to a cache entry. When the last handle to a cache entry
  380. * is released it is either freed (if it is invalid) or otherwise inserted
  381. * in to the lru list.
  382. */
  383. void
  384. mb_cache_entry_release(struct mb_cache_entry *ce)
  385. {
  386. spin_lock(&mb_cache_spinlock);
  387. __mb_cache_entry_release_unlock(ce);
  388. }
  389. /*
  390. * mb_cache_entry_free()
  391. *
  392. * This is equivalent to the sequence mb_cache_entry_takeout() --
  393. * mb_cache_entry_release().
  394. */
  395. void
  396. mb_cache_entry_free(struct mb_cache_entry *ce)
  397. {
  398. spin_lock(&mb_cache_spinlock);
  399. mb_assert(list_empty(&ce->e_lru_list));
  400. __mb_cache_entry_unhash(ce);
  401. __mb_cache_entry_release_unlock(ce);
  402. }
  403. /*
  404. * mb_cache_entry_get()
  405. *
  406. * Get a cache entry by device / block number. (There can only be one entry
  407. * in the cache per device and block.) Returns NULL if no such cache entry
  408. * exists. The returned cache entry is locked for exclusive access ("single
  409. * writer").
  410. */
  411. struct mb_cache_entry *
  412. mb_cache_entry_get(struct mb_cache *cache, struct block_device *bdev,
  413. sector_t block)
  414. {
  415. unsigned int bucket;
  416. struct list_head *l;
  417. struct mb_cache_entry *ce;
  418. bucket = hash_long((unsigned long)bdev + (block & 0xffffffff),
  419. cache->c_bucket_bits);
  420. spin_lock(&mb_cache_spinlock);
  421. list_for_each(l, &cache->c_block_hash[bucket]) {
  422. ce = list_entry(l, struct mb_cache_entry, e_block_list);
  423. if (ce->e_bdev == bdev && ce->e_block == block) {
  424. DEFINE_WAIT(wait);
  425. if (!list_empty(&ce->e_lru_list))
  426. list_del_init(&ce->e_lru_list);
  427. while (ce->e_used > 0) {
  428. ce->e_queued++;
  429. prepare_to_wait(&mb_cache_queue, &wait,
  430. TASK_UNINTERRUPTIBLE);
  431. spin_unlock(&mb_cache_spinlock);
  432. schedule();
  433. spin_lock(&mb_cache_spinlock);
  434. ce->e_queued--;
  435. }
  436. finish_wait(&mb_cache_queue, &wait);
  437. ce->e_used += 1 + MB_CACHE_WRITER;
  438. if (!__mb_cache_entry_is_hashed(ce)) {
  439. __mb_cache_entry_release_unlock(ce);
  440. return NULL;
  441. }
  442. goto cleanup;
  443. }
  444. }
  445. ce = NULL;
  446. cleanup:
  447. spin_unlock(&mb_cache_spinlock);
  448. return ce;
  449. }
  450. #if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
  451. static struct mb_cache_entry *
  452. __mb_cache_entry_find(struct list_head *l, struct list_head *head,
  453. struct block_device *bdev, unsigned int key)
  454. {
  455. while (l != head) {
  456. struct mb_cache_entry *ce =
  457. list_entry(l, struct mb_cache_entry, e_index.o_list);
  458. if (ce->e_bdev == bdev && ce->e_index.o_key == key) {
  459. DEFINE_WAIT(wait);
  460. if (!list_empty(&ce->e_lru_list))
  461. list_del_init(&ce->e_lru_list);
  462. /* Incrementing before holding the lock gives readers
  463. priority over writers. */
  464. ce->e_used++;
  465. while (ce->e_used >= MB_CACHE_WRITER) {
  466. ce->e_queued++;
  467. prepare_to_wait(&mb_cache_queue, &wait,
  468. TASK_UNINTERRUPTIBLE);
  469. spin_unlock(&mb_cache_spinlock);
  470. schedule();
  471. spin_lock(&mb_cache_spinlock);
  472. ce->e_queued--;
  473. }
  474. finish_wait(&mb_cache_queue, &wait);
  475. if (!__mb_cache_entry_is_hashed(ce)) {
  476. __mb_cache_entry_release_unlock(ce);
  477. spin_lock(&mb_cache_spinlock);
  478. return ERR_PTR(-EAGAIN);
  479. }
  480. return ce;
  481. }
  482. l = l->next;
  483. }
  484. return NULL;
  485. }
  486. /*
  487. * mb_cache_entry_find_first()
  488. *
  489. * Find the first cache entry on a given device with a certain key in
  490. * an additional index. Additonal matches can be found with
  491. * mb_cache_entry_find_next(). Returns NULL if no match was found. The
  492. * returned cache entry is locked for shared access ("multiple readers").
  493. *
  494. * @cache: the cache to search
  495. * @bdev: the device the cache entry should belong to
  496. * @key: the key in the index
  497. */
  498. struct mb_cache_entry *
  499. mb_cache_entry_find_first(struct mb_cache *cache, struct block_device *bdev,
  500. unsigned int key)
  501. {
  502. unsigned int bucket = hash_long(key, cache->c_bucket_bits);
  503. struct list_head *l;
  504. struct mb_cache_entry *ce;
  505. spin_lock(&mb_cache_spinlock);
  506. l = cache->c_index_hash[bucket].next;
  507. ce = __mb_cache_entry_find(l, &cache->c_index_hash[bucket], bdev, key);
  508. spin_unlock(&mb_cache_spinlock);
  509. return ce;
  510. }
  511. /*
  512. * mb_cache_entry_find_next()
  513. *
  514. * Find the next cache entry on a given device with a certain key in an
  515. * additional index. Returns NULL if no match could be found. The previous
  516. * entry is atomatically released, so that mb_cache_entry_find_next() can
  517. * be called like this:
  518. *
  519. * entry = mb_cache_entry_find_first();
  520. * while (entry) {
  521. * ...
  522. * entry = mb_cache_entry_find_next(entry, ...);
  523. * }
  524. *
  525. * @prev: The previous match
  526. * @bdev: the device the cache entry should belong to
  527. * @key: the key in the index
  528. */
  529. struct mb_cache_entry *
  530. mb_cache_entry_find_next(struct mb_cache_entry *prev,
  531. struct block_device *bdev, unsigned int key)
  532. {
  533. struct mb_cache *cache = prev->e_cache;
  534. unsigned int bucket = hash_long(key, cache->c_bucket_bits);
  535. struct list_head *l;
  536. struct mb_cache_entry *ce;
  537. spin_lock(&mb_cache_spinlock);
  538. l = prev->e_index.o_list.next;
  539. ce = __mb_cache_entry_find(l, &cache->c_index_hash[bucket], bdev, key);
  540. __mb_cache_entry_release_unlock(prev);
  541. return ce;
  542. }
  543. #endif /* !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0) */
  544. static int __init init_mbcache(void)
  545. {
  546. register_shrinker(&mb_cache_shrinker);
  547. return 0;
  548. }
  549. static void __exit exit_mbcache(void)
  550. {
  551. unregister_shrinker(&mb_cache_shrinker);
  552. }
  553. module_init(init_mbcache)
  554. module_exit(exit_mbcache)