linux/fs/jfs/jfs_dmap.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *   Copyright (C) International Business Machines Corp., 2000-2002
 */
#ifndef	_H_JFS_DMAP
#define _H_JFS_DMAP

#include "jfs_txnmgr.h"

#define BMAPVERSION
#define TREESIZE
#define LEAFIND
#define LPERDMAP
#define L2LPERDMAP
#define DBWORD
#define L2DBWORD
#define BUDMIN
#define BPERDMAP
#define L2BPERDMAP
#define CTLTREESIZE
#define CTLLEAFIND
#define LPERCTL
#define L2LPERCTL
#define ROOT
#define NOFREE
#define MAXAG
#define L2MAXAG
#define L2MINAGSZ
#define BMAPBLKNO

/*
 * maximum l2 number of disk blocks at the various dmapctl levels.
 */
#define L2MAXL0SIZE
#define L2MAXL1SIZE
#define L2MAXL2SIZE

/*
 * maximum number of disk blocks at the various dmapctl levels.
 */
#define MAXL0SIZE
#define MAXL1SIZE
#define MAXL2SIZE

#define MAXMAPSIZE

/*
 * determine the maximum free string for four (lower level) nodes
 * of the tree.
 */
static inline signed char TREEMAX(signed char *cp)
{}

/*
 * convert disk block number to the logical block number of the dmap
 * describing the disk block.  s is the log2(number of logical blocks per page)
 *
 * The calculation figures out how many logical pages are in front of the dmap.
 *	- the number of dmaps preceding it
 *	- the number of L0 pages preceding its L0 page
 *	- the number of L1 pages preceding its L1 page
 *	- 3 is added to account for the L2, L1, and L0 page for this dmap
 *	- 1 is added to account for the control page of the map.
 */
#define BLKTODMAP(b,s)

/*
 * convert disk block number to the logical block number of the LEVEL 0
 * dmapctl describing the disk block.  s is the log2(number of logical blocks
 * per page)
 *
 * The calculation figures out how many logical pages are in front of the L0.
 *	- the number of dmap pages preceding it
 *	- the number of L0 pages preceding it
 *	- the number of L1 pages preceding its L1 page
 *	- 2 is added to account for the L2, and L1 page for this L0
 *	- 1 is added to account for the control page of the map.
 */
#define BLKTOL0(b,s)

/*
 * convert disk block number to the logical block number of the LEVEL 1
 * dmapctl describing the disk block.  s is the log2(number of logical blocks
 * per page)
 *
 * The calculation figures out how many logical pages are in front of the L1.
 *	- the number of dmap pages preceding it
 *	- the number of L0 pages preceding it
 *	- the number of L1 pages preceding it
 *	- 1 is added to account for the L2 page
 *	- 1 is added to account for the control page of the map.
 */
#define BLKTOL1(b,s)

/*
 * convert disk block number to the logical block number of the dmapctl
 * at the specified level which describes the disk block.
 */
#define BLKTOCTL(b,s,l)

/*
 * convert aggregate map size to the zero origin dmapctl level of the
 * top dmapctl.
 */
#define BMAPSZTOLEV(size)

/* convert disk block number to allocation group number.
 */
#define BLKTOAG(b,sbi)

/* convert allocation group number to starting disk block
 * number.
 */
#define AGTOBLK(a,ip)

/*
 *	dmap summary tree
 *
 * dmaptree must be consistent with dmapctl.
 */
struct dmaptree {};				/* - 360 -			*/

/*
 *	dmap page per 8K blocks bitmap
 */
struct dmap {};				/* - 4096 -				*/

/*
 *	disk map control page per level.
 *
 * dmapctl must be consistent with dmaptree.
 */
struct dmapctl {};				/* - 4096 -			*/

/*
 *	common definition for dmaptree within dmap and dmapctl
 */
dmtree_t;

/* macros for accessing fields within dmtree */
#define dmt_nleafs
#define dmt_l2nleafs
#define dmt_leafidx
#define dmt_height
#define dmt_budmin
#define dmt_stree

/*
 *	on-disk aggregate disk allocation map descriptor.
 */
struct dbmap_disk {};				/* - 4096 -				*/

struct dbmap {};				/* - 4096 -				*/
/*
 *	in-memory aggregate disk allocation map descriptor.
 */
struct bmap {};

/* macros for accessing fields within in-memory aggregate map descriptor */
#define db_mapsize
#define db_nfree
#define db_agfree
#define db_agsize
#define db_agl2size
#define db_agwidth
#define db_agheight
#define db_agstart
#define db_numag
#define db_maxlevel
#define db_aglevel
#define db_agpref
#define db_maxag
#define db_maxfreebud
#define db_l2nbperpage

/*
 * macros for various conversions needed by the allocators.
 * blkstol2(), cntlz(), and cnttz() are operating system dependent functions.
 */
/* convert number of blocks to log2 number of blocks, rounding up to
 * the next log2 value if blocks is not a l2 multiple.
 */
#define BLKSTOL2(d)

/* convert number of leafs to log2 leaf value */
#define NLSTOL2BSZ(n)

/* convert leaf index to log2 leaf value */
#define LITOL2BSZ(n,m,b)

/* convert a block number to a dmap control leaf index */
#define BLKTOCTLLEAF(b,m)

/* convert log2 leaf value to buddy size */
#define BUDSIZE(s,m)

/*
 *	external references.
 */
extern int dbMount(struct inode *ipbmap);

extern int dbUnmount(struct inode *ipbmap, int mounterror);

extern int dbFree(struct inode *ipbmap, s64 blkno, s64 nblocks);

extern int dbUpdatePMap(struct inode *ipbmap,
			int free, s64 blkno, s64 nblocks, struct tblock * tblk);

extern int dbNextAG(struct inode *ipbmap);

extern int dbAlloc(struct inode *ipbmap, s64 hint, s64 nblocks, s64 * results);

extern int dbReAlloc(struct inode *ipbmap,
		     s64 blkno, s64 nblocks, s64 addnblocks, s64 * results);

extern int dbSync(struct inode *ipbmap);
extern int dbAllocBottomUp(struct inode *ip, s64 blkno, s64 nblocks);
extern int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks);
extern void dbFinalizeBmap(struct inode *ipbmap);
extern s64 dbMapFileSizeToMapSize(struct inode *ipbmap);
extern s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen);

#endif				/* _H_JFS_DMAP */