Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2006-2007 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_MRU_CACHE_H__ |
| 7 | #define __XFS_MRU_CACHE_H__ |
| 8 | |
Christoph Hellwig | 22328d71 | 2014-04-23 07:11:51 +1000 | [diff] [blame] | 9 | struct xfs_mru_cache; |
| 10 | |
| 11 | struct xfs_mru_cache_elem { |
| 12 | struct list_head list_node; |
| 13 | unsigned long key; |
| 14 | }; |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 15 | |
| 16 | /* Function pointer type for callback to free a client's data pointer. */ |
Christoph Hellwig | 7fcd3ef | 2018-04-09 10:23:39 -0700 | [diff] [blame] | 17 | typedef void (*xfs_mru_cache_free_func_t)(void *, struct xfs_mru_cache_elem *); |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 18 | |
| 19 | int xfs_mru_cache_init(void); |
| 20 | void xfs_mru_cache_uninit(void); |
Christoph Hellwig | 7fcd3ef | 2018-04-09 10:23:39 -0700 | [diff] [blame] | 21 | int xfs_mru_cache_create(struct xfs_mru_cache **mrup, void *data, |
| 22 | unsigned int lifetime_ms, unsigned int grp_count, |
| 23 | xfs_mru_cache_free_func_t free_func); |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 24 | void xfs_mru_cache_destroy(struct xfs_mru_cache *mru); |
| 25 | int xfs_mru_cache_insert(struct xfs_mru_cache *mru, unsigned long key, |
Christoph Hellwig | 22328d71 | 2014-04-23 07:11:51 +1000 | [diff] [blame] | 26 | struct xfs_mru_cache_elem *elem); |
| 27 | struct xfs_mru_cache_elem * |
| 28 | xfs_mru_cache_remove(struct xfs_mru_cache *mru, unsigned long key); |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 29 | void xfs_mru_cache_delete(struct xfs_mru_cache *mru, unsigned long key); |
Christoph Hellwig | 22328d71 | 2014-04-23 07:11:51 +1000 | [diff] [blame] | 30 | struct xfs_mru_cache_elem * |
| 31 | xfs_mru_cache_lookup(struct xfs_mru_cache *mru, unsigned long key); |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 32 | void xfs_mru_cache_done(struct xfs_mru_cache *mru); |
| 33 | |
| 34 | #endif /* __XFS_MRU_CACHE_H__ */ |