2018-06-06 10:42:14 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-08-12 18:49:32 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*/
|
|
|
|
#ifndef __XFS_TRANS_RESV_H__
|
|
|
|
#define __XFS_TRANS_RESV_H__
|
|
|
|
|
|
|
|
struct xfs_mount;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* structure for maintaining pre-calculated transaction reservations.
|
|
|
|
*/
|
2013-08-12 18:49:56 +08:00
|
|
|
struct xfs_trans_res {
|
|
|
|
uint tr_logres; /* log space unit in bytes per log ticket */
|
|
|
|
int tr_logcount; /* number of log operations per log ticket */
|
|
|
|
int tr_logflags; /* log flags, currently only used for indicating
|
|
|
|
* a reservation request is permanent or not */
|
|
|
|
};
|
|
|
|
|
2013-08-12 18:49:32 +08:00
|
|
|
struct xfs_trans_resv {
|
2013-08-12 18:49:56 +08:00
|
|
|
struct xfs_trans_res tr_write; /* extent alloc trans */
|
|
|
|
struct xfs_trans_res tr_itruncate; /* truncate trans */
|
|
|
|
struct xfs_trans_res tr_rename; /* rename trans */
|
|
|
|
struct xfs_trans_res tr_link; /* link trans */
|
|
|
|
struct xfs_trans_res tr_remove; /* unlink trans */
|
|
|
|
struct xfs_trans_res tr_symlink; /* symlink trans */
|
|
|
|
struct xfs_trans_res tr_create; /* create trans */
|
2013-12-18 08:22:40 +08:00
|
|
|
struct xfs_trans_res tr_create_tmpfile; /* create O_TMPFILE trans */
|
2013-08-12 18:49:56 +08:00
|
|
|
struct xfs_trans_res tr_mkdir; /* mkdir trans */
|
|
|
|
struct xfs_trans_res tr_ifree; /* inode free trans */
|
|
|
|
struct xfs_trans_res tr_ichange; /* inode update trans */
|
|
|
|
struct xfs_trans_res tr_growdata; /* fs data section grow trans */
|
|
|
|
struct xfs_trans_res tr_addafork; /* add inode attr fork trans */
|
|
|
|
struct xfs_trans_res tr_writeid; /* write setuid/setgid file */
|
|
|
|
struct xfs_trans_res tr_attrinval; /* attr fork buffer
|
|
|
|
* invalidation */
|
|
|
|
struct xfs_trans_res tr_attrsetm; /* set/create an attribute at
|
|
|
|
* mount time */
|
|
|
|
struct xfs_trans_res tr_attrsetrt; /* set/create an attribute at
|
|
|
|
* runtime */
|
|
|
|
struct xfs_trans_res tr_attrrm; /* remove an attribute */
|
|
|
|
struct xfs_trans_res tr_clearagi; /* clear agi unlinked bucket */
|
|
|
|
struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */
|
|
|
|
struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */
|
|
|
|
struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */
|
|
|
|
struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */
|
|
|
|
struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */
|
|
|
|
struct xfs_trans_res tr_sb; /* modify superblock */
|
2013-08-12 18:49:57 +08:00
|
|
|
struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */
|
2013-08-12 18:49:32 +08:00
|
|
|
};
|
|
|
|
|
2013-08-12 18:49:59 +08:00
|
|
|
/* shorthand way of accessing reservation structure */
|
|
|
|
#define M_RES(mp) (&(mp)->m_resv)
|
|
|
|
|
2013-08-12 18:49:32 +08:00
|
|
|
/*
|
|
|
|
* Per-directory log reservation for any directory change.
|
|
|
|
* dir blocks: (1 btree block per level + data block + free block) * dblock size
|
|
|
|
* bmap btree: (levels + 2) * max depth * block size
|
|
|
|
* v2 directory blocks can be fragmented below the dirblksize down to the fsb
|
|
|
|
* size, so account for that in the DAENTER macros.
|
|
|
|
*/
|
|
|
|
#define XFS_DIROP_LOG_RES(mp) \
|
|
|
|
(XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \
|
|
|
|
(XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)))
|
|
|
|
#define XFS_DIROP_LOG_COUNT(mp) \
|
|
|
|
(XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \
|
|
|
|
XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Various log count values.
|
|
|
|
*/
|
|
|
|
#define XFS_DEFAULT_LOG_COUNT 1
|
|
|
|
#define XFS_DEFAULT_PERM_LOG_COUNT 2
|
|
|
|
#define XFS_ITRUNCATE_LOG_COUNT 2
|
|
|
|
#define XFS_INACTIVE_LOG_COUNT 2
|
|
|
|
#define XFS_CREATE_LOG_COUNT 2
|
2013-12-18 08:22:40 +08:00
|
|
|
#define XFS_CREATE_TMPFILE_LOG_COUNT 2
|
2013-08-12 18:49:32 +08:00
|
|
|
#define XFS_MKDIR_LOG_COUNT 3
|
|
|
|
#define XFS_SYMLINK_LOG_COUNT 3
|
|
|
|
#define XFS_REMOVE_LOG_COUNT 2
|
|
|
|
#define XFS_LINK_LOG_COUNT 2
|
|
|
|
#define XFS_RENAME_LOG_COUNT 2
|
|
|
|
#define XFS_WRITE_LOG_COUNT 2
|
|
|
|
#define XFS_ADDAFORK_LOG_COUNT 2
|
|
|
|
#define XFS_ATTRINVAL_LOG_COUNT 1
|
|
|
|
#define XFS_ATTRSET_LOG_COUNT 3
|
|
|
|
#define XFS_ATTRRM_LOG_COUNT 3
|
|
|
|
|
2022-04-26 09:38:14 +08:00
|
|
|
/*
|
|
|
|
* Original log operation counts were overestimated in the early days of
|
|
|
|
* reflink. These are retained here purely for minimum log size calculations
|
|
|
|
* and must not be used for runtime reservations.
|
|
|
|
*/
|
|
|
|
#define XFS_ITRUNCATE_LOG_COUNT_REFLINK 8
|
|
|
|
#define XFS_WRITE_LOG_COUNT_REFLINK 8
|
|
|
|
|
2013-08-12 18:49:32 +08:00
|
|
|
void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp);
|
2022-04-26 09:38:24 +08:00
|
|
|
uint xfs_allocfree_block_count(struct xfs_mount *mp, uint num_ops);
|
2013-08-12 18:49:32 +08:00
|
|
|
|
2022-04-26 09:38:14 +08:00
|
|
|
unsigned int xfs_calc_itruncate_reservation_minlogsize(struct xfs_mount *mp);
|
|
|
|
unsigned int xfs_calc_write_reservation_minlogsize(struct xfs_mount *mp);
|
|
|
|
unsigned int xfs_calc_qm_dqalloc_reservation_minlogsize(struct xfs_mount *mp);
|
|
|
|
|
2013-08-12 18:49:32 +08:00
|
|
|
#endif /* __XFS_TRANS_RESV_H__ */
|