2018-06-05 19:42:14 -07:00
// SPDX-License-Identifier: GPL-2.0
2005-04-16 15:20:36 -07:00
/*
2005-11-02 14:58:39 +11:00
* Copyright ( c ) 2000 , 2005 Silicon Graphics , Inc .
* All Rights Reserved .
2005-04-16 15:20:36 -07:00
*/
# ifndef __XFS_IALLOC_H__
# define __XFS_IALLOC_H__
struct xfs_buf ;
struct xfs_dinode ;
2008-11-28 14:23:41 +11:00
struct xfs_imap ;
2005-04-16 15:20:36 -07:00
struct xfs_mount ;
struct xfs_trans ;
2013-10-23 10:51:50 +11:00
struct xfs_btree_cur ;
2023-02-13 09:14:52 +11:00
struct xfs_perag ;
2005-04-16 15:20:36 -07:00
2013-12-13 15:51:48 +11:00
/* Move inodes in clusters of this size */
2005-04-16 15:20:36 -07:00
# define XFS_INODE_BIG_CLUSTER_SIZE 8192
2015-05-29 09:26:03 +10:00
struct xfs_icluster {
bool deleted ; /* record is deleted */
xfs_ino_t first_ino ; /* first inode number */
uint64_t alloc ; /* inode phys. allocation bitmap for
* sparse chunks */
} ;
2005-04-16 15:20:36 -07:00
/*
* Make an inode pointer out of the buffer / offset .
*/
2005-11-02 14:38:42 +11:00
static inline struct xfs_dinode *
xfs_make_iptr ( struct xfs_mount * mp , struct xfs_buf * b , int o )
{
2015-06-22 09:44:29 +10:00
return xfs_buf_offset ( b , o < < ( mp ) - > m_sb . sb_inodelog ) ;
2005-11-02 14:38:42 +11:00
}
2005-04-16 15:20:36 -07:00
/*
2021-06-02 10:48:24 +10:00
* Allocate an inode on disk . Mode is used to tell whether the new inode will
* need space , and whether it is a directory .
2005-04-16 15:20:36 -07:00
*/
2021-06-02 10:48:24 +10:00
int xfs_dialloc ( struct xfs_trans * * tpp , xfs_ino_t parent , umode_t mode ,
xfs_ino_t * new_ino ) ;
2005-04-16 15:20:36 -07:00
2021-06-02 10:48:51 +10:00
int xfs_difree ( struct xfs_trans * tp , struct xfs_perag * pag ,
xfs_ino_t ino , struct xfs_icluster * ifree ) ;
2005-04-16 15:20:36 -07:00
/*
2008-11-28 14:23:41 +11:00
* Return the location of the inode in imap , for mapping it into a buffer .
2005-04-16 15:20:36 -07:00
*/
int
2008-11-28 14:23:41 +11:00
xfs_imap (
2023-02-13 09:14:52 +11:00
struct xfs_perag * pag ,
2005-04-16 15:20:36 -07:00
struct xfs_trans * tp , /* transaction pointer */
xfs_ino_t ino , /* inode to locate */
2008-11-28 14:23:41 +11:00
struct xfs_imap * imap , /* location map structure */
2005-04-16 15:20:36 -07:00
uint flags ) ; /* flags for inode btree lookup */
/*
* Log specified fields for the ag hdr ( inode section )
*/
void
xfs_ialloc_log_agi (
struct xfs_trans * tp , /* transaction pointer */
struct xfs_buf * bp , /* allocation group header buffer */
2022-04-21 10:46:24 +10:00
uint32_t fields ) ; /* bitmask of fields to log */
2005-04-16 15:20:36 -07:00
2022-07-07 19:07:47 +10:00
int xfs_read_agi ( struct xfs_perag * pag , struct xfs_trans * tp ,
struct xfs_buf * * agibpp ) ;
int xfs_ialloc_read_agi ( struct xfs_perag * pag , struct xfs_trans * tp ,
2022-07-07 19:07:24 +10:00
struct xfs_buf * * agibpp ) ;
2005-04-16 15:20:36 -07:00
2008-10-30 16:56:09 +11:00
/*
2009-08-31 20:58:21 -03:00
* Lookup a record by ino in the btree given by cur .
2008-10-30 16:56:09 +11:00
*/
2009-08-31 20:58:21 -03:00
int xfs_inobt_lookup ( struct xfs_btree_cur * cur , xfs_agino_t ino ,
xfs_lookup_t dir , int * stat ) ;
2008-10-30 16:56:09 +11:00
2008-10-30 16:58:11 +11:00
/*
* Get the data from the pointed - to record .
*/
2012-11-14 17:53:49 +11:00
int xfs_inobt_get_rec ( struct xfs_btree_cur * cur ,
2009-08-31 20:56:58 -03:00
xfs_inobt_rec_incore_t * rec , int * stat ) ;
2008-10-30 16:56:09 +11:00
2013-06-27 16:04:55 +10:00
/*
* Inode chunk initialisation routine
*/
int xfs_ialloc_inode_init ( struct xfs_mount * mp , struct xfs_trans * tp ,
2015-05-29 09:05:49 +10:00
struct list_head * buffer_list , int icount ,
2013-06-27 16:04:55 +10:00
xfs_agnumber_t agno , xfs_agblock_t agbno ,
xfs_agblock_t length , unsigned int gen ) ;
2014-11-28 14:25:04 +11:00
2017-06-16 11:00:08 -07:00
union xfs_btree_rec ;
2021-08-10 17:02:16 -07:00
void xfs_inobt_btrec_to_irec ( struct xfs_mount * mp ,
const union xfs_btree_rec * rec ,
2017-06-16 11:00:08 -07:00
struct xfs_inobt_rec_incore * irec ) ;
2023-04-11 19:00:01 -07:00
xfs_failaddr_t xfs_inobt_check_irec ( struct xfs_btree_cur * cur ,
const struct xfs_inobt_rec_incore * irec ) ;
2018-01-16 18:52:12 -08:00
int xfs_ialloc_has_inodes_at_extent ( struct xfs_btree_cur * cur ,
xfs_agblock_t bno , xfs_extlen_t len , bool * exists ) ;
int xfs_ialloc_has_inode_record ( struct xfs_btree_cur * cur , xfs_agino_t low ,
xfs_agino_t high , bool * exists ) ;
int xfs_ialloc_count_inodes ( struct xfs_btree_cur * cur , xfs_agino_t * count ,
xfs_agino_t * freecount ) ;
2018-05-09 10:02:02 -07:00
int xfs_inobt_insert_rec ( struct xfs_btree_cur * cur , uint16_t holemask ,
uint8_t count , int32_t freecount , xfs_inofree_t free ,
int * stat ) ;
2017-06-16 11:00:08 -07:00
int xfs_ialloc_cluster_alignment ( struct xfs_mount * mp ) ;
2019-06-05 11:19:35 -07:00
void xfs_ialloc_setup_geometry ( struct xfs_mount * mp ) ;
2019-12-11 13:19:06 -08:00
xfs_ino_t xfs_ialloc_calc_rootino ( struct xfs_mount * mp , int sunit ) ;
2014-11-28 14:25:04 +11:00
2023-02-13 09:14:52 +11:00
int xfs_ialloc_check_shrink ( struct xfs_perag * pag , struct xfs_trans * tp ,
2021-07-12 12:58:47 -07:00
struct xfs_buf * agibp , xfs_agblock_t new_length ) ;
2005-04-16 15:20:36 -07:00
# endif /* __XFS_IALLOC_H__ */