xref: /openbmc/linux/fs/xfs/libxfs/xfs_rtbitmap.h (revision 1ec7ccb4)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6 #ifndef __XFS_RTBITMAP_H__
7 #define	__XFS_RTBITMAP_H__
8 
9 /*
10  * XXX: Most of the realtime allocation functions deal in units of realtime
11  * extents, not realtime blocks.  This looks funny when paired with the type
12  * name and screams for a larger cleanup.
13  */
14 struct xfs_rtalloc_rec {
15 	xfs_rtblock_t		ar_startext;
16 	xfs_rtbxlen_t		ar_extcount;
17 };
18 
19 typedef int (*xfs_rtalloc_query_range_fn)(
20 	struct xfs_mount		*mp,
21 	struct xfs_trans		*tp,
22 	const struct xfs_rtalloc_rec	*rec,
23 	void				*priv);
24 
25 #ifdef CONFIG_XFS_RT
26 int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp,
27 		  xfs_rtblock_t block, int issum, struct xfs_buf **bpp);
28 int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp,
29 		      xfs_rtblock_t start, xfs_extlen_t len, int val,
30 		      xfs_rtblock_t *new, int *stat);
31 int xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp,
32 		    xfs_rtblock_t start, xfs_rtblock_t limit,
33 		    xfs_rtblock_t *rtblock);
34 int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp,
35 		    xfs_rtblock_t start, xfs_rtblock_t limit,
36 		    xfs_rtblock_t *rtblock);
37 int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp,
38 		       xfs_rtblock_t start, xfs_extlen_t len, int val);
39 int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp,
40 			     int log, xfs_rtblock_t bbno, int delta,
41 			     struct xfs_buf **rbpp, xfs_fsblock_t *rsb,
42 			     xfs_suminfo_t *sum);
43 int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log,
44 			 xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp,
45 			 xfs_fsblock_t *rsb);
46 int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp,
47 		     xfs_rtblock_t start, xfs_extlen_t len,
48 		     struct xfs_buf **rbpp, xfs_fsblock_t *rsb);
49 int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp,
50 		const struct xfs_rtalloc_rec *low_rec,
51 		const struct xfs_rtalloc_rec *high_rec,
52 		xfs_rtalloc_query_range_fn fn, void *priv);
53 int xfs_rtalloc_query_all(struct xfs_mount *mp, struct xfs_trans *tp,
54 			  xfs_rtalloc_query_range_fn fn,
55 			  void *priv);
56 bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
57 int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp,
58 			       xfs_rtblock_t start, xfs_extlen_t len,
59 			       bool *is_free);
60 /*
61  * Free an extent in the realtime subvolume.  Length is expressed in
62  * realtime extents, as is the block number.
63  */
64 int					/* error */
65 xfs_rtfree_extent(
66 	struct xfs_trans	*tp,	/* transaction pointer */
67 	xfs_rtblock_t		bno,	/* starting block number to free */
68 	xfs_extlen_t		len);	/* length of extent freed */
69 
70 /* Same as above, but in units of rt blocks. */
71 int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno,
72 		xfs_filblks_t rtlen);
73 
74 #else /* CONFIG_XFS_RT */
75 # define xfs_rtfree_extent(t,b,l)			(-ENOSYS)
76 # define xfs_rtfree_blocks(t,rb,rl)			(-ENOSYS)
77 # define xfs_rtalloc_query_range(m,t,l,h,f,p)		(-ENOSYS)
78 # define xfs_rtalloc_query_all(m,t,f,p)			(-ENOSYS)
79 # define xfs_rtbuf_get(m,t,b,i,p)			(-ENOSYS)
80 # define xfs_rtalloc_extent_is_free(m,t,s,l,i)		(-ENOSYS)
81 #endif /* CONFIG_XFS_RT */
82 
83 #endif /* __XFS_RTBITMAP_H__ */
84