^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __XFS_RTALLOC_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __XFS_RTALLOC_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) /* kernel only definitions and functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct xfs_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct xfs_trans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * XXX: Most of the realtime allocation functions deal in units of realtime
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * extents, not realtime blocks. This looks funny when paired with the type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * name and screams for a larger cleanup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct xfs_rtalloc_rec {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) xfs_rtblock_t ar_startext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) xfs_rtblock_t ar_extcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) typedef int (*xfs_rtalloc_query_range_fn)(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct xfs_rtalloc_rec *rec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) void *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #ifdef CONFIG_XFS_RT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * Function prototypes for exported functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * Allocate an extent in the realtime subvolume, with the usual allocation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * parameters. The length units are all in realtime extents, as is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * result block number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int /* error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) xfs_rtallocate_extent(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct xfs_trans *tp, /* transaction pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) xfs_rtblock_t bno, /* starting block number to allocate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) xfs_extlen_t minlen, /* minimum length to allocate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) xfs_extlen_t maxlen, /* maximum length to allocate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) xfs_extlen_t *len, /* out: actual length allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int wasdel, /* was a delayed allocation extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) xfs_extlen_t prod, /* extent product factor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) xfs_rtblock_t *rtblock); /* out: start block allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * Free an extent in the realtime subvolume. Length is expressed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * realtime extents, as is the block number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) int /* error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) xfs_rtfree_extent(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct xfs_trans *tp, /* transaction pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) xfs_rtblock_t bno, /* starting block number to free */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) xfs_extlen_t len); /* length of extent freed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * Initialize realtime fields in the mount structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int /* error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) xfs_rtmount_init(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct xfs_mount *mp); /* file system mount structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) xfs_rtunmount_inodes(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct xfs_mount *mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * Get the bitmap and summary inodes into the mount structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * at mount time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int /* error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) xfs_rtmount_inodes(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct xfs_mount *mp); /* file system mount structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * Pick an extent for allocation at the start of a new realtime file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * Use the sequence number stored in the atime field of the bitmap inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * Translate this to a fraction of the rtextents, and return the product
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * of rtextents and the fraction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * The fraction sequence is 0, 1/2, 1/4, 3/4, 1/8, ..., 7/8, 1/16, ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int /* error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) xfs_rtpick_extent(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct xfs_mount *mp, /* file system mount point */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct xfs_trans *tp, /* transaction pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) xfs_extlen_t len, /* allocation length (rtextents) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) xfs_rtblock_t *pick); /* result rt extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * Grow the realtime area of the filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) xfs_growfs_rt(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct xfs_mount *mp, /* file system mount structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) xfs_growfs_rt_t *in); /* user supplied growfs struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * From xfs_rtbitmap.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) xfs_rtblock_t block, int issum, struct xfs_buf **bpp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) xfs_rtblock_t start, xfs_extlen_t len, int val,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) xfs_rtblock_t *new, int *stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) int xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) xfs_rtblock_t start, xfs_rtblock_t limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) xfs_rtblock_t *rtblock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) xfs_rtblock_t start, xfs_rtblock_t limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) xfs_rtblock_t *rtblock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) xfs_rtblock_t start, xfs_extlen_t len, int val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int log, xfs_rtblock_t bbno, int delta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) xfs_buf_t **rbpp, xfs_fsblock_t *rsb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) xfs_suminfo_t *sum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) xfs_rtblock_t bbno, int delta, xfs_buf_t **rbpp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) xfs_fsblock_t *rsb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) xfs_rtblock_t start, xfs_extlen_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct xfs_buf **rbpp, xfs_fsblock_t *rsb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int xfs_rtalloc_query_range(struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct xfs_rtalloc_rec *low_rec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct xfs_rtalloc_rec *high_rec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) xfs_rtalloc_query_range_fn fn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) void *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int xfs_rtalloc_query_all(struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) xfs_rtalloc_query_range_fn fn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) void *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) xfs_rtblock_t start, xfs_extlen_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) bool *is_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) # define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (ENOSYS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) # define xfs_rtfree_extent(t,b,l) (ENOSYS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) # define xfs_rtpick_extent(m,t,l,rb) (ENOSYS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) # define xfs_growfs_rt(mp,in) (ENOSYS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) # define xfs_rtalloc_query_range(t,l,h,f,p) (ENOSYS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) # define xfs_rtalloc_query_all(t,f,p) (ENOSYS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) # define xfs_rtbuf_get(m,t,b,i,p) (ENOSYS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) # define xfs_verify_rtbno(m, r) (false)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) # define xfs_rtalloc_extent_is_free(m,t,s,l,i) (ENOSYS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static inline int /* error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) xfs_rtmount_init(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) xfs_mount_t *mp) /* file system mount structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) if (mp->m_sb.sb_rblocks == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) xfs_warn(mp, "Not built with CONFIG_XFS_RT");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) return -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) # define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) # define xfs_rtunmount_inodes(m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #endif /* CONFIG_XFS_RT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #endif /* __XFS_RTALLOC_H__ */