#include <stdio.h>
#include <stdlib.h>
#include "kerncompat.h"
#include "radix-tree.h"
#include "ctree.h"
#include "disk-io.h"
#include "print-tree.h"
static int split_node(struct btrfs_root *root, struct btrfs_path *path,
int level);
static int split_leaf(struct btrfs_root *root, struct btrfs_path *path,
int data_size);
static int push_node_left(struct btrfs_root *root, struct btrfs_buffer *dst,
struct btrfs_buffer *src);
static int balance_node_right(struct btrfs_root *root,
struct btrfs_buffer *dst_buf,
struct btrfs_buffer *src_buf);
static int del_ptr(struct btrfs_root *root, struct btrfs_path *path, int level,
int slot);
inline void btrfs_init_path(struct btrfs_path *p)
{
memset(p, 0, sizeof(*p));
}
void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p)
{
int i;
for (i = 0; i < BTRFS_MAX_LEVEL; i++) {
if (!p->nodes[i])
break;
btrfs_block_release(root, p->nodes[i]);
}
memset(p, 0, sizeof(*p));
}
static int btrfs_cow_block(struct btrfs_root *root,
struct btrfs_buffer *buf,
struct btrfs_buffer