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_RTALLOC_H__
7#define __XFS_RTALLOC_H__
8
9/* kernel only definitions and functions */
10
11struct xfs_mount;
12struct xfs_trans;
13
14#ifdef CONFIG_XFS_RT
15/*
16 * Function prototypes for exported functions.
17 */
18
19/*
20 * Allocate an extent in the realtime subvolume, with the usual allocation
21 * parameters. The length units are all in realtime extents, as is the
22 * result block number.
23 */
24int /* error */
25xfs_rtallocate_extent(
26 struct xfs_trans *tp, /* transaction pointer */
27 xfs_rtxnum_t start, /* starting rtext number to allocate */
28 xfs_rtxlen_t minlen, /* minimum length to allocate */
29 xfs_rtxlen_t maxlen, /* maximum length to allocate */
30 xfs_rtxlen_t *len, /* out: actual length allocated */
31 int wasdel, /* was a delayed allocation extent */
32 xfs_rtxlen_t prod, /* extent product factor */
33 xfs_rtxnum_t *rtblock); /* out: start rtext allocated */
34
35
36/*
37 * Initialize realtime fields in the mount structure.
38 */
39int /* error */
40xfs_rtmount_init(
41 struct xfs_mount *mp); /* file system mount structure */
42void
43xfs_rtunmount_inodes(
44 struct xfs_mount *mp);
45
46/*
47 * Get the bitmap and summary inodes into the mount structure
48 * at mount time.
49 */
50int /* error */
51xfs_rtmount_inodes(
52 struct xfs_mount *mp); /* file system mount structure */
53
54/*
55 * Pick an extent for allocation at the start of a new realtime file.
56 * Use the sequence number stored in the atime field of the bitmap inode.
57 * Translate this to a fraction of the rtextents, and return the product
58 * of rtextents and the fraction.
59 * The fraction sequence is 0, 1/2, 1/4, 3/4, 1/8, ..., 7/8, 1/16, ...
60 */
61int /* error */
62xfs_rtpick_extent(
63 struct xfs_mount *mp, /* file system mount point */
64 struct xfs_trans *tp, /* transaction pointer */
65 xfs_rtxlen_t len, /* allocation length (rtextents) */
66 xfs_rtxnum_t *pick); /* result rt extent */
67
68/*
69 * Grow the realtime area of the filesystem.
70 */
71int
72xfs_growfs_rt(
73 struct xfs_mount *mp, /* file system mount structure */
74 xfs_growfs_rt_t *in); /* user supplied growfs struct */
75
76int xfs_rtalloc_reinit_frextents(struct xfs_mount *mp);
77#else
78# define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (-ENOSYS)
79# define xfs_rtpick_extent(m,t,l,rb) (-ENOSYS)
80# define xfs_growfs_rt(mp,in) (-ENOSYS)
81# define xfs_rtalloc_reinit_frextents(m) (0)
82static inline int /* error */
83xfs_rtmount_init(
84 xfs_mount_t *mp) /* file system mount structure */
85{
86 if (mp->m_sb.sb_rblocks == 0)
87 return 0;
88
89 xfs_warn(mp, "Not built with CONFIG_XFS_RT");
90 return -ENOSYS;
91}
92# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (-ENOSYS))
93# define xfs_rtunmount_inodes(m)
94#endif /* CONFIG_XFS_RT */
95
96#endif /* __XFS_RTALLOC_H__ */
97

source code of linux/fs/xfs/xfs_rtalloc.h