39,10 → 39,9 |
|
#include <stdint.h> |
#include "../../srv/vfs/vfs.h" |
#include <futex.h> |
#include <rwlock.h> |
#include <libadt/hash_table.h> |
#include <libadt/list.h> |
#include <fibril_sync.h> |
#include <adt/hash_table.h> |
#include <adt/list.h> |
|
/* |
* Flags that can be used with block_get(). |
63,14 → 62,14 |
typedef unsigned bn_t; /**< Block number type. */ |
|
typedef struct block { |
/** Futex protecting the reference count. */ |
futex_t lock; |
/** Mutex protecting the reference count. */ |
fibril_mutex_t lock; |
/** Number of references to the block_t structure. */ |
unsigned refcnt; |
/** If true, the block needs to be written back to the block device. */ |
bool dirty; |
/** Readers / Writer lock protecting the contents of the block. */ |
rwlock_t contents_lock; |
fibril_rwlock_t contents_lock; |
/** Handle of the device where the block resides. */ |
dev_handle_t dev_handle; |
/** Block offset on the block device. Counted in 'size'-byte blocks. */ |
85,6 → 84,14 |
void *data; |
} block_t; |
|
/** Caching mode */ |
enum cache_mode { |
/** Write-Through */ |
CACHE_MODE_WT, |
/** Write-Back */ |
CACHE_MODE_WB |
}; |
|
extern int block_init(dev_handle_t, size_t); |
extern void block_fini(dev_handle_t); |
|
91,12 → 98,13 |
extern int block_bb_read(dev_handle_t, off_t, size_t); |
extern void *block_bb_get(dev_handle_t); |
|
extern int block_cache_init(dev_handle_t, size_t, unsigned); |
extern int block_cache_init(dev_handle_t, size_t, unsigned, enum cache_mode); |
|
extern block_t *block_get(dev_handle_t, bn_t, int flags); |
extern void block_put(block_t *); |
|
extern int block_read(int, off_t *, size_t *, off_t *, void *, size_t, size_t); |
extern int block_read(dev_handle_t, off_t *, size_t *, off_t *, void *, size_t, |
size_t); |
|
#endif |
|