1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 4*4882a593Smuzhiyun * All Rights Reserved. 5*4882a593Smuzhiyun */ 6*4882a593Smuzhiyun #ifndef __XFS_TRANS_RESV_H__ 7*4882a593Smuzhiyun #define __XFS_TRANS_RESV_H__ 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun struct xfs_mount; 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun /* 12*4882a593Smuzhiyun * structure for maintaining pre-calculated transaction reservations. 13*4882a593Smuzhiyun */ 14*4882a593Smuzhiyun struct xfs_trans_res { 15*4882a593Smuzhiyun uint tr_logres; /* log space unit in bytes per log ticket */ 16*4882a593Smuzhiyun int tr_logcount; /* number of log operations per log ticket */ 17*4882a593Smuzhiyun int tr_logflags; /* log flags, currently only used for indicating 18*4882a593Smuzhiyun * a reservation request is permanent or not */ 19*4882a593Smuzhiyun }; 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun struct xfs_trans_resv { 22*4882a593Smuzhiyun struct xfs_trans_res tr_write; /* extent alloc trans */ 23*4882a593Smuzhiyun struct xfs_trans_res tr_itruncate; /* truncate trans */ 24*4882a593Smuzhiyun struct xfs_trans_res tr_rename; /* rename trans */ 25*4882a593Smuzhiyun struct xfs_trans_res tr_link; /* link trans */ 26*4882a593Smuzhiyun struct xfs_trans_res tr_remove; /* unlink trans */ 27*4882a593Smuzhiyun struct xfs_trans_res tr_symlink; /* symlink trans */ 28*4882a593Smuzhiyun struct xfs_trans_res tr_create; /* create trans */ 29*4882a593Smuzhiyun struct xfs_trans_res tr_create_tmpfile; /* create O_TMPFILE trans */ 30*4882a593Smuzhiyun struct xfs_trans_res tr_mkdir; /* mkdir trans */ 31*4882a593Smuzhiyun struct xfs_trans_res tr_ifree; /* inode free trans */ 32*4882a593Smuzhiyun struct xfs_trans_res tr_ichange; /* inode update trans */ 33*4882a593Smuzhiyun struct xfs_trans_res tr_growdata; /* fs data section grow trans */ 34*4882a593Smuzhiyun struct xfs_trans_res tr_addafork; /* add inode attr fork trans */ 35*4882a593Smuzhiyun struct xfs_trans_res tr_writeid; /* write setuid/setgid file */ 36*4882a593Smuzhiyun struct xfs_trans_res tr_attrinval; /* attr fork buffer 37*4882a593Smuzhiyun * invalidation */ 38*4882a593Smuzhiyun struct xfs_trans_res tr_attrsetm; /* set/create an attribute at 39*4882a593Smuzhiyun * mount time */ 40*4882a593Smuzhiyun struct xfs_trans_res tr_attrsetrt; /* set/create an attribute at 41*4882a593Smuzhiyun * runtime */ 42*4882a593Smuzhiyun struct xfs_trans_res tr_attrrm; /* remove an attribute */ 43*4882a593Smuzhiyun struct xfs_trans_res tr_clearagi; /* clear agi unlinked bucket */ 44*4882a593Smuzhiyun struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */ 45*4882a593Smuzhiyun struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */ 46*4882a593Smuzhiyun struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ 47*4882a593Smuzhiyun struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ 48*4882a593Smuzhiyun struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ 49*4882a593Smuzhiyun struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */ 50*4882a593Smuzhiyun struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */ 51*4882a593Smuzhiyun struct xfs_trans_res tr_sb; /* modify superblock */ 52*4882a593Smuzhiyun struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */ 53*4882a593Smuzhiyun }; 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun /* shorthand way of accessing reservation structure */ 56*4882a593Smuzhiyun #define M_RES(mp) (&(mp)->m_resv) 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun /* 59*4882a593Smuzhiyun * Per-directory log reservation for any directory change. 60*4882a593Smuzhiyun * dir blocks: (1 btree block per level + data block + free block) * dblock size 61*4882a593Smuzhiyun * bmap btree: (levels + 2) * max depth * block size 62*4882a593Smuzhiyun * v2 directory blocks can be fragmented below the dirblksize down to the fsb 63*4882a593Smuzhiyun * size, so account for that in the DAENTER macros. 64*4882a593Smuzhiyun */ 65*4882a593Smuzhiyun #define XFS_DIROP_LOG_RES(mp) \ 66*4882a593Smuzhiyun (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \ 67*4882a593Smuzhiyun (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1))) 68*4882a593Smuzhiyun #define XFS_DIROP_LOG_COUNT(mp) \ 69*4882a593Smuzhiyun (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \ 70*4882a593Smuzhiyun XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1) 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun /* 73*4882a593Smuzhiyun * Various log count values. 74*4882a593Smuzhiyun */ 75*4882a593Smuzhiyun #define XFS_DEFAULT_LOG_COUNT 1 76*4882a593Smuzhiyun #define XFS_DEFAULT_PERM_LOG_COUNT 2 77*4882a593Smuzhiyun #define XFS_ITRUNCATE_LOG_COUNT 2 78*4882a593Smuzhiyun #define XFS_ITRUNCATE_LOG_COUNT_REFLINK 8 79*4882a593Smuzhiyun #define XFS_INACTIVE_LOG_COUNT 2 80*4882a593Smuzhiyun #define XFS_CREATE_LOG_COUNT 2 81*4882a593Smuzhiyun #define XFS_CREATE_TMPFILE_LOG_COUNT 2 82*4882a593Smuzhiyun #define XFS_MKDIR_LOG_COUNT 3 83*4882a593Smuzhiyun #define XFS_SYMLINK_LOG_COUNT 3 84*4882a593Smuzhiyun #define XFS_REMOVE_LOG_COUNT 2 85*4882a593Smuzhiyun #define XFS_LINK_LOG_COUNT 2 86*4882a593Smuzhiyun #define XFS_RENAME_LOG_COUNT 2 87*4882a593Smuzhiyun #define XFS_WRITE_LOG_COUNT 2 88*4882a593Smuzhiyun #define XFS_WRITE_LOG_COUNT_REFLINK 8 89*4882a593Smuzhiyun #define XFS_ADDAFORK_LOG_COUNT 2 90*4882a593Smuzhiyun #define XFS_ATTRINVAL_LOG_COUNT 1 91*4882a593Smuzhiyun #define XFS_ATTRSET_LOG_COUNT 3 92*4882a593Smuzhiyun #define XFS_ATTRRM_LOG_COUNT 3 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp); 95*4882a593Smuzhiyun uint xfs_allocfree_log_count(struct xfs_mount *mp, uint num_ops); 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun #endif /* __XFS_TRANS_RESV_H__ */ 98