]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/xfs_rtalloc.h
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #ifndef __XFS_RTALLOC_H__
33 #define __XFS_RTALLOC_H__
38 /* Min and max rt extent sizes, specified in bytes */
39 #define XFS_MAX_RTEXTSIZE (1024 * 1024 * 1024) /* 1GB */
40 #define XFS_DFL_RTEXTSIZE (64 * 1024) /* 64KB */
41 #define XFS_MIN_RTEXTSIZE (4 * 1024) /* 4KB */
44 * Constants for bit manipulations.
46 #define XFS_NBBYLOG 3 /* log2(NBBY) */
47 #define XFS_WORDLOG 2 /* log2(sizeof(xfs_rtword_t)) */
48 #define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG)
49 #define XFS_NBWORD (1 << XFS_NBWORDLOG)
50 #define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1)
52 #define XFS_BLOCKSIZE(mp) ((mp)->m_sb.sb_blocksize)
53 #define XFS_BLOCKMASK(mp) ((mp)->m_blockmask)
54 #define XFS_BLOCKWSIZE(mp) ((mp)->m_blockwsize)
55 #define XFS_BLOCKWMASK(mp) ((mp)->m_blockwmask)
58 * Summary and bit manipulation macros.
60 #define XFS_SUMOFFS(mp,ls,bb) ((int)((ls) * (mp)->m_sb.sb_rbmblocks + (bb)))
61 #define XFS_SUMOFFSTOBLOCK(mp,s) \
62 (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog)
63 #define XFS_SUMPTR(mp,bp,so) \
64 ((xfs_suminfo_t *)((char *)XFS_BUF_PTR(bp) + \
65 (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp))))
67 #define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log)
68 #define XFS_BLOCKTOBIT(mp,bb) ((bb) << (mp)->m_blkbit_log)
69 #define XFS_BITTOWORD(mp,bi) \
70 ((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp)))
72 #define XFS_RTMIN(a,b) ((a) < (b) ? (a) : (b))
73 #define XFS_RTMAX(a,b) ((a) > (b) ? (a) : (b))
75 #define XFS_RTLOBIT(w) xfs_lowbit32(w)
76 #define XFS_RTHIBIT(w) xfs_highbit32(w)
78 #if XFS_BIG_FILESYSTEMS
79 #define XFS_RTBLOCKLOG(b) xfs_highbit64(b)
81 #define XFS_RTBLOCKLOG(b) xfs_highbit32(b)
85 * Function prototypes for exported functions.
89 * Allocate an extent in the realtime subvolume, with the usual allocation
90 * parameters. The length units are all in realtime extents, as is the
91 * result block number.
94 xfs_rtallocate_extent(
95 struct xfs_trans
*tp
, /* transaction pointer */
96 xfs_rtblock_t bno
, /* starting block number to allocate */
97 xfs_extlen_t minlen
, /* minimum length to allocate */
98 xfs_extlen_t maxlen
, /* maximum length to allocate */
99 xfs_extlen_t
*len
, /* out: actual length allocated */
100 xfs_alloctype_t type
, /* allocation type XFS_ALLOCTYPE... */
101 int wasdel
, /* was a delayed allocation extent */
102 xfs_extlen_t prod
, /* extent product factor */
103 xfs_rtblock_t
*rtblock
); /* out: start block allocated */
106 * Free an extent in the realtime subvolume. Length is expressed in
107 * realtime extents, as is the block number.
111 struct xfs_trans
*tp
, /* transaction pointer */
112 xfs_rtblock_t bno
, /* starting block number to free */
113 xfs_extlen_t len
); /* length of extent freed */
116 * Initialize realtime fields in the mount structure.
120 struct xfs_mount
*mp
); /* file system mount structure */
123 * Get the bitmap and summary inodes into the mount structure
128 struct xfs_mount
*mp
); /* file system mount structure */
131 * Pick an extent for allocation at the start of a new realtime file.
132 * Use the sequence number stored in the atime field of the bitmap inode.
133 * Translate this to a fraction of the rtextents, and return the product
134 * of rtextents and the fraction.
135 * The fraction sequence is 0, 1/2, 1/4, 3/4, 1/8, ..., 7/8, 1/16, ...
139 struct xfs_mount
*mp
, /* file system mount point */
140 struct xfs_trans
*tp
, /* transaction pointer */
141 xfs_extlen_t len
, /* allocation length (rtextents) */
142 xfs_rtblock_t
*pick
); /* result rt extent */
146 * Debug code: print out the value of a range in the bitmap.
150 struct xfs_mount
*mp
, /* file system mount structure */
151 struct xfs_trans
*tp
, /* transaction pointer */
152 xfs_rtblock_t start
, /* starting block to print */
153 xfs_extlen_t len
); /* length to print */
156 * Debug code: print the summary file.
160 struct xfs_mount
*mp
, /* file system mount structure */
161 struct xfs_trans
*tp
); /* transaction pointer */
162 #endif /* XFSDEBUG */
164 #endif /* __XFS_RTALLOC_H__ */