[PATCH] orinoco MAINTAINERS update
[linux-2.6/sactl.git] / fs / xfs / xfs_rtalloc.h
blobe2710264c0544ae16b1a62f0cb82c0f4bd849e46
1 /*
2 * Copyright (c) 2000-2003 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:
26 * http://www.sgi.com
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__
35 struct xfs_mount;
36 struct xfs_trans;
38 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
40 /* Min and max rt extent sizes, specified in bytes */
41 #define XFS_MAX_RTEXTSIZE (1024 * 1024 * 1024) /* 1GB */
42 #define XFS_DFL_RTEXTSIZE (64 * 1024) /* 64KB */
43 #define XFS_MIN_RTEXTSIZE (4 * 1024) /* 4KB */
46 * Constants for bit manipulations.
48 #define XFS_NBBYLOG 3 /* log2(NBBY) */
49 #define XFS_WORDLOG 2 /* log2(sizeof(xfs_rtword_t)) */
50 #define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG)
51 #define XFS_NBWORD (1 << XFS_NBWORDLOG)
52 #define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1)
54 #define XFS_BLOCKSIZE(mp) ((mp)->m_sb.sb_blocksize)
55 #define XFS_BLOCKMASK(mp) ((mp)->m_blockmask)
56 #define XFS_BLOCKWSIZE(mp) ((mp)->m_blockwsize)
57 #define XFS_BLOCKWMASK(mp) ((mp)->m_blockwmask)
60 * Summary and bit manipulation macros.
62 #define XFS_SUMOFFS(mp,ls,bb) ((int)((ls) * (mp)->m_sb.sb_rbmblocks + (bb)))
63 #define XFS_SUMOFFSTOBLOCK(mp,s) \
64 (((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog)
65 #define XFS_SUMPTR(mp,bp,so) \
66 ((xfs_suminfo_t *)((char *)XFS_BUF_PTR(bp) + \
67 (((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp))))
69 #define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log)
70 #define XFS_BLOCKTOBIT(mp,bb) ((bb) << (mp)->m_blkbit_log)
71 #define XFS_BITTOWORD(mp,bi) \
72 ((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp)))
74 #define XFS_RTMIN(a,b) ((a) < (b) ? (a) : (b))
75 #define XFS_RTMAX(a,b) ((a) > (b) ? (a) : (b))
77 #define XFS_RTLOBIT(w) xfs_lowbit32(w)
78 #define XFS_RTHIBIT(w) xfs_highbit32(w)
80 #if XFS_BIG_BLKNOS
81 #define XFS_RTBLOCKLOG(b) xfs_highbit64(b)
82 #else
83 #define XFS_RTBLOCKLOG(b) xfs_highbit32(b)
84 #endif
87 #ifdef __KERNEL__
89 #ifdef CONFIG_XFS_RT
91 * Function prototypes for exported functions.
95 * Allocate an extent in the realtime subvolume, with the usual allocation
96 * parameters. The length units are all in realtime extents, as is the
97 * result block number.
99 int /* error */
100 xfs_rtallocate_extent(
101 struct xfs_trans *tp, /* transaction pointer */
102 xfs_rtblock_t bno, /* starting block number to allocate */
103 xfs_extlen_t minlen, /* minimum length to allocate */
104 xfs_extlen_t maxlen, /* maximum length to allocate */
105 xfs_extlen_t *len, /* out: actual length allocated */
106 xfs_alloctype_t type, /* allocation type XFS_ALLOCTYPE... */
107 int wasdel, /* was a delayed allocation extent */
108 xfs_extlen_t prod, /* extent product factor */
109 xfs_rtblock_t *rtblock); /* out: start block allocated */
112 * Free an extent in the realtime subvolume. Length is expressed in
113 * realtime extents, as is the block number.
115 int /* error */
116 xfs_rtfree_extent(
117 struct xfs_trans *tp, /* transaction pointer */
118 xfs_rtblock_t bno, /* starting block number to free */
119 xfs_extlen_t len); /* length of extent freed */
122 * Initialize realtime fields in the mount structure.
124 int /* error */
125 xfs_rtmount_init(
126 struct xfs_mount *mp); /* file system mount structure */
129 * Get the bitmap and summary inodes into the mount structure
130 * at mount time.
132 int /* error */
133 xfs_rtmount_inodes(
134 struct xfs_mount *mp); /* file system mount structure */
137 * Pick an extent for allocation at the start of a new realtime file.
138 * Use the sequence number stored in the atime field of the bitmap inode.
139 * Translate this to a fraction of the rtextents, and return the product
140 * of rtextents and the fraction.
141 * The fraction sequence is 0, 1/2, 1/4, 3/4, 1/8, ..., 7/8, 1/16, ...
143 int /* error */
144 xfs_rtpick_extent(
145 struct xfs_mount *mp, /* file system mount point */
146 struct xfs_trans *tp, /* transaction pointer */
147 xfs_extlen_t len, /* allocation length (rtextents) */
148 xfs_rtblock_t *pick); /* result rt extent */
151 * Debug code: print out the value of a range in the bitmap.
153 void
154 xfs_rtprint_range(
155 struct xfs_mount *mp, /* file system mount structure */
156 struct xfs_trans *tp, /* transaction pointer */
157 xfs_rtblock_t start, /* starting block to print */
158 xfs_extlen_t len); /* length to print */
161 * Debug code: print the summary file.
163 void
164 xfs_rtprint_summary(
165 struct xfs_mount *mp, /* file system mount structure */
166 struct xfs_trans *tp); /* transaction pointer */
169 * Grow the realtime area of the filesystem.
172 xfs_growfs_rt(
173 struct xfs_mount *mp, /* file system mount structure */
174 xfs_growfs_rt_t *in); /* user supplied growfs struct */
176 #else
177 # define xfs_rtallocate_extent(t,b,min,max,l,a,f,p,rb) (ENOSYS)
178 # define xfs_rtfree_extent(t,b,l) (ENOSYS)
179 # define xfs_rtpick_extent(m,t,l,rb) (ENOSYS)
180 # define xfs_growfs_rt(mp,in) (ENOSYS)
181 # define xfs_rtmount_init(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
182 # define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
183 #endif /* CONFIG_XFS_RT */
185 #endif /* __KERNEL__ */
187 #endif /* __XFS_RTALLOC_H__ */