* Fixed a bug in CachedBlock::Unset() that would call block_cache_put() on the same
block everytime it's called - that caused negative reference counts in the block cache, causing all sorts of problems once they were flushed. * Changed order of includes in system_dependencies.h to what I prefer: descending from private to public (resp. from most specific to most generic) headers. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21480 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
/* CachedBlock - interface for the block cache
|
/*
|
||||||
*
|
* Copyright 2001-2007, Axel Dörfler, [email protected].
|
||||||
* Copyright 2001-2004, Axel Dörfler, [email protected].
|
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef CACHED_BLOCK_H
|
#ifndef CACHED_BLOCK_H
|
||||||
#define CACHED_BLOCK_H
|
#define CACHED_BLOCK_H
|
||||||
|
|
||||||
|
//! interface for the block cache
|
||||||
|
|
||||||
|
|
||||||
#include "system_dependencies.h"
|
#include "system_dependencies.h"
|
||||||
|
|
||||||
@@ -35,9 +36,12 @@ class CachedBlock {
|
|||||||
inline const uint8 *SetTo(off_t block, off_t base, size_t length);
|
inline const uint8 *SetTo(off_t block, off_t base, size_t length);
|
||||||
inline const uint8 *SetTo(off_t block);
|
inline const uint8 *SetTo(off_t block);
|
||||||
inline const uint8 *SetTo(block_run run);
|
inline const uint8 *SetTo(block_run run);
|
||||||
inline uint8 *SetToWritable(Transaction &transaction, off_t block, off_t base, size_t length, bool empty = false);
|
inline uint8 *SetToWritable(Transaction &transaction, off_t block,
|
||||||
inline uint8 *SetToWritable(Transaction &transaction, off_t block, bool empty = false);
|
off_t base, size_t length, bool empty = false);
|
||||||
inline uint8 *SetToWritable(Transaction &transaction, block_run run, bool empty = false);
|
inline uint8 *SetToWritable(Transaction &transaction, off_t block,
|
||||||
|
bool empty = false);
|
||||||
|
inline uint8 *SetToWritable(Transaction &transaction, block_run run,
|
||||||
|
bool empty = false);
|
||||||
inline status_t MakeWritable(Transaction &transaction);
|
inline status_t MakeWritable(Transaction &transaction);
|
||||||
|
|
||||||
const uint8 *Block() const { return fBlock; }
|
const uint8 *Block() const { return fBlock; }
|
||||||
@@ -57,7 +61,6 @@ class CachedBlock {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------
|
|
||||||
// inlines
|
// inlines
|
||||||
|
|
||||||
|
|
||||||
@@ -121,8 +124,10 @@ CachedBlock::Keep()
|
|||||||
inline void
|
inline void
|
||||||
CachedBlock::Unset()
|
CachedBlock::Unset()
|
||||||
{
|
{
|
||||||
if (fBlock != NULL)
|
if (fBlock != NULL) {
|
||||||
block_cache_put(fVolume->BlockCache(), fBlockNumber);
|
block_cache_put(fVolume->BlockCache(), fBlockNumber);
|
||||||
|
fBlock = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -131,7 +136,8 @@ CachedBlock::SetTo(off_t block, off_t base, size_t length)
|
|||||||
{
|
{
|
||||||
Unset();
|
Unset();
|
||||||
fBlockNumber = block;
|
fBlockNumber = block;
|
||||||
return fBlock = (uint8 *)block_cache_get_etc(fVolume->BlockCache(), block, base, length);
|
return fBlock = (uint8 *)block_cache_get_etc(fVolume->BlockCache(),
|
||||||
|
block, base, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -150,16 +156,21 @@ CachedBlock::SetTo(block_run run)
|
|||||||
|
|
||||||
|
|
||||||
inline uint8 *
|
inline uint8 *
|
||||||
CachedBlock::SetToWritable(Transaction &transaction, off_t block, off_t base, size_t length, bool empty)
|
CachedBlock::SetToWritable(Transaction &transaction, off_t block, off_t base,
|
||||||
|
size_t length, bool empty)
|
||||||
{
|
{
|
||||||
Unset();
|
Unset();
|
||||||
fBlockNumber = block;
|
fBlockNumber = block;
|
||||||
|
|
||||||
if (empty)
|
if (empty) {
|
||||||
return fBlock = (uint8 *)block_cache_get_empty(fVolume->BlockCache(), block, transaction.ID());
|
fBlock = (uint8 *)block_cache_get_empty(fVolume->BlockCache(),
|
||||||
|
block, transaction.ID());
|
||||||
|
} else {
|
||||||
|
fBlock = (uint8 *)block_cache_get_writable_etc(fVolume->BlockCache(),
|
||||||
|
block, base, length, transaction.ID());
|
||||||
|
}
|
||||||
|
|
||||||
return fBlock = (uint8 *)block_cache_get_writable_etc(fVolume->BlockCache(),
|
return fBlock;
|
||||||
block, base, length, transaction.ID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,7 +194,8 @@ CachedBlock::MakeWritable(Transaction &transaction)
|
|||||||
if (fBlock == NULL)
|
if (fBlock == NULL)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|
||||||
return block_cache_make_writable(fVolume->BlockCache(), fBlockNumber, transaction.ID());
|
return block_cache_make_writable(fVolume->BlockCache(), fBlockNumber,
|
||||||
|
transaction.ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Copyright 2001-2007, Axel Dörfler, [email protected].
|
* Copyright 2001-2007, Axel Dörfler, [email protected].
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
* Copyright 2007, Ingo Weinhold, [email protected].
|
* Copyright 2007, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYSTEM_DEPENDENCIES_H
|
#ifndef _SYSTEM_DEPENDENCIES_H
|
||||||
#define _SYSTEM_DEPENDENCIES_H
|
#define _SYSTEM_DEPENDENCIES_H
|
||||||
|
|
||||||
@@ -13,6 +12,28 @@
|
|||||||
|
|
||||||
#else // !BFS_SHELL
|
#else // !BFS_SHELL
|
||||||
|
|
||||||
|
#include <util/DoublyLinkedList.h>
|
||||||
|
#include <util/kernel_cpp.h>
|
||||||
|
#include <util/Stack.h>
|
||||||
|
|
||||||
|
#include <ByteOrder.h>
|
||||||
|
|
||||||
|
#ifndef _BOOT_MODE
|
||||||
|
# include <driver_settings.h>
|
||||||
|
# include <fs_attr.h>
|
||||||
|
# include <fs_cache.h>
|
||||||
|
# include <fs_index.h>
|
||||||
|
# include <fs_info.h>
|
||||||
|
# include <fs_interface.h>
|
||||||
|
# include <fs_query.h>
|
||||||
|
# include <fs_volume.h>
|
||||||
|
# include <Drivers.h>
|
||||||
|
# include <KernelExport.h>
|
||||||
|
# include <NodeMonitor.h>
|
||||||
|
# include <SupportDefs.h>
|
||||||
|
# include <TypeConstants.h>
|
||||||
|
#endif // _BOOT_MODE
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <null.h>
|
#include <null.h>
|
||||||
@@ -22,28 +43,6 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <ByteOrder.h>
|
|
||||||
|
|
||||||
#ifndef _BOOT_MODE
|
|
||||||
#include <driver_settings.h>
|
|
||||||
#include <fs_attr.h>
|
|
||||||
#include <fs_cache.h>
|
|
||||||
#include <fs_index.h>
|
|
||||||
#include <fs_info.h>
|
|
||||||
#include <fs_interface.h>
|
|
||||||
#include <fs_query.h>
|
|
||||||
#include <fs_volume.h>
|
|
||||||
#include <Drivers.h>
|
|
||||||
#include <KernelExport.h>
|
|
||||||
#include <NodeMonitor.h>
|
|
||||||
#include <SupportDefs.h>
|
|
||||||
#include <TypeConstants.h>
|
|
||||||
#endif // _BOOT_MODE
|
|
||||||
|
|
||||||
#include <util/DoublyLinkedList.h>
|
|
||||||
#include <util/kernel_cpp.h>
|
|
||||||
#include <util/Stack.h>
|
|
||||||
|
|
||||||
#endif // !BFS_SHELL
|
#endif // !BFS_SHELL
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user