Convert the calculation of sync incore superblock counters transaction log
space reservation from
runtime to mount time.
Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
---
fs/xfs/xfs_mount.c | 4 ++--
fs/xfs/xfs_mount.h | 1 +
fs/xfs/xfs_trans.c | 13 +++++++++++++
fs/xfs/xfs_trans.h | 1 +
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index b39fa96..a596705 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1550,8 +1550,8 @@ xfs_log_sbcount(xfs_mount_t *mp)
return 0;
tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_COUNT, KM_SLEEP);
- error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
- XFS_DEFAULT_LOG_COUNT);
+ error = xfs_trans_reserve(tp, 0, XFS_SYNC_ICSBCOUNT_LOG_RES(mp),
+ 0, 0, XFS_DEFAULT_LOG_COUNT);
if (error) {
xfs_trans_cancel(tp, 0);
return error;
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index c5abd86..d119a56 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -45,6 +45,7 @@ typedef struct xfs_trans_reservations {
uint tr_qm_dqalloc; /* allocate quota on disk */
uint tr_qm_quotaoff; /* turn quota off */
uint tr_qm_equotaoff;/* end of turn quota off */
+ uint tr_sicsbcount; /* sync incore super block counters */
} xfs_trans_reservations_t;
#ifndef __KERNEL__
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index eb1e9ea..ae48a8d 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -604,6 +604,18 @@ xfs_calc_qm_quotaoff_end_reservation(
}
/*
+ * Syncing the incore super block counters to disk.
+ * the super block to reflect the allocated inodes,
+ * free inodes/free data blocks: sector size
+ */
+STATIC uint
+xfs_calc_sync_icsbcount_reservation(
+ struct xfs_mount *mp)
+{
+ return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
+}
+
+/*
* Initialize the precomputed transaction reservation values
* in the mount structure.
*/
@@ -639,6 +651,7 @@ xfs_trans_init(
resp->tr_qm_dqalloc = xfs_calc_qm_dqalloc_reservation(mp);
resp->tr_qm_quotaoff = xfs_calc_qm_quotaoff_reservation(mp);
resp->tr_qm_equotaoff = xfs_calc_qm_quotaoff_end_reservation(mp);
+ resp->tr_sicsbcount = xfs_calc_sync_icsbcount_reservation(mp);
}
/*
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 77ccc36..637f59b 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -267,6 +267,7 @@ struct xfs_log_item_desc {
#define XFS_QM_DQALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_qm_dqalloc)
#define XFS_QM_QUOTAOFF_LOG_RES(mp) ((mp)->m_reservations.tr_qm_quotaoff)
#define XFS_QM_QUOTAOFF_END_LOG_RES(mp)
((mp)->m_reservations.tr_qm_equotaoff)
+#define XFS_SYNC_ICSBCOUNT_LOG_RES(mp) ((mp)->m_reservations.tr_sicsbcount)
/*
* Various log count values.
--
1.7.9.5
|