blockcache.c File Reference

#include <routix/device.h>
#include <routix/kalloc.h>
#include <routix/kstdio.h>
#include <routix/task.h>
#include <routix/system.h>
#include <fs/blockcache.h>
#include <sys/list.h>
#include <routix/atomic.h>

Go to the source code of this file.

Defines

Functions


Define Documentation

#define HASH maxhash,
dev,
sector   )     ( (dev+sector)%maxhash )
 

Definition at line 30 of file blockcache.c.

Referenced by cache_read().

#define HASH_DEVICE dev   )     (dev)
 

Definition at line 31 of file blockcache.c.

Referenced by endrequest(), getrequest(), and sendrequest().

#define MAKE_MULTIPLE original,
multiple   )     ((original)+((multiple)-(original)%(multiple)))
 

Definition at line 33 of file blockcache.c.

#define MAX_BLOCKCACHE_MEM   5
 

#define MAXHASHENTRIES   10
 

Definition at line 29 of file blockcache.c.

Referenced by cache_read(), LIST_NEW(), and show_cached_list().

#define PAGE_SIZE   4096
 

Definition at line 27 of file blockcache.c.

Referenced by alloc_block(), and alloc_header().

#define RUNSTATS   1
 

Definition at line 24 of file blockcache.c.


Function Documentation

byte* alloc_block  )  [inline, static]
 

Definition at line 124 of file blockcache.c.

block_cache_t* alloc_header  )  [inline, static]
 

Definition at line 138 of file blockcache.c.

int cache_read device_t  device,
word  sector,
unsigned int  start,
char *  dstbuffer,
unsigned int  len
 

Es la encargada de realizar una lectura desde el cache de bloques y en caso de no poseer dicha solicitud genera la petición al dispositivo correspondiente.

Parameters:
device dispositivo sobre el que se desea leer el sector (ver routix/device.h)
sector sector lógico a leer
start offset desde donde se desea leer el sector
bufferdst puntero a donde debe copiarse la información solicitada por el proceso
len largo a leer
Algorithm: function: cache_read(device,sector,start,bufferdst,len) restart: START ATOMIC OPERATION find (dev,sector) in cached_list if found { if ( WRITE_LOCKED or SYNCRONIZING ) { put this process in the list of io pending processes sleep process FINISH ATOMIC OPERATION reschedule goto restart } increment the lock count for this block if ( UNLOCKED ) { mark it READ_LOCKED quit block from free list } } else { get a free block (via getfreeblock) mark it SYNCRONIZING set it device, sector and operation (IOREAD in this case) insert it into cached list insert process into io processes pending list send request to driver sleep process FINISH ATOMIC OPERATION reschedule START ATOMIC OPERATION quit this process from io processes pending list wake up all other process waiting for this block clean io pending list if request has fail { remove from cached list add block to front of free list FINISH ATOMIC OPERATION return ERROR } mark it READ_LOCKED increment the lock count for this block } FINISH ATOMIC OPERATION copy data to buffer START ATOMIC OPERATION decrement lock count if ( lock count is 0 ) { mark block UNLOCKED put block in TAIL of the free list (LRU) wake up all other process waiting for this block (they wait for write on it) clean io pending list } FINISH ATOMIC OPERATION return SUCCESS

Definition at line 287 of file blockcache.c.

Referenced by read(), and sys_read_debug().

void endrequest block_cache_t block  )  [inline]
 

Definition at line 162 of file blockcache.c.

Referenced by error(), and leer_escribir_new().

block_cache_t* getfreeblock void   )  [inline, static]
 

Obtiene un bloque libre de la lista de bloques libres, debe tenerse en consideración si el bloque esta marcado como DIRTY (modificado en memoria y no en disco), por lo que debe realizarse una solicitud de escritura al device y buscar el siguiente hasta encontrar uno libre.

Algorithm: function: getfreeblock() do { get first block from free list quit from free list if block is marked as DIRTY { send asynchronous write request (that is manage by kernel) } } while ( not found free block ) return free block

Todo:
Agregado de manejo de envio de escritura asincrónica en caso de obtener un bloque marcado como DIRTY (modificado)

Definition at line 562 of file blockcache.c.

Referenced by cache_read().

block_cache_t* getrequest device_t  device  )  [inline]
 

Definition at line 154 of file blockcache.c.

Referenced by floppy_procesar_buffer().

LIST_NEW block_cache_t   )  [static]
 

Definition at line 36 of file blockcache.c.

void sendrequest block_cache_t block  )  [inline]
 

es la encargada de insertar la solicitud al driver correspondiente

Parameters:
el bloque solicitado (de tipo block_cache_t)

Definition at line 176 of file blockcache.c.

Referenced by cache_read().

void show_cached_list void   )  [static]
 

Definition at line 592 of file blockcache.c.

Referenced by cache_read().


Generated on Sun May 30 18:38:36 2004 for Routix OS by doxygen 1.3.6