xfs: Introduce a new transaction for shrinking fs data section
PATCH 10/15 xfs: Introduce a new transaction for shrinking fs data section
This is a new transaction which would be used for shrinking fs data section.
Signed-off-by Jie Liu <[email protected]>
--- fs/xfs/xfs_mount.h | 1 + fs/xfs/xfs_trans.c | 16 ++++++++++++++++ fs/xfs/xfs_trans.h | 7 +++++-- fs/xfs/xfs_trans_space.h | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-)
fs/xfs/xfs_mount.h +1 -0
@@ -41,6 +41,7 @@ typedef struct xfs_trans_reservations {uint tr_growrtzero;/* grow realtime zeroing */ uint tr_growrtfree;/* grow realtime freeing */ uint tr_setagstate;/* set a.g. state trans */ +uint tr_shrinkdata;/* fs data section shrink trans */ } xfs_trans_reservations_t;#ifndef __KERNEL__
fs/xfs/xfs_trans.c +16 -0
@@ -542,6 +542,21 @@ xfs_calc_set_agstate_reservation( }/* +* Shrinking the data section of the filesystem. +* superblock +* agi and agf +* allocation btrees +*/ +STATIC uint +xfs_calc_shrinkdata_reservation ( +struct xfs_mount *mp) +{ +return mp->m_sb.sb_sectsize *3 + +XFS_ALLOCFREE_LOG_RES (mp,1 ) + +128 * (3 +XFS_ALLOCFREE_LOG_COUNT (mp,1 )); +} + +/* * Initialize the precomputed transaction reservation values * in the mount structure. */
@@ -573,6 +588,7 @@ xfs_trans_init( resp->tr_growrtzero =xfs_calc_growrtzero_reservation (mp); resp->tr_growrtfree =xfs_calc_growrtfree_reservation (mp); resp->tr_setagstate =xfs_calc_set_agstate_reservation (mp); + resp->tr_shrinkdata =xfs_calc_shrinkdata_reservation (mp); }/*
fs/xfs/xfs_trans.h +5 -2
@@ -109,7 +109,8 @@ typedef struct xfs_trans_header {#define XFS_TRANS_CHECKPOINT 42#define XFS_TRANS_SET_AGSTATE 43#define XFS_TRANS_SWAPINO 44 -#define XFS_TRANS_TYPE_MAX 44 +#define XFS_TRANS_SHRINKFS 45 +#define XFS_TRANS_TYPE_MAX 45/* new transaction types need to be reflected in xfs_logprint(8) */ #define XFS_TRANS_TYPES \
@@ -156,7 +157,8 @@ typedef struct xfs_trans_header { { XFS_TRANS_DUMMY2, "DUMMY2" }, \ { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" }, \ { XFS_TRANS_SET_AGSTATE, "SET_AGSTATE" }, \ - { XFS_TRANS_SWAPINO, "SWAPINO" } + { XFS_TRANS_SWAPINO, "SWAPINO" }, \ + { XFS_TRANS_SHRINKFS, "SHRINKFS" }/* * This structure is used to track log items associated with
@@ -267,6 +269,7 @@ struct xfs_log_item_desc {#define XFS_ATTRRM_LOG_RES (mp) ((mp)->m_reservations.tr_attrrm)#define XFS_CLEAR_AGI_BUCKET_LOG_RES (mp) ((mp)->m_reservations.tr_clearagi)#define XFS_SETAGSTATE_LOG_RES (mp) ((mp)->m_reservations.tr_setagstate) +#define XFS_SHRINKDATA_LOG_RES (mp) ((mp)->m_reservations.tr_shrinkdata)/* * Various log count values.
fs/xfs/xfs_trans_space.h +2 -0
@@ -82,5 +82,7 @@ (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))#define XFS_SYMLINK_SPACE_RES (mp,nl,b) \ (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b)) +#define XFS_SHRINKFS_SPACE_RES (mp) \ + (2 * XFS_AG_MAXLEVELS(mp))#endif /* __XFS_TRANS_SPACE_H__ */
Signature · 6 lines
1.7.4.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs