Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * NILFS B-tree.
0004  *
0005  * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
0006  *
0007  * Written by Koji Sato.
0008  */
0009 
0010 #ifndef _NILFS_BTREE_H
0011 #define _NILFS_BTREE_H
0012 
0013 #include <linux/types.h>
0014 #include <linux/buffer_head.h>
0015 #include <linux/list.h>
0016 #include <linux/nilfs2_ondisk.h>    /* nilfs_btree_node */
0017 #include "btnode.h"
0018 #include "bmap.h"
0019 
0020 /**
0021  * struct nilfs_btree_path - A path on which B-tree operations are executed
0022  * @bp_bh: buffer head of node block
0023  * @bp_sib_bh: buffer head of sibling node block
0024  * @bp_index: index of child node
0025  * @bp_oldreq: ptr end request for old ptr
0026  * @bp_newreq: ptr alloc request for new ptr
0027  * @bp_op: rebalance operation
0028  */
0029 struct nilfs_btree_path {
0030     struct buffer_head *bp_bh;
0031     struct buffer_head *bp_sib_bh;
0032     int bp_index;
0033     union nilfs_bmap_ptr_req bp_oldreq;
0034     union nilfs_bmap_ptr_req bp_newreq;
0035     struct nilfs_btnode_chkey_ctxt bp_ctxt;
0036     void (*bp_op)(struct nilfs_bmap *, struct nilfs_btree_path *,
0037               int, __u64 *, __u64 *);
0038 };
0039 
0040 #define NILFS_BTREE_ROOT_SIZE       NILFS_BMAP_SIZE
0041 #define NILFS_BTREE_ROOT_NCHILDREN_MAX                  \
0042     ((NILFS_BTREE_ROOT_SIZE - sizeof(struct nilfs_btree_node)) /    \
0043      (sizeof(__le64 /* dkey */) + sizeof(__le64 /* dptr */)))
0044 #define NILFS_BTREE_ROOT_NCHILDREN_MIN  0
0045 #define NILFS_BTREE_NODE_EXTRA_PAD_SIZE (sizeof(__le64))
0046 #define NILFS_BTREE_NODE_NCHILDREN_MAX(nodesize)            \
0047     (((nodesize) - sizeof(struct nilfs_btree_node) -        \
0048         NILFS_BTREE_NODE_EXTRA_PAD_SIZE) /          \
0049      (sizeof(__le64 /* dkey */) + sizeof(__le64 /* dptr */)))
0050 #define NILFS_BTREE_NODE_NCHILDREN_MIN(nodesize)            \
0051     ((NILFS_BTREE_NODE_NCHILDREN_MAX(nodesize) - 1) / 2 + 1)
0052 #define NILFS_BTREE_KEY_MIN ((__u64)0)
0053 #define NILFS_BTREE_KEY_MAX (~(__u64)0)
0054 
0055 extern struct kmem_cache *nilfs_btree_path_cache;
0056 
0057 int nilfs_btree_init(struct nilfs_bmap *);
0058 int nilfs_btree_convert_and_insert(struct nilfs_bmap *, __u64, __u64,
0059                    const __u64 *, const __u64 *, int);
0060 void nilfs_btree_init_gc(struct nilfs_bmap *);
0061 
0062 int nilfs_btree_broken_node_block(struct buffer_head *bh);
0063 
0064 #endif  /* _NILFS_BTREE_H */