]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - libxfs/xfs_ialloc.h
xfs: pass perag to xfs_ialloc_read_agi()
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_ialloc.h
index 77fffced8bac42418b269f359138f8a0ebf9dc2f..72cb33170d9fe35e8f1dafc87e1feeb1cd3790c6 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_IALLOC_H__
 #define        __XFS_IALLOC_H__
@@ -35,16 +23,6 @@ struct xfs_icluster {
                                         * sparse chunks */
 };
 
-/* Calculate and return the number of filesystem blocks per inode cluster */
-static inline int
-xfs_icluster_size_fsb(
-       struct xfs_mount        *mp)
-{
-       if (mp->m_sb.sb_blocksize >= mp->m_inode_cluster_size)
-               return 1;
-       return mp->m_inode_cluster_size >> mp->m_sb.sb_blocklog;
-}
-
 /*
  * Make an inode pointer out of the buffer/offset.
  */
@@ -55,47 +33,14 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
 }
 
 /*
- * Allocate an inode on disk.
- * Mode is used to tell whether the new inode will need space, and whether
- * it is a directory.
- *
- * To work within the constraint of one allocation per transaction,
- * xfs_dialloc() is designed to be called twice if it has to do an
- * allocation to make more free inodes.  If an inode is
- * available without an allocation, agbp would be set to the current
- * agbp and alloc_done set to false.
- * If an allocation needed to be done, agbp would be set to the
- * inode header of the allocation group and alloc_done set to true.
- * The caller should then commit the current transaction and allocate a new
- * transaction.  xfs_dialloc() should then be called again with
- * the agbp value returned from the previous call.
- *
- * Once we successfully pick an inode its number is returned and the
- * on-disk data structures are updated.  The inode itself is not read
- * in, since doing so would break ordering constraints with xfs_reclaim.
- *
- * *agbp should be set to NULL on the first call, *alloc_done set to FALSE.
+ * Allocate an inode on disk.  Mode is used to tell whether the new inode will
+ * need space, and whether it is a directory.
  */
-int                                    /* error */
-xfs_dialloc(
-       struct xfs_trans *tp,           /* transaction pointer */
-       xfs_ino_t       parent,         /* parent inode (directory) */
-       umode_t         mode,           /* mode bits for new inode */
-       struct xfs_buf  **agbp,         /* buf for a.g. inode header */
-       xfs_ino_t       *inop);         /* inode number allocated */
+int xfs_dialloc(struct xfs_trans **tpp, xfs_ino_t parent, umode_t mode,
+               xfs_ino_t *new_ino);
 
-/*
- * Free disk inode.  Carefully avoids touching the incore inode, all
- * manipulations incore are the caller's responsibility.
- * The on-disk inode is not changed by this operation, only the
- * btree (free inode mask) is changed.
- */
-int                                    /* error */
-xfs_difree(
-       struct xfs_trans *tp,           /* transaction pointer */
-       xfs_ino_t       inode,          /* inode to be freed */
-       struct xfs_defer_ops *dfops,    /* extents to free */
-       struct xfs_icluster *ifree);    /* cluster info if deleted */
+int xfs_difree(struct xfs_trans *tp, struct xfs_perag *pag,
+               xfs_ino_t ino, struct xfs_icluster *ifree);
 
 /*
  * Return the location of the inode in imap, for mapping it into a buffer.
@@ -108,13 +53,6 @@ xfs_imap(
        struct xfs_imap *imap,          /* location map structure */
        uint            flags);         /* flags for inode btree lookup */
 
-/*
- * Compute and fill in value of m_in_maxlevels.
- */
-void
-xfs_ialloc_compute_maxlevels(
-       struct xfs_mount *mp);          /* file system mount structure */
-
 /*
  * Log specified fields for the ag hdr (inode section)
  */
@@ -122,27 +60,14 @@ void
 xfs_ialloc_log_agi(
        struct xfs_trans *tp,           /* transaction pointer */
        struct xfs_buf  *bp,            /* allocation group header buffer */
-       int             fields);        /* bitmask of fields to log */
+       uint32_t        fields);        /* bitmask of fields to log */
 
 /*
  * Read in the allocation group header (inode allocation section)
  */
 int                                    /* error */
-xfs_ialloc_read_agi(
-       struct xfs_mount *mp,           /* file system mount structure */
-       struct xfs_trans *tp,           /* transaction pointer */
-       xfs_agnumber_t  agno,           /* allocation group number */
-       struct xfs_buf  **bpp);         /* allocation group hdr buf */
-
-/*
- * Read in the allocation group header to initialise the per-ag data
- * in the mount structure
- */
-int
-xfs_ialloc_pagi_init(
-       struct xfs_mount *mp,           /* file system mount structure */
-       struct xfs_trans *tp,           /* transaction pointer */
-        xfs_agnumber_t  agno);         /* allocation group number */
+xfs_ialloc_read_agi(struct xfs_perag *pag, struct xfs_trans *tp,
+               struct xfs_buf **agibpp);
 
 /*
  * Lookup a record by ino in the btree given by cur.
@@ -168,7 +93,8 @@ int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
                xfs_agnumber_t agno, struct xfs_buf **bpp);
 
 union xfs_btree_rec;
-void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, union xfs_btree_rec *rec,
+void xfs_inobt_btrec_to_irec(struct xfs_mount *mp,
+               const union xfs_btree_rec *rec,
                struct xfs_inobt_rec_incore *irec);
 int xfs_ialloc_has_inodes_at_extent(struct xfs_btree_cur *cur,
                xfs_agblock_t bno, xfs_extlen_t len, bool *exists);
@@ -181,12 +107,10 @@ int xfs_inobt_insert_rec(struct xfs_btree_cur *cur, uint16_t holemask,
                int *stat);
 
 int xfs_ialloc_cluster_alignment(struct xfs_mount *mp);
-void xfs_ialloc_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno,
-               xfs_agino_t *first, xfs_agino_t *last);
-bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno,
-               xfs_agino_t agino);
-bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino);
-bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino);
-bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino);
+void xfs_ialloc_setup_geometry(struct xfs_mount *mp);
+xfs_ino_t xfs_ialloc_calc_rootino(struct xfs_mount *mp, int sunit);
+
+int xfs_ialloc_check_shrink(struct xfs_trans *tp, xfs_agnumber_t agno,
+               struct xfs_buf *agibp, xfs_agblock_t new_length);
 
 #endif /* __XFS_IALLOC_H__ */