[BACK]Return to xfs_ag.h CVS log [TXT][DIR] Up to [Development] / linux-2.6-xfs / fs / xfs

File: [Development] / linux-2.6-xfs / fs / xfs / xfs_ag.h (download)

Revision 1.9, Mon Dec 27 22:23:23 1993 UTC (23 years, 9 months ago) by doucette
Branch: MAIN
Changes since 1.8: +78 -50 lines

Split allocation group header into two buffers; make superblock one
buffer long instead of one block long.

#ifndef _FS_XFS_AG_H
#define	_FS_XFS_AG_H

#ident	"$Revision$"

/*
 * Allocation group header
 * This is divided into two structures, placed in sequential 512-byte 
 * buffers after a copy of the superblock (also in a 512-byte buffer).
 */

#define	XFS_AGF_MAGIC	0x58414746	/* 'XAGF' */
#define	XFS_AGI_MAGIC	0x58414749	/* 'XAGI' */
#define	XFS_AGF_VERSION	1
#define	XFS_AGI_VERSION	1

typedef struct xfs_agf
{
	/*
	 * Common allocation group header information
	 */
	__uint32_t	agf_magicnum;	/* magic number == XFS_AGF_MAGIC */
	__uint32_t	agf_versionnum;	/* header version == XFS_AGF_VERSION */
	xfs_agnumber_t	agf_seqno;	/* sequence # starting from 0 */
	xfs_agblock_t	agf_length;	/* size in blocks of a.g. */
	/*
	 * Freespace information
	 */
	xfs_agblock_t	agf_roots[XFS_BTNUM_MAX - 1];
	__uint32_t	agf_levels[XFS_BTNUM_MAX - 1];
	xfs_agblock_t	agf_freelist;	/* free blocks */
	xfs_extlen_t	agf_freecount;	/* #blocks on agf_freelist */
	xfs_extlen_t	agf_freeblks;	/* total free blocks */
	xfs_extlen_t	agf_longest;	/* longest free space */
} xfs_agf_t;

#define	XFS_AGF_MAGICNUM	0x0001
#define	XFS_AGF_VERSIONNUM	0x0002
#define	XFS_AGF_SEQNO		0x0004
#define	XFS_AGF_LENGTH		0x0008
#define	XFS_AGF_ROOTS		0x0010
#define	XFS_AGF_LEVELS		0x0020
#define	XFS_AGF_FREELIST	0x0040
#define	XFS_AGF_FREECOUNT	0x0080
#define	XFS_AGF_FREEBLKS	0x0100
#define	XFS_AGF_LONGEST		0x0200
#define	XFS_AGF_NUM_BITS	10
#define	XFS_AGF_ALL_BITS	((1 << XFS_AGF_NUM_BITS) - 1)

/* disk block (daddr_t) in the AG */
#define	XFS_AGF_DADDR		((daddr_t)1)
#define	XFS_AGF_BLOCK(s)	xfs_hdr_block(s, XFS_AGF_DADDR)

typedef struct xfs_agi
{
	/*
	 * Common allocation group header information
	 */
	__uint32_t	agi_magicnum;	/* magic number == XFS_AGI_MAGIC */
	__uint32_t	agi_versionnum;	/* header version == XFS_AGI_VERSION */
	xfs_agnumber_t	agi_seqno;	/* sequence # starting from 0 */
	xfs_agblock_t	agi_length;	/* size in blocks of a.g. */
	/*
	 * Inode information
	 * Inodes are mapped by interpreting the inode number, so no
	 * mapping data is needed here.
	 */
	xfs_agino_t	agi_count;	/* count of allocated inodes */
	xfs_agino_t	agi_first;	/* first allocated inode */
	xfs_agino_t	agi_last;	/* last allocated inode */
	xfs_agino_t	agi_freelist;	/* first free inode */
	xfs_agino_t	agi_freecount;	/* number of free inodes */
} xfs_agi_t;

#define	XFS_AGI_MAGICNUM	0x0001
#define	XFS_AGI_VERSIONNUM	0x0002
#define	XFS_AGI_SEQNO		0x0004
#define	XFS_AGI_LENGTH		0x0008
#define	XFS_AGI_COUNT		0x0010
#define	XFS_AGI_FIRST		0x0020
#define	XFS_AGI_LAST		0x0040
#define	XFS_AGI_FREELIST	0x0080
#define	XFS_AGI_FREECOUNT	0x0100
#define	XFS_AGI_NUM_BITS	9
#define	XFS_AGI_ALL_BITS	((1 << XFS_AGI_NUM_BITS) - 1)

/* disk block (daddr_t) in the AG */
#define	XFS_AGI_DADDR		((daddr_t)2)
#define	XFS_AGI_BLOCK(s)	xfs_hdr_block(s, XFS_AGI_DADDR)

#define	XFS_AG_MIN_BYTES	(1LL << 24)	/* 16 MB */
#define	XFS_AG_MAX_BYTES	(1LL << 32)	/*  4 GB */

#define	XFS_AG_MIN_BLOCKS(bl)	((xfs_extlen_t)(XFS_AG_MIN_BYTES >> bl))
#define	XFS_AG_MAX_BLOCKS(bl)	((xfs_extlen_t)(XFS_AG_MAX_BYTES >> bl))

#define	XFS_MIN_FREELIST(a)	(2 * (((a)->agf_levels[XFS_BTNUM_BNO]) + ((a)->agf_levels[XFS_BTNUM_CNT]) + 1))

#define	xfs_agb_mask(k)	((1 << (k)) - 1)
#define	xfs_agb_to_fsb(s,agno,agbno) \
	(((xfs_fsblock_t)(agno) << (s)->sb_agblklog) | (agbno))
#define	xfs_fsb_to_agno(s,fsbno) \
	((xfs_agnumber_t)((fsbno) >> (s)->sb_agblklog))
#define	xfs_fsb_to_agbno(s,fsbno) \
	((xfs_agblock_t)((fsbno) & xfs_agb_mask((s)->sb_agblklog)))

#define	xfs_agb_to_daddr(s,agno,agbno) \
	(xfs_btod(s, (xfs_fsblock_t)(agno) * (s)->sb_agblocks + (agbno)))
#define	xfs_daddr_to_agno(s,d) \
	((xfs_agnumber_t)(xfs_dtobt(s, d) / (s)->sb_agblocks))
#define	xfs_daddr_to_agbno(s,d) \
	((xfs_agblock_t)(xfs_dtobt(s, d) % (s)->sb_agblocks))

#define	xfs_ag_daddr(s,agno,d)	(xfs_agb_to_daddr(s, agno, 0) + (d))

#define	xfs_buf_to_agf(buf)	((xfs_agf_t *)(buf)->b_un.b_addr)
#define	xfs_buf_to_agi(buf)	((xfs_agi_t *)(buf)->b_un.b_addr)

#endif	/* !_FS_XFS_AG_H */