SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

001 /* Copyright (C) 2005,2006      David Decotigny
002 
003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any later version.
007 
008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details.
012 
013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA.
017 */
018 #ifndef _SOS_BLKCACHE_H_
019 #define _SOS_BLKCACHE_H_
020 
021 
022 /**
023  * @file blkcache.h
024  *
025  * Simple block cache interface. This implementation is based on a
026  * fixed-size block cache, the size being set at construction time.
027  */
028 #include <sos/errno.h>
029 #include <sos/blkdev.h>
030 
031 
032 /** Opaque structure holding a cache */
033 struct sos_block_cache;
034 
035 /** Opaque structure holding a cache entry (used as a cookie from
036     blkcache_retrieve to blkcache_release) */
037 struct sos_block_cache_entry;
038 
039 
040 sos_ret_t sos_blkcache_subsystem_setup(void);
041 
042 
043 /** Create a new block cache */
044 struct sos_block_cache *
045 sos_blkcache_new_cache(void * blockdev_instance_custom_data,
046                        sos_size_t  block_size,
047                        sos_count_t cache_size_in_blocks,
048                        struct sos_blockdev_operations * blockdev_ops);
049 
050 
051 /** Delete a block cache */
052 sos_ret_t
053 sos_blkcache_delete_cache(struct sos_block_cache * bc);
054 
055 
056 /**
057  * "Write-only" cached blocks are expected to be *completely*
058  * overwritten by the blkdev code
059  */
060 typedef enum { SOS_BLKCACHE_READ_ONLY  = 0x4242,
061                SOS_BLKCACHE_READ_WRITE = 0x2442,
062                SOS_BLKCACHE_WRITE_ONLY = 0x4224 } sos_blkcache_access_type_t;
063 
064 
065 /**
066  * Retrieve a block from the cache
067  *  @param block_contents is filled with the address of the kernel
068  *    buffer holding the data
069  *  @return opaque structure used by release_block, or NULL when the
070  *    block could not be retrieved from disk
071  *
072  * @note once used and/or modified, the block must be released.
073  */
074 struct sos_block_cache_entry *
075 sos_blkcache_retrieve_block(struct sos_block_cache * bc,
076                             sos_luoffset_t block_index,
077                             sos_blkcache_access_type_t access_type,
078                             sos_vaddr_t */*out*/ block_contents);
079 
080 
081 /**
082  * Unreference a block previously retrieved. If is_dirty is TRUE, the
083  * block MUST have been retrieved with the "read_write" or
084  * "write_only" access type.
085  */
086 sos_ret_t
087 sos_blkcache_release_block(struct sos_block_cache * bc,
088                            struct sos_block_cache_entry * entry,
089                            sos_bool_t is_dirty,
090                            sos_bool_t force_flush);
091 
092 
093 /** Flush any modified blocks to disk */
094 sos_ret_t
095 sos_blkcache_flush(struct sos_block_cache * bc);
096 
097 #endif

source navigation ] diff markup ] identifier search ] general search ]