blob: fb5245ba5ff744990978b1b69885cc7903698858 [file] [log] [blame]
David Chinner2a82b8b2007-07-11 11:09:12 +10001/*
2 * Copyright (c) 2006-2007 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef __XFS_MRU_CACHE_H__
19#define __XFS_MRU_CACHE_H__
20
Christoph Hellwig22328d72014-04-23 07:11:51 +100021struct xfs_mru_cache;
22
23struct xfs_mru_cache_elem {
24 struct list_head list_node;
25 unsigned long key;
26};
David Chinner2a82b8b2007-07-11 11:09:12 +100027
28/* Function pointer type for callback to free a client's data pointer. */
Christoph Hellwig22328d72014-04-23 07:11:51 +100029typedef void (*xfs_mru_cache_free_func_t)(struct xfs_mru_cache_elem *elem);
David Chinner2a82b8b2007-07-11 11:09:12 +100030
31int xfs_mru_cache_init(void);
32void xfs_mru_cache_uninit(void);
33int xfs_mru_cache_create(struct xfs_mru_cache **mrup, unsigned int lifetime_ms,
34 unsigned int grp_count,
35 xfs_mru_cache_free_func_t free_func);
David Chinner2a82b8b2007-07-11 11:09:12 +100036void xfs_mru_cache_destroy(struct xfs_mru_cache *mru);
37int xfs_mru_cache_insert(struct xfs_mru_cache *mru, unsigned long key,
Christoph Hellwig22328d72014-04-23 07:11:51 +100038 struct xfs_mru_cache_elem *elem);
39struct xfs_mru_cache_elem *
40xfs_mru_cache_remove(struct xfs_mru_cache *mru, unsigned long key);
David Chinner2a82b8b2007-07-11 11:09:12 +100041void xfs_mru_cache_delete(struct xfs_mru_cache *mru, unsigned long key);
Christoph Hellwig22328d72014-04-23 07:11:51 +100042struct xfs_mru_cache_elem *
43xfs_mru_cache_lookup(struct xfs_mru_cache *mru, unsigned long key);
David Chinner2a82b8b2007-07-11 11:09:12 +100044void xfs_mru_cache_done(struct xfs_mru_cache *mru);
45
46#endif /* __XFS_MRU_CACHE_H__ */