2005-04-17 00:20:36 +02:00
|
|
|
/*
|
2005-11-02 04:58:39 +01:00
|
|
|
* Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
|
|
|
|
* All Rights Reserved.
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
2005-11-02 04:58:39 +01:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
2005-04-17 00:20:36 +02:00
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
2005-11-02 04:58:39 +01:00
|
|
|
* This program is distributed in the hope that it would be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
2005-11-02 04:58:39 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
#ifndef __XFS_BTREE_H__
|
|
|
|
#define __XFS_BTREE_H__
|
|
|
|
|
|
|
|
struct xfs_buf;
|
|
|
|
struct xfs_bmap_free;
|
|
|
|
struct xfs_inode;
|
|
|
|
struct xfs_mount;
|
|
|
|
struct xfs_trans;
|
|
|
|
|
2007-11-23 06:28:09 +01:00
|
|
|
extern kmem_zone_t *xfs_btree_cur_zone;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* This nonsense is to make -wlint happy.
|
|
|
|
*/
|
|
|
|
#define XFS_LOOKUP_EQ ((xfs_lookup_t)XFS_LOOKUP_EQi)
|
|
|
|
#define XFS_LOOKUP_LE ((xfs_lookup_t)XFS_LOOKUP_LEi)
|
|
|
|
#define XFS_LOOKUP_GE ((xfs_lookup_t)XFS_LOOKUP_GEi)
|
|
|
|
|
|
|
|
#define XFS_BTNUM_BNO ((xfs_btnum_t)XFS_BTNUM_BNOi)
|
|
|
|
#define XFS_BTNUM_CNT ((xfs_btnum_t)XFS_BTNUM_CNTi)
|
|
|
|
#define XFS_BTNUM_BMAP ((xfs_btnum_t)XFS_BTNUM_BMAPi)
|
|
|
|
#define XFS_BTNUM_INO ((xfs_btnum_t)XFS_BTNUM_INOi)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Short form header: space allocation btrees.
|
|
|
|
*/
|
2005-11-02 05:11:25 +01:00
|
|
|
typedef struct xfs_btree_sblock {
|
|
|
|
__be32 bb_magic; /* magic number for block type */
|
|
|
|
__be16 bb_level; /* 0 is a leaf */
|
|
|
|
__be16 bb_numrecs; /* current # of data records */
|
|
|
|
__be32 bb_leftsib; /* left sibling block or NULLAGBLOCK */
|
|
|
|
__be32 bb_rightsib; /* right sibling block or NULLAGBLOCK */
|
2005-04-17 00:20:36 +02:00
|
|
|
} xfs_btree_sblock_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Long form header: bmap btrees.
|
|
|
|
*/
|
2005-11-02 05:11:25 +01:00
|
|
|
typedef struct xfs_btree_lblock {
|
|
|
|
__be32 bb_magic; /* magic number for block type */
|
|
|
|
__be16 bb_level; /* 0 is a leaf */
|
|
|
|
__be16 bb_numrecs; /* current # of data records */
|
|
|
|
__be64 bb_leftsib; /* left sibling block or NULLDFSBNO */
|
|
|
|
__be64 bb_rightsib; /* right sibling block or NULLDFSBNO */
|
2005-04-17 00:20:36 +02:00
|
|
|
} xfs_btree_lblock_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Combined header and structure, used by common code.
|
|
|
|
*/
|
2008-10-30 06:53:47 +01:00
|
|
|
typedef struct xfs_btree_block {
|
2005-11-02 05:11:25 +01:00
|
|
|
__be32 bb_magic; /* magic number for block type */
|
|
|
|
__be16 bb_level; /* 0 is a leaf */
|
|
|
|
__be16 bb_numrecs; /* current # of data records */
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
__be32 bb_leftsib;
|
|
|
|
__be32 bb_rightsib;
|
|
|
|
} s; /* short form pointers */
|
2005-04-17 00:20:36 +02:00
|
|
|
struct {
|
2005-11-02 05:11:25 +01:00
|
|
|
__be64 bb_leftsib;
|
|
|
|
__be64 bb_rightsib;
|
|
|
|
} l; /* long form pointers */
|
|
|
|
} bb_u; /* rest */
|
2005-04-17 00:20:36 +02:00
|
|
|
} xfs_btree_block_t;
|
|
|
|
|
2008-10-30 06:54:12 +01:00
|
|
|
/*
|
|
|
|
* Generic key, ptr and record wrapper structures.
|
|
|
|
*
|
|
|
|
* These are disk format structures, and are converted where necessary
|
|
|
|
* by the btree specific code that needs to interpret them.
|
|
|
|
*/
|
|
|
|
union xfs_btree_ptr {
|
|
|
|
__be32 s; /* short form ptr */
|
|
|
|
__be64 l; /* long form ptr */
|
|
|
|
};
|
|
|
|
|
|
|
|
union xfs_btree_key {
|
|
|
|
xfs_bmbt_key_t bmbt;
|
|
|
|
xfs_bmdr_key_t bmbr; /* bmbt root block */
|
|
|
|
xfs_alloc_key_t alloc;
|
|
|
|
xfs_inobt_key_t inobt;
|
|
|
|
};
|
|
|
|
|
|
|
|
union xfs_btree_rec {
|
|
|
|
xfs_bmbt_rec_t bmbt;
|
|
|
|
xfs_bmdr_rec_t bmbr; /* bmbt root block */
|
|
|
|
xfs_alloc_rec_t alloc;
|
|
|
|
xfs_inobt_rec_t inobt;
|
|
|
|
};
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* For logging record fields.
|
|
|
|
*/
|
|
|
|
#define XFS_BB_MAGIC 0x01
|
|
|
|
#define XFS_BB_LEVEL 0x02
|
|
|
|
#define XFS_BB_NUMRECS 0x04
|
|
|
|
#define XFS_BB_LEFTSIB 0x08
|
|
|
|
#define XFS_BB_RIGHTSIB 0x10
|
|
|
|
#define XFS_BB_NUM_BITS 5
|
|
|
|
#define XFS_BB_ALL_BITS ((1 << XFS_BB_NUM_BITS) - 1)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Magic numbers for btree blocks.
|
|
|
|
*/
|
|
|
|
extern const __uint32_t xfs_magics[];
|
|
|
|
|
2008-10-30 06:55:03 +01:00
|
|
|
/*
|
|
|
|
* Generic stats interface
|
|
|
|
*/
|
|
|
|
#define __XFS_BTREE_STATS_INC(type, stat) \
|
|
|
|
XFS_STATS_INC(xs_ ## type ## _2_ ## stat)
|
|
|
|
#define XFS_BTREE_STATS_INC(cur, stat) \
|
|
|
|
do { \
|
|
|
|
switch (cur->bc_btnum) { \
|
|
|
|
case XFS_BTNUM_BNO: __XFS_BTREE_STATS_INC(abtb, stat); break; \
|
|
|
|
case XFS_BTNUM_CNT: __XFS_BTREE_STATS_INC(abtc, stat); break; \
|
|
|
|
case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_INC(bmbt, stat); break; \
|
|
|
|
case XFS_BTNUM_INO: __XFS_BTREE_STATS_INC(ibt, stat); break; \
|
|
|
|
case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define __XFS_BTREE_STATS_ADD(type, stat, val) \
|
|
|
|
XFS_STATS_ADD(xs_ ## type ## _2_ ## stat, val)
|
|
|
|
#define XFS_BTREE_STATS_ADD(cur, stat, val) \
|
|
|
|
do { \
|
|
|
|
switch (cur->bc_btnum) { \
|
|
|
|
case XFS_BTNUM_BNO: __XFS_BTREE_STATS_ADD(abtb, stat, val); break; \
|
|
|
|
case XFS_BTNUM_CNT: __XFS_BTREE_STATS_ADD(abtc, stat, val); break; \
|
|
|
|
case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_ADD(bmbt, stat, val); break; \
|
|
|
|
case XFS_BTNUM_INO: __XFS_BTREE_STATS_ADD(ibt, stat, val); break; \
|
|
|
|
case XFS_BTNUM_MAX: ASSERT(0); /* fucking gcc */ ; break; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Maximum and minimum records in a btree block.
|
|
|
|
* Given block size, type prefix, and leaf flag (0 or 1).
|
|
|
|
* The divisor below is equivalent to lf ? (e1) : (e2) but that produces
|
|
|
|
* compiler warnings.
|
|
|
|
*/
|
|
|
|
#define XFS_BTREE_BLOCK_MAXRECS(bsz,t,lf) \
|
|
|
|
((int)(((bsz) - (uint)sizeof(t ## _block_t)) / \
|
|
|
|
(((lf) * (uint)sizeof(t ## _rec_t)) + \
|
|
|
|
((1 - (lf)) * \
|
|
|
|
((uint)sizeof(t ## _key_t) + (uint)sizeof(t ## _ptr_t))))))
|
|
|
|
#define XFS_BTREE_BLOCK_MINRECS(bsz,t,lf) \
|
|
|
|
(XFS_BTREE_BLOCK_MAXRECS(bsz,t,lf) / 2)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Record, key, and pointer address calculation macros.
|
|
|
|
* Given block size, type prefix, block pointer, and index of requested entry
|
|
|
|
* (first entry numbered 1).
|
|
|
|
*/
|
2007-02-10 08:37:33 +01:00
|
|
|
#define XFS_BTREE_REC_ADDR(t,bb,i) \
|
2005-04-17 00:20:36 +02:00
|
|
|
((t ## _rec_t *)((char *)(bb) + sizeof(t ## _block_t) + \
|
|
|
|
((i) - 1) * sizeof(t ## _rec_t)))
|
2007-02-10 08:37:33 +01:00
|
|
|
#define XFS_BTREE_KEY_ADDR(t,bb,i) \
|
2005-04-17 00:20:36 +02:00
|
|
|
((t ## _key_t *)((char *)(bb) + sizeof(t ## _block_t) + \
|
|
|
|
((i) - 1) * sizeof(t ## _key_t)))
|
2007-02-10 08:37:33 +01:00
|
|
|
#define XFS_BTREE_PTR_ADDR(t,bb,i,mxr) \
|
2005-04-17 00:20:36 +02:00
|
|
|
((t ## _ptr_t *)((char *)(bb) + sizeof(t ## _block_t) + \
|
|
|
|
(mxr) * sizeof(t ## _key_t) + ((i) - 1) * sizeof(t ## _ptr_t)))
|
|
|
|
|
|
|
|
#define XFS_BTREE_MAXLEVELS 8 /* max of all btrees */
|
|
|
|
|
2008-10-30 06:53:59 +01:00
|
|
|
struct xfs_btree_ops {
|
|
|
|
/* cursor operations */
|
|
|
|
struct xfs_btree_cur *(*dup_cursor)(struct xfs_btree_cur *);
|
2008-10-30 06:55:13 +01:00
|
|
|
|
2008-10-30 06:55:23 +01:00
|
|
|
/* records in block/level */
|
|
|
|
int (*get_maxrecs)(struct xfs_btree_cur *cur, int level);
|
|
|
|
|
2008-10-30 06:55:13 +01:00
|
|
|
/* btree tracing */
|
|
|
|
#ifdef XFS_BTREE_TRACE
|
|
|
|
void (*trace_enter)(struct xfs_btree_cur *, const char *,
|
|
|
|
char *, int, int, __psunsigned_t,
|
|
|
|
__psunsigned_t, __psunsigned_t,
|
|
|
|
__psunsigned_t, __psunsigned_t,
|
|
|
|
__psunsigned_t, __psunsigned_t,
|
|
|
|
__psunsigned_t, __psunsigned_t,
|
|
|
|
__psunsigned_t, __psunsigned_t);
|
|
|
|
void (*trace_cursor)(struct xfs_btree_cur *, __uint32_t *,
|
|
|
|
__uint64_t *, __uint64_t *);
|
|
|
|
void (*trace_key)(struct xfs_btree_cur *,
|
|
|
|
union xfs_btree_key *, __uint64_t *,
|
|
|
|
__uint64_t *);
|
|
|
|
void (*trace_record)(struct xfs_btree_cur *,
|
|
|
|
union xfs_btree_rec *, __uint64_t *,
|
|
|
|
__uint64_t *, __uint64_t *);
|
|
|
|
#endif
|
2008-10-30 06:53:59 +01:00
|
|
|
};
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Btree cursor structure.
|
|
|
|
* This collects all information needed by the btree code in one place.
|
|
|
|
*/
|
|
|
|
typedef struct xfs_btree_cur
|
|
|
|
{
|
|
|
|
struct xfs_trans *bc_tp; /* transaction we're in, if any */
|
|
|
|
struct xfs_mount *bc_mp; /* file system mount struct */
|
2008-10-30 06:53:59 +01:00
|
|
|
const struct xfs_btree_ops *bc_ops;
|
2008-10-30 06:54:22 +01:00
|
|
|
uint bc_flags; /* btree features - below */
|
2005-04-17 00:20:36 +02:00
|
|
|
union {
|
2005-11-02 05:11:25 +01:00
|
|
|
xfs_alloc_rec_incore_t a;
|
2005-04-17 00:20:36 +02:00
|
|
|
xfs_bmbt_irec_t b;
|
2006-09-28 02:57:04 +02:00
|
|
|
xfs_inobt_rec_incore_t i;
|
2005-04-17 00:20:36 +02:00
|
|
|
} bc_rec; /* current insert/search record value */
|
|
|
|
struct xfs_buf *bc_bufs[XFS_BTREE_MAXLEVELS]; /* buf ptr per level */
|
|
|
|
int bc_ptrs[XFS_BTREE_MAXLEVELS]; /* key/record # */
|
|
|
|
__uint8_t bc_ra[XFS_BTREE_MAXLEVELS]; /* readahead bits */
|
|
|
|
#define XFS_BTCUR_LEFTRA 1 /* left sibling has been read-ahead */
|
|
|
|
#define XFS_BTCUR_RIGHTRA 2 /* right sibling has been read-ahead */
|
|
|
|
__uint8_t bc_nlevels; /* number of levels in the tree */
|
|
|
|
__uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */
|
|
|
|
xfs_btnum_t bc_btnum; /* identifies which btree type */
|
|
|
|
union {
|
2008-08-13 08:25:27 +02:00
|
|
|
struct { /* needed for BNO, CNT, INO */
|
|
|
|
struct xfs_buf *agbp; /* agf/agi buffer pointer */
|
2005-04-17 00:20:36 +02:00
|
|
|
xfs_agnumber_t agno; /* ag number */
|
|
|
|
} a;
|
|
|
|
struct { /* needed for BMAP */
|
|
|
|
struct xfs_inode *ip; /* pointer to our inode */
|
|
|
|
struct xfs_bmap_free *flist; /* list to free after */
|
|
|
|
xfs_fsblock_t firstblock; /* 1st blk allocated */
|
|
|
|
int allocated; /* count of alloced */
|
|
|
|
short forksize; /* fork's inode space */
|
|
|
|
char whichfork; /* data or attr fork */
|
|
|
|
char flags; /* flags */
|
|
|
|
#define XFS_BTCUR_BPRV_WASDEL 1 /* was delayed */
|
|
|
|
} b;
|
|
|
|
} bc_private; /* per-btree type data */
|
|
|
|
} xfs_btree_cur_t;
|
|
|
|
|
2008-10-30 06:54:22 +01:00
|
|
|
/* cursor flags */
|
2008-10-30 06:54:33 +01:00
|
|
|
#define XFS_BTREE_LONG_PTRS (1<<0) /* pointers are 64bits long */
|
2008-10-30 06:54:22 +01:00
|
|
|
#define XFS_BTREE_ROOT_IN_INODE (1<<1) /* root may be variable size */
|
|
|
|
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#define XFS_BTREE_NOERROR 0
|
|
|
|
#define XFS_BTREE_ERROR 1
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert from buffer to btree block header.
|
|
|
|
*/
|
2005-11-02 04:38:42 +01:00
|
|
|
#define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)XFS_BUF_PTR(bp))
|
|
|
|
#define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)XFS_BUF_PTR(bp))
|
|
|
|
#define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)XFS_BUF_PTR(bp))
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
/*
|
2008-10-30 06:54:53 +01:00
|
|
|
* Check that long form block header is ok.
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
2008-10-30 06:54:53 +01:00
|
|
|
int /* error (0 or EFSCORRUPTED) */
|
|
|
|
xfs_btree_check_lblock(
|
|
|
|
struct xfs_btree_cur *cur, /* btree cursor */
|
|
|
|
struct xfs_btree_lblock *block, /* btree long form block pointer */
|
2005-04-17 00:20:36 +02:00
|
|
|
int level, /* level of the btree block */
|
|
|
|
struct xfs_buf *bp); /* buffer containing block, if any */
|
|
|
|
|
|
|
|
/*
|
2008-10-30 06:54:53 +01:00
|
|
|
* Check that short form block header is ok.
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
2008-10-30 06:54:53 +01:00
|
|
|
int /* error (0 or EFSCORRUPTED) */
|
|
|
|
xfs_btree_check_sblock(
|
|
|
|
struct xfs_btree_cur *cur, /* btree cursor */
|
|
|
|
struct xfs_btree_sblock *block, /* btree short form block pointer */
|
|
|
|
int level, /* level of the btree block */
|
|
|
|
struct xfs_buf *bp); /* buffer containing block */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
2008-10-30 06:54:53 +01:00
|
|
|
* Check that block header is ok.
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
2008-10-30 06:54:53 +01:00
|
|
|
int
|
|
|
|
xfs_btree_check_block(
|
|
|
|
struct xfs_btree_cur *cur, /* btree cursor */
|
|
|
|
struct xfs_btree_block *block, /* generic btree block pointer */
|
2005-04-17 00:20:36 +02:00
|
|
|
int level, /* level of the btree block */
|
|
|
|
struct xfs_buf *bp); /* buffer containing block, if any */
|
|
|
|
|
|
|
|
/*
|
2008-10-30 06:54:53 +01:00
|
|
|
* Check that (long) pointer is ok.
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
int /* error (0 or EFSCORRUPTED) */
|
|
|
|
xfs_btree_check_lptr(
|
2008-10-30 06:54:53 +01:00
|
|
|
struct xfs_btree_cur *cur, /* btree cursor */
|
2005-04-17 00:20:36 +02:00
|
|
|
xfs_dfsbno_t ptr, /* btree block disk address */
|
|
|
|
int level); /* btree block level */
|
|
|
|
|
2006-09-28 02:57:42 +02:00
|
|
|
#define xfs_btree_check_lptr_disk(cur, ptr, level) \
|
2006-09-28 02:58:06 +02:00
|
|
|
xfs_btree_check_lptr(cur, be64_to_cpu(ptr), level)
|
2006-09-28 02:57:42 +02:00
|
|
|
|
2008-10-30 06:54:53 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
2008-10-30 06:54:53 +01:00
|
|
|
* Check that (short) pointer is ok.
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
int /* error (0 or EFSCORRUPTED) */
|
2008-10-30 06:54:53 +01:00
|
|
|
xfs_btree_check_sptr(
|
|
|
|
struct xfs_btree_cur *cur, /* btree cursor */
|
|
|
|
xfs_agblock_t ptr, /* btree block disk address */
|
|
|
|
int level); /* btree block level */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
2008-10-30 06:54:53 +01:00
|
|
|
* Check that (short) pointer is ok.
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
int /* error (0 or EFSCORRUPTED) */
|
2008-10-30 06:54:53 +01:00
|
|
|
xfs_btree_check_ptr(
|
|
|
|
struct xfs_btree_cur *cur, /* btree cursor */
|
|
|
|
union xfs_btree_ptr *ptr, /* btree block disk address */
|
|
|
|
int index, /* offset from ptr to check */
|
2005-04-17 00:20:36 +02:00
|
|
|
int level); /* btree block level */
|
|
|
|
|
2008-10-30 06:54:53 +01:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Debug routine: check that keys are in the right order.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xfs_btree_check_key(
|
|
|
|
xfs_btnum_t btnum, /* btree identifier */
|
|
|
|
void *ak1, /* pointer to left (lower) key */
|
|
|
|
void *ak2); /* pointer to right (higher) key */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Debug routine: check that records are in the right order.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xfs_btree_check_rec(
|
|
|
|
xfs_btnum_t btnum, /* btree identifier */
|
|
|
|
void *ar1, /* pointer to left (lower) record */
|
|
|
|
void *ar2); /* pointer to right (higher) record */
|
|
|
|
#else
|
|
|
|
#define xfs_btree_check_key(a, b, c)
|
|
|
|
#define xfs_btree_check_rec(a, b, c)
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Delete the btree cursor.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xfs_btree_del_cursor(
|
|
|
|
xfs_btree_cur_t *cur, /* btree cursor */
|
|
|
|
int error); /* del because of error */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Duplicate the btree cursor.
|
|
|
|
* Allocate a new one, copy the record, re-get the buffers.
|
|
|
|
*/
|
|
|
|
int /* error */
|
|
|
|
xfs_btree_dup_cursor(
|
|
|
|
xfs_btree_cur_t *cur, /* input cursor */
|
|
|
|
xfs_btree_cur_t **ncur);/* output cursor */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Change the cursor to point to the first record in the current block
|
|
|
|
* at the given level. Other levels are unaffected.
|
|
|
|
*/
|
|
|
|
int /* success=1, failure=0 */
|
|
|
|
xfs_btree_firstrec(
|
|
|
|
xfs_btree_cur_t *cur, /* btree cursor */
|
|
|
|
int level); /* level to change */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a buffer for the block, return it with no data read.
|
|
|
|
* Long-form addressing.
|
|
|
|
*/
|
|
|
|
struct xfs_buf * /* buffer for fsbno */
|
|
|
|
xfs_btree_get_bufl(
|
|
|
|
struct xfs_mount *mp, /* file system mount point */
|
|
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
|
|
xfs_fsblock_t fsbno, /* file system block number */
|
|
|
|
uint lock); /* lock flags for get_buf */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a buffer for the block, return it with no data read.
|
|
|
|
* Short-form addressing.
|
|
|
|
*/
|
|
|
|
struct xfs_buf * /* buffer for agno/agbno */
|
|
|
|
xfs_btree_get_bufs(
|
|
|
|
struct xfs_mount *mp, /* file system mount point */
|
|
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
|
|
xfs_agnumber_t agno, /* allocation group number */
|
|
|
|
xfs_agblock_t agbno, /* allocation group block number */
|
|
|
|
uint lock); /* lock flags for get_buf */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for the cursor referring to the last block at the given level.
|
|
|
|
*/
|
|
|
|
int /* 1=is last block, 0=not last block */
|
|
|
|
xfs_btree_islastblock(
|
|
|
|
xfs_btree_cur_t *cur, /* btree cursor */
|
|
|
|
int level); /* level to check */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Change the cursor to point to the last record in the current block
|
|
|
|
* at the given level. Other levels are unaffected.
|
|
|
|
*/
|
|
|
|
int /* success=1, failure=0 */
|
|
|
|
xfs_btree_lastrec(
|
|
|
|
xfs_btree_cur_t *cur, /* btree cursor */
|
|
|
|
int level); /* level to change */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute first and last byte offsets for the fields given.
|
|
|
|
* Interprets the offsets table, which contains struct field offsets.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xfs_btree_offsets(
|
|
|
|
__int64_t fields, /* bitmask of fields */
|
|
|
|
const short *offsets,/* table of field offsets */
|
|
|
|
int nbits, /* number of bits to inspect */
|
|
|
|
int *first, /* output: first byte offset */
|
|
|
|
int *last); /* output: last byte offset */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a buffer for the block, return it read in.
|
|
|
|
* Long-form addressing.
|
|
|
|
*/
|
|
|
|
int /* error */
|
|
|
|
xfs_btree_read_bufl(
|
|
|
|
struct xfs_mount *mp, /* file system mount point */
|
|
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
|
|
xfs_fsblock_t fsbno, /* file system block number */
|
|
|
|
uint lock, /* lock flags for read_buf */
|
|
|
|
struct xfs_buf **bpp, /* buffer for fsbno */
|
|
|
|
int refval);/* ref count value for buffer */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a buffer for the block, return it read in.
|
|
|
|
* Short-form addressing.
|
|
|
|
*/
|
|
|
|
int /* error */
|
|
|
|
xfs_btree_read_bufs(
|
|
|
|
struct xfs_mount *mp, /* file system mount point */
|
|
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
|
|
xfs_agnumber_t agno, /* allocation group number */
|
|
|
|
xfs_agblock_t agbno, /* allocation group block number */
|
|
|
|
uint lock, /* lock flags for read_buf */
|
|
|
|
struct xfs_buf **bpp, /* buffer for agno/agbno */
|
|
|
|
int refval);/* ref count value for buffer */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read-ahead the block, don't wait for it, don't return a buffer.
|
|
|
|
* Long-form addressing.
|
|
|
|
*/
|
|
|
|
void /* error */
|
|
|
|
xfs_btree_reada_bufl(
|
|
|
|
struct xfs_mount *mp, /* file system mount point */
|
|
|
|
xfs_fsblock_t fsbno, /* file system block number */
|
|
|
|
xfs_extlen_t count); /* count of filesystem blocks */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read-ahead the block, don't wait for it, don't return a buffer.
|
|
|
|
* Short-form addressing.
|
|
|
|
*/
|
|
|
|
void /* error */
|
|
|
|
xfs_btree_reada_bufs(
|
|
|
|
struct xfs_mount *mp, /* file system mount point */
|
|
|
|
xfs_agnumber_t agno, /* allocation group number */
|
|
|
|
xfs_agblock_t agbno, /* allocation group block number */
|
|
|
|
xfs_extlen_t count); /* count of filesystem blocks */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read-ahead btree blocks, at the given level.
|
|
|
|
* Bits in lr are set from XFS_BTCUR_{LEFT,RIGHT}RA.
|
|
|
|
*/
|
|
|
|
int /* readahead block count */
|
|
|
|
xfs_btree_readahead(
|
|
|
|
xfs_btree_cur_t *cur, /* btree cursor */
|
|
|
|
int lev, /* level in btree */
|
2008-10-30 06:54:43 +01:00
|
|
|
int lr); /* left/right bits */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the buffer for level "lev" in the cursor to bp, releasing
|
|
|
|
* any previous buffer.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xfs_btree_setbuf(
|
|
|
|
xfs_btree_cur_t *cur, /* btree cursor */
|
|
|
|
int lev, /* level in btree */
|
|
|
|
struct xfs_buf *bp); /* new buffer to set */
|
|
|
|
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Min and max functions for extlen, agblock, fileoff, and filblks types.
|
|
|
|
*/
|
2007-06-28 08:43:39 +02:00
|
|
|
#define XFS_EXTLEN_MIN(a,b) min_t(xfs_extlen_t, (a), (b))
|
|
|
|
#define XFS_EXTLEN_MAX(a,b) max_t(xfs_extlen_t, (a), (b))
|
|
|
|
#define XFS_AGBLOCK_MIN(a,b) min_t(xfs_agblock_t, (a), (b))
|
|
|
|
#define XFS_AGBLOCK_MAX(a,b) max_t(xfs_agblock_t, (a), (b))
|
|
|
|
#define XFS_FILEOFF_MIN(a,b) min_t(xfs_fileoff_t, (a), (b))
|
|
|
|
#define XFS_FILEOFF_MAX(a,b) max_t(xfs_fileoff_t, (a), (b))
|
|
|
|
#define XFS_FILBLKS_MIN(a,b) min_t(xfs_filblks_t, (a), (b))
|
|
|
|
#define XFS_FILBLKS_MAX(a,b) max_t(xfs_filblks_t, (a), (b))
|
2005-11-02 04:38:42 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#define XFS_FSB_SANITY_CHECK(mp,fsb) \
|
|
|
|
(XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
|
2005-11-02 04:38:42 +01:00
|
|
|
XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#endif /* __XFS_BTREE_H__ */
|