Move cache code to own file
[yaffs2.git] / yaffs_cache.h
1 /*
2  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2018 Aleph One Ltd.
5  *
6  * Created by Charles Manning <charles@aleph1.co.uk>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12
13 #ifndef __YAFFS_CACHE_H__
14 #define __YAFFS_CACHE_H__
15
16 #include "yaffs_guts.h"
17
18
19 /* Does the object have a dirty cache ? */
20 int yaffs_obj_cache_dirty(struct yaffs_obj *obj);
21
22 /* Flush the cache associated with a file, either discarding or keeping */
23 void yaffs_flush_file_cache(struct yaffs_obj *obj, int discard);
24
25 /* Flush everything in the cache, either discarding or keeping */
26 void yaffs_flush_whole_cache(struct yaffs_dev *dev, int discard);
27
28 /* Grab a cache item during read or write. */
29 struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev);
30
31 /* Find a cached chunk */
32 struct yaffs_cache *yaffs_find_chunk_cache(const struct yaffs_obj *obj,
33                                                   int chunk_id);
34
35 /* Mark the chunk for the least recently used algorithym */
36 void yaffs_use_cache(struct yaffs_dev *dev, struct yaffs_cache *cache,
37                             int is_write);
38
39
40 /* Invalidate a single cache page. The cache no longer holds valid data. */
41 void yaffs_invalidate_chunk_cache(struct yaffs_obj *object,
42                                          int chunk_id);
43
44 /* Invalidate all the cache pages associated with this object
45  * Do this whenever ther file is deleted or resized.
46  */
47 void yaffs_invalidate_file_cache(struct yaffs_obj *in);
48
49 /* Init/deinit. */
50 int yaffs_cache_init(struct yaffs_dev *dev);
51 void yaffs_cache_deinit(struct yaffs_dev *dev);
52
53 #endif