blob: f1fde1ecf730f7fdb7c010cc4102bb98ba0a023d [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
David Chinner2a82b8b2007-07-11 11:09:12 +10002/*
3 * Copyright (c) 2006-2007 Silicon Graphics, Inc.
4 * All Rights Reserved.
David Chinner2a82b8b2007-07-11 11:09:12 +10005 */
6#ifndef __XFS_MRU_CACHE_H__
7#define __XFS_MRU_CACHE_H__
8
Christoph Hellwig22328d712014-04-23 07:11:51 +10009struct xfs_mru_cache;
10
11struct xfs_mru_cache_elem {
12 struct list_head list_node;
13 unsigned long key;
14};
David Chinner2a82b8b2007-07-11 11:09:12 +100015
16/* Function pointer type for callback to free a client's data pointer. */
Christoph Hellwig7fcd3ef2018-04-09 10:23:39 -070017typedef void (*xfs_mru_cache_free_func_t)(void *, struct xfs_mru_cache_elem *);
David Chinner2a82b8b2007-07-11 11:09:12 +100018
19int xfs_mru_cache_init(void);
20void xfs_mru_cache_uninit(void);
Christoph Hellwig7fcd3ef2018-04-09 10:23:39 -070021int 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 Chinner2a82b8b2007-07-11 11:09:12 +100024void xfs_mru_cache_destroy(struct xfs_mru_cache *mru);
25int xfs_mru_cache_insert(struct xfs_mru_cache *mru, unsigned long key,
Christoph Hellwig22328d712014-04-23 07:11:51 +100026 struct xfs_mru_cache_elem *elem);
27struct xfs_mru_cache_elem *
28xfs_mru_cache_remove(struct xfs_mru_cache *mru, unsigned long key);
David Chinner2a82b8b2007-07-11 11:09:12 +100029void xfs_mru_cache_delete(struct xfs_mru_cache *mru, unsigned long key);
Christoph Hellwig22328d712014-04-23 07:11:51 +100030struct xfs_mru_cache_elem *
31xfs_mru_cache_lookup(struct xfs_mru_cache *mru, unsigned long key);
David Chinner2a82b8b2007-07-11 11:09:12 +100032void xfs_mru_cache_done(struct xfs_mru_cache *mru);
33
34#endif /* __XFS_MRU_CACHE_H__ */