BTRFS: Node now holding Volume instead of cache to retrieve more values

Signed-off-by: Augustin Cavalier <[email protected]>
This commit is contained in:
hyche
2017-12-10 10:56:10 -05:00
committed by Augustin Cavalier
parent 16de9db54b
commit 8160f31fc1
2 changed files with 14 additions and 14 deletions
+11 -11
View File
@@ -20,10 +20,10 @@
# define ERROR(x...) dprintf("\33[34mbtrfs:\33[0m " x) # define ERROR(x...) dprintf("\33[34mbtrfs:\33[0m " x)
BTree::Node::Node(void* cache) BTree::Node::Node(Volume* volume)
: :
fNode(NULL), fNode(NULL),
fCache(cache), fVolume(volume),
fBlockNumber(0), fBlockNumber(0),
fCurrentSlot(0), fCurrentSlot(0),
fWritable(false) fWritable(false)
@@ -31,10 +31,10 @@ BTree::Node::Node(void* cache)
} }
BTree::Node::Node(void* cache, off_t block) BTree::Node::Node(Volume* volume, off_t block)
: :
fNode(NULL), fNode(NULL),
fCache(cache), fVolume(volume),
fBlockNumber(0), fBlockNumber(0),
fCurrentSlot(0), fCurrentSlot(0),
fWritable(false) fWritable(false)
@@ -59,7 +59,7 @@ void
BTree::Node::Unset() BTree::Node::Unset()
{ {
if (fNode != NULL) { if (fNode != NULL) {
block_cache_put(fCache, fBlockNumber); block_cache_put(fVolume->BlockCache(), fBlockNumber);
fNode = NULL; fNode = NULL;
} }
} }
@@ -70,7 +70,7 @@ BTree::Node::SetTo(off_t block)
{ {
Unset(); Unset();
fBlockNumber = block; fBlockNumber = block;
fNode = (btrfs_stream*)block_cache_get(fCache, block); fNode = (btrfs_stream*)block_cache_get(fVolume->BlockCache(), block);
} }
@@ -81,11 +81,11 @@ BTree::Node::SetToWritable(off_t block, int32 transactionId, bool empty)
fBlockNumber = block; fBlockNumber = block;
fWritable = true; fWritable = true;
if (empty) { if (empty) {
fNode = (btrfs_stream*)block_cache_get_empty(fCache, block, fNode = (btrfs_stream*)block_cache_get_empty(fVolume->BlockCache(),
transactionId); block, transactionId);
} else { } else {
fNode = (btrfs_stream*)block_cache_get_writable(fCache, block, fNode = (btrfs_stream*)block_cache_get_writable(fVolume->BlockCache(),
transactionId); block, transactionId);
} }
} }
@@ -217,7 +217,7 @@ BTree::_Find(btrfs_key& key, void** _value, uint32* _size,
{ {
TRACE("Find() objectid %" B_PRId64 " type %d offset %" B_PRId64 " \n", TRACE("Find() objectid %" B_PRId64 " type %d offset %" B_PRId64 " \n",
key.ObjectID(), key.Type(), key.Offset()); key.ObjectID(), key.Type(), key.Offset());
BTree::Node node(fVolume->BlockCache(), fRootBlock); BTree::Node node(fVolume, fRootBlock);
int slot, ret; int slot, ret;
fsblock_t physicalBlock; fsblock_t physicalBlock;
@@ -83,8 +83,8 @@ private:
public: public:
class Node { class Node {
public: public:
Node(void* cache); Node(Volume* volume);
Node(void* cache, off_t block); Node(Volume* volume, off_t block);
~Node(); ~Node();
// just return from Header // just return from Header
@@ -127,7 +127,7 @@ public:
//no implementation //no implementation
btrfs_stream* fNode; btrfs_stream* fNode;
void* fCache; Volume* fVolume;
off_t fBlockNumber; off_t fBlockNumber;
uint32 fCurrentSlot; uint32 fCurrentSlot;
bool fWritable; bool fWritable;