AFS: Documentation updates
[linux-2.6/mini2440.git] / fs / nilfs2 / btree.h
blob0e72bbbc6b648bb1a420f735fedaafe11b3d29ab
1 /*
2 * btree.h - NILFS B-tree.
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Written by Koji Sato <koji@osrg.net>.
23 #ifndef _NILFS_BTREE_H
24 #define _NILFS_BTREE_H
26 #include <linux/types.h>
27 #include <linux/buffer_head.h>
28 #include <linux/list.h>
29 #include <linux/nilfs2_fs.h>
30 #include "btnode.h"
31 #include "bmap.h"
33 struct nilfs_btree;
34 struct nilfs_btree_path;
36 /**
37 * struct nilfs_btree_node - B-tree node
38 * @bn_flags: flags
39 * @bn_level: level
40 * @bn_nchildren: number of children
41 * @bn_pad: padding
43 struct nilfs_btree_node {
44 __u8 bn_flags;
45 __u8 bn_level;
46 __le16 bn_nchildren;
47 __le32 bn_pad;
50 /* flags */
51 #define NILFS_BTREE_NODE_ROOT 0x01
53 /* level */
54 #define NILFS_BTREE_LEVEL_DATA 0
55 #define NILFS_BTREE_LEVEL_NODE_MIN (NILFS_BTREE_LEVEL_DATA + 1)
56 #define NILFS_BTREE_LEVEL_MAX 14
58 /**
59 * struct nilfs_btree - B-tree structure
60 * @bt_bmap: bmap base structure
62 struct nilfs_btree {
63 struct nilfs_bmap bt_bmap;
67 #define NILFS_BTREE_ROOT_SIZE NILFS_BMAP_SIZE
68 #define NILFS_BTREE_ROOT_NCHILDREN_MAX \
69 ((NILFS_BTREE_ROOT_SIZE - sizeof(struct nilfs_btree_node)) / \
70 (sizeof(__le64 /* dkey */) + sizeof(__le64 /* dptr */)))
71 #define NILFS_BTREE_ROOT_NCHILDREN_MIN 0
72 #define NILFS_BTREE_NODE_EXTRA_PAD_SIZE (sizeof(__le64))
73 #define NILFS_BTREE_NODE_NCHILDREN_MAX(nodesize) \
74 (((nodesize) - sizeof(struct nilfs_btree_node) - \
75 NILFS_BTREE_NODE_EXTRA_PAD_SIZE) / \
76 (sizeof(__le64 /* dkey */) + sizeof(__le64 /* dptr */)))
77 #define NILFS_BTREE_NODE_NCHILDREN_MIN(nodesize) \
78 ((NILFS_BTREE_NODE_NCHILDREN_MAX(nodesize) - 1) / 2 + 1)
79 #define NILFS_BTREE_KEY_MIN ((__u64)0)
80 #define NILFS_BTREE_KEY_MAX (~(__u64)0)
83 int nilfs_btree_path_cache_init(void);
84 void nilfs_btree_path_cache_destroy(void);
85 int nilfs_btree_init(struct nilfs_bmap *);
86 int nilfs_btree_convert_and_insert(struct nilfs_bmap *, __u64, __u64,
87 const __u64 *, const __u64 *, int);
88 void nilfs_btree_init_gc(struct nilfs_bmap *);
90 #endif /* _NILFS_BTREE_H */