[BACK]Return to xfs_ialloc.h CVS log [TXT][DIR] Up to [Development] / xfs-linux-nodel

File: [Development] / xfs-linux-nodel / xfs_ialloc.h (download)

Revision 1.3, Sat Oct 30 00:24:49 1993 UTC (24 years ago) by doucette
Branch: MAIN
Changes since 1.2: +5 -22 lines

Move stuff into xfs_inum.h and xfs_dinode.h.
Change types from u_int??_t form to __uint??_t form.

#ifndef _FS_XFS_IALLOC_H
#define	_FS_XFS_IALLOC_H

#ident	"$Revision$"

#include "xfs_types.h"
#include <sys/pfdat.h>
#include <sys/buf.h>
#include "xfs.h"
#include "xfs_trans.h"

/*
 * block numbers in the AG; SB is block 0, AGH is block 1, free btree roots
 * are 2 and 3.
 */
#define	XFS_IBT_BLOCK	((xfs_agblock_t)(XFS_CNT_BLOCK + 1))

#define	XFS_PREALLOC_BLOCKS	((xfs_agblock_t)(XFS_IBT_BLOCK + 1))

#define	XFS_IALLOC_MAX_EVER	1024
#define	XFS_IALLOC_MIN_ALLOC(s,a)	((s)->xfsb_inopblock)
#define XFS_IALLOC_MAX_ALLOC(s,a)	\
	((a)->xfsag_icount > XFS_IALLOC_MAX_EVER ? \
	XFS_IALLOC_MAX_EVER : \
	((a)->xfsag_icount) ? (a)->xfsag_icount : XFS_IALLOC_MIN_ALLOC(s,a))

/*
 * Structures for inode mapping
 */
#define	XFS_IBT_MAGIC	0x58494254	/* 'XIBT' */
typedef struct xfs_ialloc_block
{
	__uint32_t	magic;		/* XFS_IBT_MAGIC */
	__uint16_t	level;		/* 0 is a leaf */
	__uint16_t	numrecs;	/* current # of data records */
	xfs_agblock_t	leftsib;	/* left sibling block */
	xfs_agblock_t	rightsib;	/* right sibling block */
} xfs_ialloc_block_t;

/*
 * Data record/key structure
 */
typedef struct xfs_ialloc_rec
{
	xfs_agino_t	startinode;	/* starting inode number */
	xfs_agblock_t	startblock;	/* starting block number */
	xfs_agino_t	inodecount;	/* number of inodes */
} xfs_ialloc_rec_t;

/*
 * Real block structures have a size equal to the file system block size.
 */

#define	XFS_IALLOC_BLOCK_MAXRECS(n,l)	\
	(((1 << (n)) - sizeof(xfs_ialloc_block_t)) / (sizeof(xfs_ialloc_rec_t) + sizeof(xfs_agblock_t) * ((l) > 0)))
#define	XFS_IALLOC_BLOCK_MINRECS(n,l)	(XFS_IALLOC_BLOCK_MAXRECS(n,l) / 2)

#define	XFS_IALLOC_REC_ADDR(b,i,n)	((xfs_ialloc_rec_t *)((char *)(b) + sizeof(xfs_ialloc_block_t) + ((i) - 1) * sizeof(xfs_ialloc_rec_t)))
#define	XFS_IALLOC_PTR_ADDR(b,i,n)	((xfs_agblock_t *)((char *)(b) + sizeof(xfs_ialloc_block_t) + XFS_IALLOC_BLOCK_MAXRECS(n,1) * sizeof(xfs_ialloc_rec_t) + ((i) - 1) * sizeof(xfs_agblock_t)))

#define	XFS_IALLOC_MAXLEVELS	5 /* ??? */

typedef struct xfs_ialloc_cur
{
	xfs_trans_t		*tp;	/* links cursors on freelist */
	buf_t			*agbuf;
	xfs_agnumber_t		agno;
	xfs_ialloc_rec_t	rec;
	buf_t			*bufs[XFS_IALLOC_MAXLEVELS];
	int			ptrs[XFS_IALLOC_MAXLEVELS];
	int			nlevels;
#ifdef XFSIDEBUG
	int			lineno;
	struct xfs_ialloc_cur	*next;	/* on all cursors list */
#endif
} xfs_ialloc_cur_t;

#define	xfs_buf_to_iblock(buf)	((xfs_ialloc_block_t *)(buf->b_un.b_addr))

#define	xfs_make_iptr(s,b,o) \
	((xfs_dinode_t *)((caddr_t)xfs_buf_to_iblock(b) + (o) * (s)->xfsb_inodesize))

/*
 * Prototypes for per-ag routines.
 */
int xfs_ialloc_ag_alloc(xfs_ialloc_cur_t *);
int xfs_ialloc_ag_locate(xfs_ialloc_cur_t *, xfs_agino_t, xfs_agblock_t *, int *);
buf_t *xfs_ialloc_ag_select(xfs_trans_t *, xfs_ino_t, int, int);

/*
 * Prototypes for per-fs routines.
 */
xfs_ino_t xfs_ialloc(xfs_trans_t *, xfs_ino_t, int, int);
xfs_agino_t xfs_ialloc_next_free(xfs_trans_t *, buf_t *, xfs_agino_t);
int xfs_ifree(xfs_trans_t *, xfs_ino_t);

#endif	/* !_FS_XFS_IALLOC_H */