162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. 462306a36Sopenharmony_ci * All Rights Reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef __XFS_RTALLOC_H__ 762306a36Sopenharmony_ci#define __XFS_RTALLOC_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* kernel only definitions and functions */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_cistruct xfs_mount; 1262306a36Sopenharmony_cistruct xfs_trans; 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* 1562306a36Sopenharmony_ci * XXX: Most of the realtime allocation functions deal in units of realtime 1662306a36Sopenharmony_ci * extents, not realtime blocks. This looks funny when paired with the type 1762306a36Sopenharmony_ci * name and screams for a larger cleanup. 1862306a36Sopenharmony_ci */ 1962306a36Sopenharmony_cistruct xfs_rtalloc_rec { 2062306a36Sopenharmony_ci xfs_rtblock_t ar_startext; 2162306a36Sopenharmony_ci xfs_rtblock_t ar_extcount; 2262306a36Sopenharmony_ci}; 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_citypedef int (*xfs_rtalloc_query_range_fn)( 2562306a36Sopenharmony_ci struct xfs_mount *mp, 2662306a36Sopenharmony_ci struct xfs_trans *tp, 2762306a36Sopenharmony_ci const struct xfs_rtalloc_rec *rec, 2862306a36Sopenharmony_ci void *priv); 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#ifdef CONFIG_XFS_RT 3162306a36Sopenharmony_ci/* 3262306a36Sopenharmony_ci * Function prototypes for exported functions. 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* 3662306a36Sopenharmony_ci * Allocate an extent in the realtime subvolume, with the usual allocation 3762306a36Sopenharmony_ci * parameters. The length units are all in realtime extents, as is the 3862306a36Sopenharmony_ci * result block number. 3962306a36Sopenharmony_ci */ 4062306a36Sopenharmony_ciint /* error */ 4162306a36Sopenharmony_cixfs_rtallocate_extent( 4262306a36Sopenharmony_ci struct xfs_trans *tp, /* transaction pointer */ 4362306a36Sopenharmony_ci xfs_rtblock_t bno, /* starting block number to allocate */ 4462306a36Sopenharmony_ci xfs_extlen_t minlen, /* minimum length to allocate */ 4562306a36Sopenharmony_ci xfs_extlen_t maxlen, /* maximum length to allocate */ 4662306a36Sopenharmony_ci xfs_extlen_t *len, /* out: actual length allocated */ 4762306a36Sopenharmony_ci int wasdel, /* was a delayed allocation extent */ 4862306a36Sopenharmony_ci xfs_extlen_t prod, /* extent product factor */ 4962306a36Sopenharmony_ci xfs_rtblock_t *rtblock); /* out: start block allocated */ 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci/* 5262306a36Sopenharmony_ci * Free an extent in the realtime subvolume. Length is expressed in 5362306a36Sopenharmony_ci * realtime extents, as is the block number. 5462306a36Sopenharmony_ci */ 5562306a36Sopenharmony_ciint /* error */ 5662306a36Sopenharmony_cixfs_rtfree_extent( 5762306a36Sopenharmony_ci struct xfs_trans *tp, /* transaction pointer */ 5862306a36Sopenharmony_ci xfs_rtblock_t bno, /* starting block number to free */ 5962306a36Sopenharmony_ci xfs_extlen_t len); /* length of extent freed */ 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci/* Same as above, but in units of rt blocks. */ 6262306a36Sopenharmony_ciint xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno, 6362306a36Sopenharmony_ci xfs_filblks_t rtlen); 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* 6662306a36Sopenharmony_ci * Initialize realtime fields in the mount structure. 6762306a36Sopenharmony_ci */ 6862306a36Sopenharmony_ciint /* error */ 6962306a36Sopenharmony_cixfs_rtmount_init( 7062306a36Sopenharmony_ci struct xfs_mount *mp); /* file system mount structure */ 7162306a36Sopenharmony_civoid 7262306a36Sopenharmony_cixfs_rtunmount_inodes( 7362306a36Sopenharmony_ci struct xfs_mount *mp); 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/* 7662306a36Sopenharmony_ci * Get the bitmap and summary inodes into the mount structure 7762306a36Sopenharmony_ci * at mount time. 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ciint /* error */ 8062306a36Sopenharmony_cixfs_rtmount_inodes( 8162306a36Sopenharmony_ci struct xfs_mount *mp); /* file system mount structure */ 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci/* 8462306a36Sopenharmony_ci * Pick an extent for allocation at the start of a new realtime file. 8562306a36Sopenharmony_ci * Use the sequence number stored in the atime field of the bitmap inode. 8662306a36Sopenharmony_ci * Translate this to a fraction of the rtextents, and return the product 8762306a36Sopenharmony_ci * of rtextents and the fraction. 8862306a36Sopenharmony_ci * The fraction sequence is 0, 1/2, 1/4, 3/4, 1/8, ..., 7/8, 1/16, ... 8962306a36Sopenharmony_ci */ 9062306a36Sopenharmony_ciint /* error */ 9162306a36Sopenharmony_cixfs_rtpick_extent( 9262306a36Sopenharmony_ci struct xfs_mount *mp, /* file system mount point */ 9362306a36Sopenharmony_ci struct xfs_trans *tp, /* transaction pointer */ 9462306a36Sopenharmony_ci xfs_extlen_t len, /* allocation length (rtextents) */ 9562306a36Sopenharmony_ci xfs_rtblock_t *pick); /* result rt extent */ 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci/* 9862306a36Sopenharmony_ci * Grow the realtime area of the filesystem. 9962306a36Sopenharmony_ci */ 10062306a36Sopenharmony_ciint 10162306a36Sopenharmony_cixfs_growfs_rt( 10262306a36Sopenharmony_ci struct xfs_mount *mp, /* file system mount structure */ 10362306a36Sopenharmony_ci xfs_growfs_rt_t *in); /* user supplied growfs struct */ 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci/* 10662306a36Sopenharmony_ci * From xfs_rtbitmap.c 10762306a36Sopenharmony_ci */ 10862306a36Sopenharmony_ciint xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, 10962306a36Sopenharmony_ci xfs_rtblock_t block, int issum, struct xfs_buf **bpp); 11062306a36Sopenharmony_ciint xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, 11162306a36Sopenharmony_ci xfs_rtblock_t start, xfs_extlen_t len, int val, 11262306a36Sopenharmony_ci xfs_rtblock_t *new, int *stat); 11362306a36Sopenharmony_ciint xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp, 11462306a36Sopenharmony_ci xfs_rtblock_t start, xfs_rtblock_t limit, 11562306a36Sopenharmony_ci xfs_rtblock_t *rtblock); 11662306a36Sopenharmony_ciint xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp, 11762306a36Sopenharmony_ci xfs_rtblock_t start, xfs_rtblock_t limit, 11862306a36Sopenharmony_ci xfs_rtblock_t *rtblock); 11962306a36Sopenharmony_ciint xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp, 12062306a36Sopenharmony_ci xfs_rtblock_t start, xfs_extlen_t len, int val); 12162306a36Sopenharmony_ciint xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp, 12262306a36Sopenharmony_ci int log, xfs_rtblock_t bbno, int delta, 12362306a36Sopenharmony_ci struct xfs_buf **rbpp, xfs_fsblock_t *rsb, 12462306a36Sopenharmony_ci xfs_suminfo_t *sum); 12562306a36Sopenharmony_ciint xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log, 12662306a36Sopenharmony_ci xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp, 12762306a36Sopenharmony_ci xfs_fsblock_t *rsb); 12862306a36Sopenharmony_ciint xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp, 12962306a36Sopenharmony_ci xfs_rtblock_t start, xfs_extlen_t len, 13062306a36Sopenharmony_ci struct xfs_buf **rbpp, xfs_fsblock_t *rsb); 13162306a36Sopenharmony_ciint xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp, 13262306a36Sopenharmony_ci const struct xfs_rtalloc_rec *low_rec, 13362306a36Sopenharmony_ci const struct xfs_rtalloc_rec *high_rec, 13462306a36Sopenharmony_ci xfs_rtalloc_query_range_fn fn, void *priv); 13562306a36Sopenharmony_ciint xfs_rtalloc_query_all(struct xfs_mount *mp, struct xfs_trans *tp, 13662306a36Sopenharmony_ci xfs_rtalloc_query_range_fn fn, 13762306a36Sopenharmony_ci void *priv); 13862306a36Sopenharmony_cibool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); 13962306a36Sopenharmony_ciint xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp, 14062306a36Sopenharmony_ci xfs_rtblock_t start, xfs_extlen_t len, 14162306a36Sopenharmony_ci bool *is_free); 14262306a36Sopenharmony_ciint xfs_rtalloc_reinit_frextents(struct xfs_mount *mp); 14362306a36Sopenharmony_ci#else 14462306a36Sopenharmony_ci# define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (-ENOSYS) 14562306a36Sopenharmony_ci# define xfs_rtfree_extent(t,b,l) (-ENOSYS) 14662306a36Sopenharmony_ci# define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS) 14762306a36Sopenharmony_ci# define xfs_rtpick_extent(m,t,l,rb) (-ENOSYS) 14862306a36Sopenharmony_ci# define xfs_growfs_rt(mp,in) (-ENOSYS) 14962306a36Sopenharmony_ci# define xfs_rtalloc_query_range(m,t,l,h,f,p) (-ENOSYS) 15062306a36Sopenharmony_ci# define xfs_rtalloc_query_all(m,t,f,p) (-ENOSYS) 15162306a36Sopenharmony_ci# define xfs_rtbuf_get(m,t,b,i,p) (-ENOSYS) 15262306a36Sopenharmony_ci# define xfs_verify_rtbno(m, r) (false) 15362306a36Sopenharmony_ci# define xfs_rtalloc_extent_is_free(m,t,s,l,i) (-ENOSYS) 15462306a36Sopenharmony_ci# define xfs_rtalloc_reinit_frextents(m) (0) 15562306a36Sopenharmony_cistatic inline int /* error */ 15662306a36Sopenharmony_cixfs_rtmount_init( 15762306a36Sopenharmony_ci xfs_mount_t *mp) /* file system mount structure */ 15862306a36Sopenharmony_ci{ 15962306a36Sopenharmony_ci if (mp->m_sb.sb_rblocks == 0) 16062306a36Sopenharmony_ci return 0; 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci xfs_warn(mp, "Not built with CONFIG_XFS_RT"); 16362306a36Sopenharmony_ci return -ENOSYS; 16462306a36Sopenharmony_ci} 16562306a36Sopenharmony_ci# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (-ENOSYS)) 16662306a36Sopenharmony_ci# define xfs_rtunmount_inodes(m) 16762306a36Sopenharmony_ci#endif /* CONFIG_XFS_RT */ 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci#endif /* __XFS_RTALLOC_H__ */ 170