Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_RTALLOC_H__
0007 #define __XFS_RTALLOC_H__
0008 
0009 /* kernel only definitions and functions */
0010 
0011 struct xfs_mount;
0012 struct xfs_trans;
0013 
0014 /*
0015  * XXX: Most of the realtime allocation functions deal in units of realtime
0016  * extents, not realtime blocks.  This looks funny when paired with the type
0017  * name and screams for a larger cleanup.
0018  */
0019 struct xfs_rtalloc_rec {
0020     xfs_rtblock_t       ar_startext;
0021     xfs_rtblock_t       ar_extcount;
0022 };
0023 
0024 typedef int (*xfs_rtalloc_query_range_fn)(
0025     struct xfs_mount        *mp,
0026     struct xfs_trans        *tp,
0027     const struct xfs_rtalloc_rec    *rec,
0028     void                *priv);
0029 
0030 #ifdef CONFIG_XFS_RT
0031 /*
0032  * Function prototypes for exported functions.
0033  */
0034 
0035 /*
0036  * Allocate an extent in the realtime subvolume, with the usual allocation
0037  * parameters.  The length units are all in realtime extents, as is the
0038  * result block number.
0039  */
0040 int                 /* error */
0041 xfs_rtallocate_extent(
0042     struct xfs_trans    *tp,    /* transaction pointer */
0043     xfs_rtblock_t       bno,    /* starting block number to allocate */
0044     xfs_extlen_t        minlen, /* minimum length to allocate */
0045     xfs_extlen_t        maxlen, /* maximum length to allocate */
0046     xfs_extlen_t        *len,   /* out: actual length allocated */
0047     int         wasdel, /* was a delayed allocation extent */
0048     xfs_extlen_t        prod,   /* extent product factor */
0049     xfs_rtblock_t       *rtblock); /* out: start block allocated */
0050 
0051 /*
0052  * Free an extent in the realtime subvolume.  Length is expressed in
0053  * realtime extents, as is the block number.
0054  */
0055 int                 /* error */
0056 xfs_rtfree_extent(
0057     struct xfs_trans    *tp,    /* transaction pointer */
0058     xfs_rtblock_t       bno,    /* starting block number to free */
0059     xfs_extlen_t        len);   /* length of extent freed */
0060 
0061 /*
0062  * Initialize realtime fields in the mount structure.
0063  */
0064 int                 /* error */
0065 xfs_rtmount_init(
0066     struct xfs_mount    *mp);   /* file system mount structure */
0067 void
0068 xfs_rtunmount_inodes(
0069     struct xfs_mount    *mp);
0070 
0071 /*
0072  * Get the bitmap and summary inodes into the mount structure
0073  * at mount time.
0074  */
0075 int                 /* error */
0076 xfs_rtmount_inodes(
0077     struct xfs_mount    *mp);   /* file system mount structure */
0078 
0079 /*
0080  * Pick an extent for allocation at the start of a new realtime file.
0081  * Use the sequence number stored in the atime field of the bitmap inode.
0082  * Translate this to a fraction of the rtextents, and return the product
0083  * of rtextents and the fraction.
0084  * The fraction sequence is 0, 1/2, 1/4, 3/4, 1/8, ..., 7/8, 1/16, ...
0085  */
0086 int                 /* error */
0087 xfs_rtpick_extent(
0088     struct xfs_mount    *mp,    /* file system mount point */
0089     struct xfs_trans    *tp,    /* transaction pointer */
0090     xfs_extlen_t        len,    /* allocation length (rtextents) */
0091     xfs_rtblock_t       *pick); /* result rt extent */
0092 
0093 /*
0094  * Grow the realtime area of the filesystem.
0095  */
0096 int
0097 xfs_growfs_rt(
0098     struct xfs_mount    *mp,    /* file system mount structure */
0099     xfs_growfs_rt_t     *in);   /* user supplied growfs struct */
0100 
0101 /*
0102  * From xfs_rtbitmap.c
0103  */
0104 int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp,
0105           xfs_rtblock_t block, int issum, struct xfs_buf **bpp);
0106 int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp,
0107               xfs_rtblock_t start, xfs_extlen_t len, int val,
0108               xfs_rtblock_t *new, int *stat);
0109 int xfs_rtfind_back(struct xfs_mount *mp, struct xfs_trans *tp,
0110             xfs_rtblock_t start, xfs_rtblock_t limit,
0111             xfs_rtblock_t *rtblock);
0112 int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp,
0113             xfs_rtblock_t start, xfs_rtblock_t limit,
0114             xfs_rtblock_t *rtblock);
0115 int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp,
0116                xfs_rtblock_t start, xfs_extlen_t len, int val);
0117 int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp,
0118                  int log, xfs_rtblock_t bbno, int delta,
0119                  struct xfs_buf **rbpp, xfs_fsblock_t *rsb,
0120                  xfs_suminfo_t *sum);
0121 int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log,
0122              xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp,
0123              xfs_fsblock_t *rsb);
0124 int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp,
0125              xfs_rtblock_t start, xfs_extlen_t len,
0126              struct xfs_buf **rbpp, xfs_fsblock_t *rsb);
0127 int xfs_rtalloc_query_range(struct xfs_mount *mp, struct xfs_trans *tp,
0128         const struct xfs_rtalloc_rec *low_rec,
0129         const struct xfs_rtalloc_rec *high_rec,
0130         xfs_rtalloc_query_range_fn fn, void *priv);
0131 int xfs_rtalloc_query_all(struct xfs_mount *mp, struct xfs_trans *tp,
0132               xfs_rtalloc_query_range_fn fn,
0133               void *priv);
0134 bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
0135 int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp,
0136                    xfs_rtblock_t start, xfs_extlen_t len,
0137                    bool *is_free);
0138 int xfs_rtalloc_reinit_frextents(struct xfs_mount *mp);
0139 #else
0140 # define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb)    (ENOSYS)
0141 # define xfs_rtfree_extent(t,b,l)                       (ENOSYS)
0142 # define xfs_rtpick_extent(m,t,l,rb)                    (ENOSYS)
0143 # define xfs_growfs_rt(mp,in)                           (ENOSYS)
0144 # define xfs_rtalloc_query_range(t,l,h,f,p)             (ENOSYS)
0145 # define xfs_rtalloc_query_all(m,t,f,p)                 (ENOSYS)
0146 # define xfs_rtbuf_get(m,t,b,i,p)                       (ENOSYS)
0147 # define xfs_verify_rtbno(m, r)         (false)
0148 # define xfs_rtalloc_extent_is_free(m,t,s,l,i)          (ENOSYS)
0149 # define xfs_rtalloc_reinit_frextents(m)                (0)
0150 static inline int       /* error */
0151 xfs_rtmount_init(
0152     xfs_mount_t *mp)    /* file system mount structure */
0153 {
0154     if (mp->m_sb.sb_rblocks == 0)
0155         return 0;
0156 
0157     xfs_warn(mp, "Not built with CONFIG_XFS_RT");
0158     return -ENOSYS;
0159 }
0160 # define xfs_rtmount_inodes(m)  (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
0161 # define xfs_rtunmount_inodes(m)
0162 #endif  /* CONFIG_XFS_RT */
0163 
0164 #endif  /* __XFS_RTALLOC_H__ */