aboutsummaryrefslogtreecommitdiffstats
path: root/cache.c
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-05-11 16:47:51 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-05-11 16:47:51 +0800
commit0d701f8a814792f5db473d417648c2e5a9f6a20c (patch)
treea6ef6f1800fe043aa9a812714b5b7fb01946ba13 /cache.c
parentdcc79fb69015fd7aed1db14544b155969f4d1783 (diff)
downloaddevel-0d701f8a814792f5db473d417648c2e5a9f6a20c.tar.gz
devel-0d701f8a814792f5db473d417648c2e5a9f6a20c.tar.xz
devel-0d701f8a814792f5db473d417648c2e5a9f6a20c.zip
Make cache based on block size and fixed some bugs
well, it's a big change. 1st, make the caceh based on block but not sector 2nd, make the fast symlink check worked. 3rd, totally changed the linsector function. 4th, some little changes.
Diffstat (limited to 'cache.c')
-rw-r--r--cache.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/cache.c b/cache.c
index bfcdf29..6fdbd25 100644
--- a/cache.c
+++ b/cache.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include <stdio.h>
+#include <fcntl.h>
#include <malloc.h>
@@ -13,6 +14,7 @@
*/
struct cache_struct cache[CACHE_ENTRIES + 1] = {0,};
+extern int blk_size;
/**
* cache_init:
@@ -29,7 +31,7 @@ void cache_init(void)
prev = &cache[CACHE_ENTRIES];
for ( i = 0; i < CACHE_ENTRIES + 1; i++ ) {
- cur->sector = 0;
+ cur->block = 0;
cur->prev = prev;
prev->next = cur;
cur->data = NULL;
@@ -43,25 +45,25 @@ void cache_init(void)
/**
- * get_cache_sector:
+ * get_cache_block:
*
- * Check for a particular SECTOR in the sector cache,
+ * Check for a particular BLOCK in the block cache,
* and if it is already there, just do nothing and return;
* otherwise load it and updata the relative cache
* structre with data pointer.
*
- * @param: sector, the sector number we want check.
+ * @param: block, the block number we want check.
* @retrun: return the most recent cache structure pointer
*
*/
-struct cache_struct * get_cache_sector(int sector)
+struct cache_struct * get_cache_block(__u32 block)
{
struct cache_struct *cs = &cache[1];
struct cache_struct *head, *last;
int i;
for ( i = 0; i < CACHE_ENTRIES; i ++ ) {
- if ( cs->sector == sector )
+ if ( cs->block == block )
goto hit;
else
cs = &cache[i + 1];
@@ -69,14 +71,11 @@ struct cache_struct * get_cache_sector(int sector)
/* we missed it here, so we need to load it */
miss:
- /* free the first cache's buffer first */
- if ( cache[0].next->data)
- free(cache[0].next->data);
/* store it at head of real cache */
cs = cache[0].next;
- cs->sector = sector;
- cs->data = (void*)getonesec(sector);
+ cs->block = block;
+ cs->data = (void*)getoneblk(block);
hit:
/* remove cs from current position in list */