162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 462306a36Sopenharmony_ci * All Rights Reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef __XFS_TRANS_RESV_H__ 762306a36Sopenharmony_ci#define __XFS_TRANS_RESV_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_cistruct xfs_mount; 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/* 1262306a36Sopenharmony_ci * structure for maintaining pre-calculated transaction reservations. 1362306a36Sopenharmony_ci */ 1462306a36Sopenharmony_cistruct xfs_trans_res { 1562306a36Sopenharmony_ci uint tr_logres; /* log space unit in bytes per log ticket */ 1662306a36Sopenharmony_ci int tr_logcount; /* number of log operations per log ticket */ 1762306a36Sopenharmony_ci int tr_logflags; /* log flags, currently only used for indicating 1862306a36Sopenharmony_ci * a reservation request is permanent or not */ 1962306a36Sopenharmony_ci}; 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_cistruct xfs_trans_resv { 2262306a36Sopenharmony_ci struct xfs_trans_res tr_write; /* extent alloc trans */ 2362306a36Sopenharmony_ci struct xfs_trans_res tr_itruncate; /* truncate trans */ 2462306a36Sopenharmony_ci struct xfs_trans_res tr_rename; /* rename trans */ 2562306a36Sopenharmony_ci struct xfs_trans_res tr_link; /* link trans */ 2662306a36Sopenharmony_ci struct xfs_trans_res tr_remove; /* unlink trans */ 2762306a36Sopenharmony_ci struct xfs_trans_res tr_symlink; /* symlink trans */ 2862306a36Sopenharmony_ci struct xfs_trans_res tr_create; /* create trans */ 2962306a36Sopenharmony_ci struct xfs_trans_res tr_create_tmpfile; /* create O_TMPFILE trans */ 3062306a36Sopenharmony_ci struct xfs_trans_res tr_mkdir; /* mkdir trans */ 3162306a36Sopenharmony_ci struct xfs_trans_res tr_ifree; /* inode free trans */ 3262306a36Sopenharmony_ci struct xfs_trans_res tr_ichange; /* inode update trans */ 3362306a36Sopenharmony_ci struct xfs_trans_res tr_growdata; /* fs data section grow trans */ 3462306a36Sopenharmony_ci struct xfs_trans_res tr_addafork; /* add inode attr fork trans */ 3562306a36Sopenharmony_ci struct xfs_trans_res tr_writeid; /* write setuid/setgid file */ 3662306a36Sopenharmony_ci struct xfs_trans_res tr_attrinval; /* attr fork buffer 3762306a36Sopenharmony_ci * invalidation */ 3862306a36Sopenharmony_ci struct xfs_trans_res tr_attrsetm; /* set/create an attribute at 3962306a36Sopenharmony_ci * mount time */ 4062306a36Sopenharmony_ci struct xfs_trans_res tr_attrsetrt; /* set/create an attribute at 4162306a36Sopenharmony_ci * runtime */ 4262306a36Sopenharmony_ci struct xfs_trans_res tr_attrrm; /* remove an attribute */ 4362306a36Sopenharmony_ci struct xfs_trans_res tr_clearagi; /* clear agi unlinked bucket */ 4462306a36Sopenharmony_ci struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */ 4562306a36Sopenharmony_ci struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */ 4662306a36Sopenharmony_ci struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ 4762306a36Sopenharmony_ci struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ 4862306a36Sopenharmony_ci struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ 4962306a36Sopenharmony_ci struct xfs_trans_res tr_sb; /* modify superblock */ 5062306a36Sopenharmony_ci struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */ 5162306a36Sopenharmony_ci}; 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci/* shorthand way of accessing reservation structure */ 5462306a36Sopenharmony_ci#define M_RES(mp) (&(mp)->m_resv) 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci/* 5762306a36Sopenharmony_ci * Per-directory log reservation for any directory change. 5862306a36Sopenharmony_ci * dir blocks: (1 btree block per level + data block + free block) * dblock size 5962306a36Sopenharmony_ci * bmap btree: (levels + 2) * max depth * block size 6062306a36Sopenharmony_ci * v2 directory blocks can be fragmented below the dirblksize down to the fsb 6162306a36Sopenharmony_ci * size, so account for that in the DAENTER macros. 6262306a36Sopenharmony_ci */ 6362306a36Sopenharmony_ci#define XFS_DIROP_LOG_RES(mp) \ 6462306a36Sopenharmony_ci (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \ 6562306a36Sopenharmony_ci (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1))) 6662306a36Sopenharmony_ci#define XFS_DIROP_LOG_COUNT(mp) \ 6762306a36Sopenharmony_ci (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \ 6862306a36Sopenharmony_ci XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1) 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci/* 7162306a36Sopenharmony_ci * Various log count values. 7262306a36Sopenharmony_ci */ 7362306a36Sopenharmony_ci#define XFS_DEFAULT_LOG_COUNT 1 7462306a36Sopenharmony_ci#define XFS_DEFAULT_PERM_LOG_COUNT 2 7562306a36Sopenharmony_ci#define XFS_ITRUNCATE_LOG_COUNT 2 7662306a36Sopenharmony_ci#define XFS_INACTIVE_LOG_COUNT 2 7762306a36Sopenharmony_ci#define XFS_CREATE_LOG_COUNT 2 7862306a36Sopenharmony_ci#define XFS_CREATE_TMPFILE_LOG_COUNT 2 7962306a36Sopenharmony_ci#define XFS_MKDIR_LOG_COUNT 3 8062306a36Sopenharmony_ci#define XFS_SYMLINK_LOG_COUNT 3 8162306a36Sopenharmony_ci#define XFS_REMOVE_LOG_COUNT 2 8262306a36Sopenharmony_ci#define XFS_LINK_LOG_COUNT 2 8362306a36Sopenharmony_ci#define XFS_RENAME_LOG_COUNT 2 8462306a36Sopenharmony_ci#define XFS_WRITE_LOG_COUNT 2 8562306a36Sopenharmony_ci#define XFS_ADDAFORK_LOG_COUNT 2 8662306a36Sopenharmony_ci#define XFS_ATTRINVAL_LOG_COUNT 1 8762306a36Sopenharmony_ci#define XFS_ATTRSET_LOG_COUNT 3 8862306a36Sopenharmony_ci#define XFS_ATTRRM_LOG_COUNT 3 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* 9162306a36Sopenharmony_ci * Original log operation counts were overestimated in the early days of 9262306a36Sopenharmony_ci * reflink. These are retained here purely for minimum log size calculations 9362306a36Sopenharmony_ci * and must not be used for runtime reservations. 9462306a36Sopenharmony_ci */ 9562306a36Sopenharmony_ci#define XFS_ITRUNCATE_LOG_COUNT_REFLINK 8 9662306a36Sopenharmony_ci#define XFS_WRITE_LOG_COUNT_REFLINK 8 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_civoid xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp); 9962306a36Sopenharmony_ciuint xfs_allocfree_block_count(struct xfs_mount *mp, uint num_ops); 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ciunsigned int xfs_calc_itruncate_reservation_minlogsize(struct xfs_mount *mp); 10262306a36Sopenharmony_ciunsigned int xfs_calc_write_reservation_minlogsize(struct xfs_mount *mp); 10362306a36Sopenharmony_ciunsigned int xfs_calc_qm_dqalloc_reservation_minlogsize(struct xfs_mount *mp); 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci#endif /* __XFS_TRANS_RESV_H__ */ 106