mirror of
https://github.com/ksherlock/profuse.git
synced 2025-01-24 21:34:18 +00:00
git-svn-id: https://profuse.googlecode.com/svn/branches/v2@240 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
parent
d9bc18bdee
commit
e7b4c96984
@ -58,3 +58,18 @@ BlockCache *BlockCache::Create(BlockDevice *device)
|
||||
|
||||
return device->createBlockCache();
|
||||
}
|
||||
|
||||
|
||||
void BlockCache::zeroBlock(unsigned block)
|
||||
{
|
||||
/*
|
||||
void *address = acquire(block);
|
||||
std::memset(address, 0, 512);
|
||||
release(block, true);
|
||||
*/
|
||||
|
||||
uint8_t buffer[512];
|
||||
|
||||
std::memset(buffer, 0, 512);
|
||||
write(block, buffer);
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public:
|
||||
virtual void release(unsigned block, int flags) = 0 ;
|
||||
virtual void markDirty(unsigned block) = 0;
|
||||
|
||||
|
||||
virtual void zeroBlock(unsigned block);
|
||||
|
||||
void release(unsigned block) { release(block, 0); }
|
||||
void release(unsigned block, bool dirty)
|
||||
{
|
||||
|
@ -148,6 +148,8 @@ void ConcreteBlockCache::write(unsigned block, const void *bp)
|
||||
setLast(e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConcreteBlockCache::markDirty(unsigned block)
|
||||
{
|
||||
Entry *e = findEntry(block);
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
virtual void release(unsigned block, int flags);
|
||||
virtual void markDirty(unsigned block);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
struct Entry {
|
||||
|
@ -69,6 +69,14 @@ void MappedBlockCache::write(unsigned block, const void *vp)
|
||||
}
|
||||
|
||||
|
||||
void MappedBlockCache::zeroBlock(unsigned block)
|
||||
{
|
||||
_dirty = true;
|
||||
std::memset(_data + block * 512, 0, 512);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// sync everything.
|
||||
void MappedBlockCache::sync()
|
||||
{
|
||||
|
@ -14,6 +14,8 @@ class MappedBlockCache : public BlockCache {
|
||||
virtual void sync();
|
||||
virtual void write(unsigned block, const void *vp);
|
||||
|
||||
virtual void zeroBlock(unsigned block);
|
||||
|
||||
|
||||
virtual void *acquire(unsigned block);
|
||||
virtual void release(unsigned block, int flags);
|
||||
|
@ -78,6 +78,9 @@ class VolumeEntry : public Entry {
|
||||
|
||||
public:
|
||||
|
||||
static unsigned ValidName(const char *);
|
||||
|
||||
|
||||
// create new
|
||||
VolumeEntry(const char *name, Device::BlockDevice *);
|
||||
|
||||
@ -103,8 +106,8 @@ public:
|
||||
void readBlock(unsigned block, void *);
|
||||
void writeBlock(unsigned block, void *);
|
||||
|
||||
|
||||
unsigned static ValidName(const char *);
|
||||
void sync();
|
||||
|
||||
|
||||
protected:
|
||||
virtual void writeDirectoryEntry(LittleEndian::IOBuffer *);
|
||||
|
@ -77,9 +77,10 @@ VolumeEntry::VolumeEntry(const char *name, Device::BlockDevice *device)
|
||||
_cache = BlockCache::Create(device);
|
||||
_device = device;
|
||||
|
||||
|
||||
for (unsigned i = 2; i < 6; ++i)
|
||||
{
|
||||
device->zeroBlock(i);
|
||||
_cache->zeroBlock(i);
|
||||
}
|
||||
|
||||
void *vp = _cache->acquire(2);
|
||||
@ -89,6 +90,7 @@ VolumeEntry::VolumeEntry(const char *name, Device::BlockDevice *device)
|
||||
|
||||
_cache->release(2, true);
|
||||
|
||||
_cache->sync();
|
||||
}
|
||||
|
||||
|
||||
@ -216,6 +218,10 @@ void VolumeEntry::writeBlock(unsigned block, void *buffer)
|
||||
}
|
||||
|
||||
|
||||
void VolumeEntry::sync()
|
||||
{
|
||||
_cache->sync();
|
||||
}
|
||||
|
||||
void VolumeEntry::writeDirectoryEntry(IOBuffer *b)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user