Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_TRANS_RESV_H__
0007 #define __XFS_TRANS_RESV_H__
0008 
0009 struct xfs_mount;
0010 
0011 /*
0012  * structure for maintaining pre-calculated transaction reservations.
0013  */
0014 struct xfs_trans_res {
0015     uint    tr_logres;  /* log space unit in bytes per log ticket */
0016     int tr_logcount;    /* number of log operations per log ticket */
0017     int tr_logflags;    /* log flags, currently only used for indicating
0018                  * a reservation request is permanent or not */
0019 };
0020 
0021 struct xfs_trans_resv {
0022     struct xfs_trans_res    tr_write;   /* extent alloc trans */
0023     struct xfs_trans_res    tr_itruncate;   /* truncate trans */
0024     struct xfs_trans_res    tr_rename;  /* rename trans */
0025     struct xfs_trans_res    tr_link;    /* link trans */
0026     struct xfs_trans_res    tr_remove;  /* unlink trans */
0027     struct xfs_trans_res    tr_symlink; /* symlink trans */
0028     struct xfs_trans_res    tr_create;  /* create trans */
0029     struct xfs_trans_res    tr_create_tmpfile; /* create O_TMPFILE trans */
0030     struct xfs_trans_res    tr_mkdir;   /* mkdir trans */
0031     struct xfs_trans_res    tr_ifree;   /* inode free trans */
0032     struct xfs_trans_res    tr_ichange; /* inode update trans */
0033     struct xfs_trans_res    tr_growdata;    /* fs data section grow trans */
0034     struct xfs_trans_res    tr_addafork;    /* add inode attr fork trans */
0035     struct xfs_trans_res    tr_writeid; /* write setuid/setgid file */
0036     struct xfs_trans_res    tr_attrinval;   /* attr fork buffer
0037                          * invalidation */
0038     struct xfs_trans_res    tr_attrsetm;    /* set/create an attribute at
0039                          * mount time */
0040     struct xfs_trans_res    tr_attrsetrt;   /* set/create an attribute at
0041                          * runtime */
0042     struct xfs_trans_res    tr_attrrm;  /* remove an attribute */
0043     struct xfs_trans_res    tr_clearagi;    /* clear agi unlinked bucket */
0044     struct xfs_trans_res    tr_growrtalloc; /* grow realtime allocations */
0045     struct xfs_trans_res    tr_growrtzero;  /* grow realtime zeroing */
0046     struct xfs_trans_res    tr_growrtfree;  /* grow realtime freeing */
0047     struct xfs_trans_res    tr_qm_setqlim;  /* adjust quota limits */
0048     struct xfs_trans_res    tr_qm_dqalloc;  /* allocate quota on disk */
0049     struct xfs_trans_res    tr_sb;      /* modify superblock */
0050     struct xfs_trans_res    tr_fsyncts; /* update timestamps on fsync */
0051 };
0052 
0053 /* shorthand way of accessing reservation structure */
0054 #define M_RES(mp)   (&(mp)->m_resv)
0055 
0056 /*
0057  * Per-directory log reservation for any directory change.
0058  * dir blocks: (1 btree block per level + data block + free block) * dblock size
0059  * bmap btree: (levels + 2) * max depth * block size
0060  * v2 directory blocks can be fragmented below the dirblksize down to the fsb
0061  * size, so account for that in the DAENTER macros.
0062  */
0063 #define XFS_DIROP_LOG_RES(mp)   \
0064     (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \
0065      (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)))
0066 #define XFS_DIROP_LOG_COUNT(mp) \
0067     (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \
0068      XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)
0069 
0070 /*
0071  * Various log count values.
0072  */
0073 #define XFS_DEFAULT_LOG_COUNT       1
0074 #define XFS_DEFAULT_PERM_LOG_COUNT  2
0075 #define XFS_ITRUNCATE_LOG_COUNT     2
0076 #define XFS_INACTIVE_LOG_COUNT      2
0077 #define XFS_CREATE_LOG_COUNT        2
0078 #define XFS_CREATE_TMPFILE_LOG_COUNT    2
0079 #define XFS_MKDIR_LOG_COUNT     3
0080 #define XFS_SYMLINK_LOG_COUNT       3
0081 #define XFS_REMOVE_LOG_COUNT        2
0082 #define XFS_LINK_LOG_COUNT      2
0083 #define XFS_RENAME_LOG_COUNT        2
0084 #define XFS_WRITE_LOG_COUNT     2
0085 #define XFS_ADDAFORK_LOG_COUNT      2
0086 #define XFS_ATTRINVAL_LOG_COUNT     1
0087 #define XFS_ATTRSET_LOG_COUNT       3
0088 #define XFS_ATTRRM_LOG_COUNT        3
0089 
0090 /*
0091  * Original log operation counts were overestimated in the early days of
0092  * reflink.  These are retained here purely for minimum log size calculations
0093  * and must not be used for runtime reservations.
0094  */
0095 #define XFS_ITRUNCATE_LOG_COUNT_REFLINK 8
0096 #define XFS_WRITE_LOG_COUNT_REFLINK 8
0097 
0098 void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp);
0099 uint xfs_allocfree_block_count(struct xfs_mount *mp, uint num_ops);
0100 
0101 unsigned int xfs_calc_itruncate_reservation_minlogsize(struct xfs_mount *mp);
0102 unsigned int xfs_calc_write_reservation_minlogsize(struct xfs_mount *mp);
0103 unsigned int xfs_calc_qm_dqalloc_reservation_minlogsize(struct xfs_mount *mp);
0104 
0105 #endif  /* __XFS_TRANS_RESV_H__ */