diff options
author | Christoph Hellwig <hch@lst.de> | 2014-04-22 17:11:51 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-04-22 17:11:51 -0400 |
commit | 22328d712dd7fdc984d17da2121be840d1f844cd (patch) | |
tree | 678de2634238b10bfcbf72f1ded34faee9919f32 /fs/xfs/xfs_mru_cache.h | |
parent | ce695c6551f9488e75247ac1eefcd173fda0c029 (diff) |
xfs: embedd mru_elem into parent structure
There is no need to do a separate allocation for each mru element, just
embedd the structure into the parent one in the user. Besides saving
a memory allocation and the infrastructure required for it this also
simplifies the API.
While we do major surgery on xfs_mru_cache.c also de-typedef it and
make struct mru_cache private to the implementation file.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_mru_cache.h')
-rw-r--r-- | fs/xfs/xfs_mru_cache.h | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/fs/xfs/xfs_mru_cache.h b/fs/xfs/xfs_mru_cache.h index 36dd3ec8b4eb..fb5245ba5ff7 100644 --- a/fs/xfs/xfs_mru_cache.h +++ b/fs/xfs/xfs_mru_cache.h | |||
@@ -18,24 +18,15 @@ | |||
18 | #ifndef __XFS_MRU_CACHE_H__ | 18 | #ifndef __XFS_MRU_CACHE_H__ |
19 | #define __XFS_MRU_CACHE_H__ | 19 | #define __XFS_MRU_CACHE_H__ |
20 | 20 | ||
21 | struct xfs_mru_cache; | ||
21 | 22 | ||
22 | /* Function pointer type for callback to free a client's data pointer. */ | 23 | struct xfs_mru_cache_elem { |
23 | typedef void (*xfs_mru_cache_free_func_t)(unsigned long, void*); | 24 | struct list_head list_node; |
25 | unsigned long key; | ||
26 | }; | ||
24 | 27 | ||
25 | typedef struct xfs_mru_cache | 28 | /* Function pointer type for callback to free a client's data pointer. */ |
26 | { | 29 | typedef void (*xfs_mru_cache_free_func_t)(struct xfs_mru_cache_elem *elem); |
27 | struct radix_tree_root store; /* Core storage data structure. */ | ||
28 | struct list_head *lists; /* Array of lists, one per grp. */ | ||
29 | struct list_head reap_list; /* Elements overdue for reaping. */ | ||
30 | spinlock_t lock; /* Lock to protect this struct. */ | ||
31 | unsigned int grp_count; /* Number of discrete groups. */ | ||
32 | unsigned int grp_time; /* Time period spanned by grps. */ | ||
33 | unsigned int lru_grp; /* Group containing time zero. */ | ||
34 | unsigned long time_zero; /* Time first element was added. */ | ||
35 | xfs_mru_cache_free_func_t free_func; /* Function pointer for freeing. */ | ||
36 | struct delayed_work work; /* Workqueue data for reaping. */ | ||
37 | unsigned int queued; /* work has been queued */ | ||
38 | } xfs_mru_cache_t; | ||
39 | 30 | ||
40 | int xfs_mru_cache_init(void); | 31 | int xfs_mru_cache_init(void); |
41 | void xfs_mru_cache_uninit(void); | 32 | void xfs_mru_cache_uninit(void); |
@@ -44,10 +35,12 @@ int xfs_mru_cache_create(struct xfs_mru_cache **mrup, unsigned int lifetime_ms, | |||
44 | xfs_mru_cache_free_func_t free_func); | 35 | xfs_mru_cache_free_func_t free_func); |
45 | void xfs_mru_cache_destroy(struct xfs_mru_cache *mru); | 36 | void xfs_mru_cache_destroy(struct xfs_mru_cache *mru); |
46 | int xfs_mru_cache_insert(struct xfs_mru_cache *mru, unsigned long key, | 37 | int xfs_mru_cache_insert(struct xfs_mru_cache *mru, unsigned long key, |
47 | void *value); | 38 | struct xfs_mru_cache_elem *elem); |
48 | void * xfs_mru_cache_remove(struct xfs_mru_cache *mru, unsigned long key); | 39 | struct xfs_mru_cache_elem * |
40 | xfs_mru_cache_remove(struct xfs_mru_cache *mru, unsigned long key); | ||
49 | void xfs_mru_cache_delete(struct xfs_mru_cache *mru, unsigned long key); | 41 | void xfs_mru_cache_delete(struct xfs_mru_cache *mru, unsigned long key); |
50 | void *xfs_mru_cache_lookup(struct xfs_mru_cache *mru, unsigned long key); | 42 | struct xfs_mru_cache_elem * |
43 | xfs_mru_cache_lookup(struct xfs_mru_cache *mru, unsigned long key); | ||
51 | void xfs_mru_cache_done(struct xfs_mru_cache *mru); | 44 | void xfs_mru_cache_done(struct xfs_mru_cache *mru); |
52 | 45 | ||
53 | #endif /* __XFS_MRU_CACHE_H__ */ | 46 | #endif /* __XFS_MRU_CACHE_H__ */ |